@@ -392,8 +392,8 @@ class BpmnDocument extends DOMDocument implements BpmnDocumentInterface
392392 DataInputAssociationInterface::BPMN_PROPERTY_TRANSFORMATION => ['1 ' , [self ::BPMN_MODEL , DataInputAssociationInterface::BPMN_PROPERTY_TRANSFORMATION ]],
393393 ],
394394 ],
395- DataInputAssociationInterface::BPMN_PROPERTY_TARGET_REF => [self ::IS_REFERENCE , []],
396- DataInputAssociationInterface::BPMN_PROPERTY_SOURCES_REF => [self ::IS_REFERENCE , []],
395+ DataInputAssociationInterface::BPMN_PROPERTY_TARGET_REF => [self ::IS_REFERENCE_OPTIONAL , []],
396+ DataInputAssociationInterface::BPMN_PROPERTY_SOURCES_REF => [self ::IS_REFERENCE_OPTIONAL , []],
397397 DataInputAssociationInterface::BPMN_PROPERTY_TRANSFORMATION => [
398398 FormalExpressionInterface::class,
399399 [
@@ -546,6 +546,8 @@ class BpmnDocument extends DOMDocument implements BpmnDocumentInterface
546546
547547 const IS_REFERENCE = 'isReference ' ;
548548
549+ const IS_REFERENCE_OPTIONAL = 'isReferenceOptional ' ;
550+
549551 const TEXT_PROPERTY = 'textProperty ' ;
550552
551553 const IS_ARRAY = 'isArray ' ;
@@ -703,7 +705,7 @@ public function hasBpmnInstance($id)
703705 *
704706 * @return \ProcessMaker\Nayra\Contracts\Bpmn\EntityInterface
705707 */
706- public function getElementInstanceById ($ id )
708+ public function getElementInstanceById ($ id, ? bool $ isOptional = false )
707709 {
708710 $ this ->bpmnElements [$ id ] = isset ($ this ->bpmnElements [$ id ])
709711 ? $ this ->bpmnElements [$ id ]
@@ -712,7 +714,7 @@ public function getElementInstanceById($id)
712714 ? $ element ->getBpmnElementInstance ()
713715 : null
714716 );
715- if ($ this ->bpmnElements [$ id ] === null && empty ($ element )) {
717+ if ($ this ->bpmnElements [$ id ] === null && empty ($ element ) && ! $ isOptional ) {
716718 throw new ElementNotFoundException ($ id );
717719 }
718720
0 commit comments