diff --git a/src/ProcessMaker/Nayra/Storage/BpmnDocument.php b/src/ProcessMaker/Nayra/Storage/BpmnDocument.php index b3e2f55..0425d35 100644 --- a/src/ProcessMaker/Nayra/Storage/BpmnDocument.php +++ b/src/ProcessMaker/Nayra/Storage/BpmnDocument.php @@ -392,8 +392,8 @@ class BpmnDocument extends DOMDocument implements BpmnDocumentInterface DataInputAssociationInterface::BPMN_PROPERTY_TRANSFORMATION => ['1', [self::BPMN_MODEL, DataInputAssociationInterface::BPMN_PROPERTY_TRANSFORMATION]], ], ], - DataInputAssociationInterface::BPMN_PROPERTY_TARGET_REF => [self::IS_REFERENCE, []], - DataInputAssociationInterface::BPMN_PROPERTY_SOURCES_REF => [self::IS_REFERENCE, []], + DataInputAssociationInterface::BPMN_PROPERTY_TARGET_REF => [self::IS_REFERENCE_OPTIONAL, []], + DataInputAssociationInterface::BPMN_PROPERTY_SOURCES_REF => [self::IS_REFERENCE_OPTIONAL, []], DataInputAssociationInterface::BPMN_PROPERTY_TRANSFORMATION => [ FormalExpressionInterface::class, [ @@ -546,6 +546,8 @@ class BpmnDocument extends DOMDocument implements BpmnDocumentInterface const IS_REFERENCE = 'isReference'; + const IS_REFERENCE_OPTIONAL = 'isReferenceOptional'; + const TEXT_PROPERTY = 'textProperty'; const IS_ARRAY = 'isArray'; @@ -703,7 +705,7 @@ public function hasBpmnInstance($id) * * @return \ProcessMaker\Nayra\Contracts\Bpmn\EntityInterface */ - public function getElementInstanceById($id) + public function getElementInstanceById($id, ?bool $isOptional = false) { $this->bpmnElements[$id] = isset($this->bpmnElements[$id]) ? $this->bpmnElements[$id] @@ -712,7 +714,7 @@ public function getElementInstanceById($id) ? $element->getBpmnElementInstance() : null ); - if ($this->bpmnElements[$id] === null && empty($element)) { + if ($this->bpmnElements[$id] === null && empty($element) && !$isOptional) { throw new ElementNotFoundException($id); } diff --git a/src/ProcessMaker/Nayra/Storage/BpmnElement.php b/src/ProcessMaker/Nayra/Storage/BpmnElement.php index c7b71e1..121736d 100644 --- a/src/ProcessMaker/Nayra/Storage/BpmnElement.php +++ b/src/ProcessMaker/Nayra/Storage/BpmnElement.php @@ -44,9 +44,11 @@ public function getBpmnElementInstance($owner = null) return null; } list($classInterface, $mapProperties) = $map[$this->namespaceURI][$this->localName]; - if ($classInterface === BpmnDocument::IS_REFERENCE) { - $bpmnElement = $this->ownerDocument->getElementInstanceById($this->nodeValue); - $this->bpmn = $bpmnElement; + if ($classInterface === BpmnDocument::IS_REFERENCE || $classInterface === BpmnDocument::IS_REFERENCE_OPTIONAL) { + $bpmnElement = $this->ownerDocument->getElementInstanceById( + $this->nodeValue, + $classInterface === BpmnDocument::IS_REFERENCE_OPTIONAL + ); } elseif ($classInterface === BpmnDocument::TEXT_PROPERTY) { $bpmnElement = $this->nodeValue; $owner->setProperty($this->nodeName, $this->nodeValue);