/** * {@inheritdoc} * * @param Context $readerContext * @param Layout\Element $currentElement * @return $this */ public function interpret(Context $readerContext, Layout\Element $currentElement) { $scheduledStructure = $readerContext->getScheduledStructure(); $referenceName = $this->layoutHelper->scheduleStructure($readerContext->getScheduledStructure(), $currentElement, $currentElement->getParent(), ['attributes' => $this->getAttributes($currentElement)]); $scheduledStructure->setStructureElementData($referenceName, ['attributes' => $this->getAttributes($currentElement)]); $configPath = (string) $currentElement->getAttribute('ifconfig'); if (!empty($configPath)) { $scheduledStructure->setElementToIfconfigList($referenceName, $configPath, $this->scopeType); } return $this; }
/** * {@inheritdoc} * * @param Context $readerContext * @param Layout\Element $currentElement * @param Layout\Element $parentElement * @return $this */ public function interpret(Context $readerContext, Layout\Element $currentElement) { switch ($currentElement->getName()) { case self::TYPE_CONTAINER: $this->helper->scheduleStructure($readerContext->getScheduledStructure(), $currentElement, $currentElement->getParent()); $this->mergeContainerAttributes($readerContext->getScheduledStructure(), $currentElement); break; case self::TYPE_REFERENCE_CONTAINER: $this->containerReference($readerContext->getScheduledStructure(), $currentElement); break; default: break; } $this->readerPool->interpret($readerContext, $currentElement); return $this; }
/** * @param string $currentNodeName * @param string $actualNodeName * @param int $unsetPathElementCount * @param int $unsetStructureElementCount * @return void * * @dataProvider scheduleStructureDataProvider */ public function testScheduleStructure($currentNodeName, $actualNodeName, $unsetPathElementCount, $unsetStructureElementCount) { $parentNodeName = 'parent_node'; $currentNodeAs = 'currentNode'; $after = 'after'; $block = 'block'; $testPath = 'test_path'; $potentialChild = 'potential_child'; $this->scheduledStructureMock->expects($this->once())->method('hasPath')->with($parentNodeName)->will($this->returnValue(true)); $this->scheduledStructureMock->expects($this->any())->method('hasStructureElement')->with($actualNodeName)->will($this->returnValue(true)); $this->scheduledStructureMock->expects($this->once())->method('setPathElement')->with($actualNodeName, $testPath . '/' . $actualNodeName)->will($this->returnValue(true)); $this->scheduledStructureMock->expects($this->once())->method('setStructureElement')->with($actualNodeName, [$block, $currentNodeAs, $parentNodeName, $after, true]); $this->scheduledStructureMock->expects($this->once())->method('getPath')->with($parentNodeName)->will($this->returnValue('test_path')); $this->scheduledStructureMock->expects($this->once())->method('getPaths')->will($this->returnValue([$potentialChild => $testPath . '/' . $currentNodeName . '/'])); $this->scheduledStructureMock->expects($this->exactly($unsetPathElementCount))->method('unsetPathElement')->with($potentialChild); $this->scheduledStructureMock->expects($this->exactly($unsetStructureElementCount))->method('unsetStructureElement')->with($potentialChild); $currentNode = new \Magento\Framework\View\Layout\Element('<' . $block . ' name="' . $currentNodeName . '" as="' . $currentNodeAs . '" after="' . $after . '"/>'); $parentNode = new \Magento\Framework\View\Layout\Element('<' . $block . ' name="' . $parentNodeName . '"/>'); $result = $this->helper->scheduleStructure($this->scheduledStructureMock, $currentNode, $parentNode); $this->assertEquals($actualNodeName, $result); }
/** * Process block element their attributes and children * * @param Layout\ScheduledStructure $scheduledStructure * @param Layout\Element $currentElement * @return void */ protected function scheduleBlock(Layout\ScheduledStructure $scheduledStructure, Layout\Element $currentElement) { $elementName = $this->helper->scheduleStructure($scheduledStructure, $currentElement, $currentElement->getParent()); $data = $scheduledStructure->getStructureElementData($elementName, []); $data['attributes'] = $this->getAttributes($currentElement); $this->updateScheduledData($currentElement, $data); $this->evaluateArguments($currentElement, $data); $scheduledStructure->setStructureElementData($elementName, $data); $configPath = (string) $currentElement->getAttribute('ifconfig'); if (!empty($configPath)) { $scheduledStructure->setElementToIfconfigList($elementName, $configPath, $this->scopeType); } }