Skip to content

Commit

Permalink
MAGETWO-54935: [Github#1931] Cancellation of element removal in layou…
Browse files Browse the repository at this point in the history
…ts doesn't work
  • Loading branch information
Evgeniy Kolesov authored and Tommy Quissens committed Mar 23, 2018
1 parent 4dfef9f commit 44746e0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
14 changes: 8 additions & 6 deletions lib/internal/Magento/Framework/View/Layout/Reader/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,15 @@ protected function scheduleReference(
$elementRemove = filter_var($currentElement->getAttribute('remove'), FILTER_VALIDATE_BOOLEAN);
if ($elementRemove) {
$scheduledStructure->setElementToRemoveList($elementName);
} else {
$data = $scheduledStructure->getStructureElementData($elementName, []);
$data['attributes'] = $this->mergeBlockAttributes($data, $currentElement);
$this->updateScheduledData($currentElement, $data);
$this->evaluateArguments($currentElement, $data);
$scheduledStructure->setStructureElementData($elementName, $data);
return;
} elseif ($currentElement->getAttribute('remove')) {
$scheduledStructure->unsetElementFromListToRemove($elementName);
}
$data = $scheduledStructure->getStructureElementData($elementName, []);
$data['attributes'] = $this->mergeBlockAttributes($data, $currentElement);
$this->updateScheduledData($currentElement, $data);
$this->evaluateArguments($currentElement, $data);
$scheduledStructure->setStructureElementData($elementName, $data);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,12 @@ protected function containerReference(
) {
$containerName = $currentElement->getAttribute('name');
$containerRemove = filter_var($currentElement->getAttribute('remove'), FILTER_VALIDATE_BOOLEAN);

if ($containerRemove) {
$scheduledStructure->setElementToRemoveList($containerName);
} else {
$this->mergeContainerAttributes($scheduledStructure, $currentElement);
return;
} elseif ($currentElement->getAttribute('remove')) {
$scheduledStructure->unsetElementFromListToRemove($containerName);
}
$this->mergeContainerAttributes($scheduledStructure, $currentElement);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ public function testProcessReference(
$setCondition,
$setRemoveCondition
) {
if ($literal == 'referenceBlock' && $remove == 'false') {
$this->scheduledStructure->expects($this->once())
->method('unsetElementFromListToRemove')
->with($literal);
}

$this->context->expects($this->once())->method('getScheduledStructure')
->will($this->returnValue($this->scheduledStructure));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ public function testProcess(
->with($contextMock, $elementCurrent)
->willReturnSelf();

if ($elementCurrent->getAttribute('remove') == 'false') {
$scheduledStructureMock->expects($this->once())
->method('unsetElementFromListToRemove')
->with($elementCurrent->getAttribute('name'));
}

$this->container->interpret($contextMock, $elementCurrent);
}

Expand Down

0 comments on commit 44746e0

Please sign in to comment.