Skip to content

Commit 62e6510

Browse files
committed
fix: Allow missing target or source references for backward compatibility
1 parent a9d98e0 commit 62e6510

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/ProcessMaker/Nayra/Storage/BpmnDocument.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/ProcessMaker/Nayra/Storage/BpmnElement.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ public function getBpmnElementInstance($owner = null)
4444
return null;
4545
}
4646
list($classInterface, $mapProperties) = $map[$this->namespaceURI][$this->localName];
47-
if ($classInterface === BpmnDocument::IS_REFERENCE) {
48-
$bpmnElement = $this->ownerDocument->getElementInstanceById($this->nodeValue);
49-
$this->bpmn = $bpmnElement;
47+
if ($classInterface === BpmnDocument::IS_REFERENCE || $classInterface === BpmnDocument::IS_REFERENCE_OPTIONAL) {
48+
$bpmnElement = $this->ownerDocument->getElementInstanceById(
49+
$this->nodeValue,
50+
$classInterface === BpmnDocument::IS_REFERENCE_OPTIONAL
51+
);
5052
} elseif ($classInterface === BpmnDocument::TEXT_PROPERTY) {
5153
$bpmnElement = $this->nodeValue;
5254
$owner->setProperty($this->nodeName, $this->nodeValue);

0 commit comments

Comments
 (0)