Esempio n. 1
0
 /**
  * @covers \Magento\Framework\View\Layout\ScheduledStructure::flushScheduledStructure
  */
 public function testFlushScheduledStructure()
 {
     $this->assertNotEmpty($this->_model->getPaths());
     $this->assertNotEmpty($this->_model->getElements());
     $this->assertNotEmpty($this->_model->getStructure());
     $this->_model->flushScheduledStructure();
     $this->assertEmpty($this->_model->getPaths());
     $this->assertEmpty($this->_model->getElements());
     $this->assertEmpty($this->_model->getStructure());
 }
Esempio n. 2
0
 /**
  * Destroy previous element with same name and all its children, if new element overrides it
  *
  * This is a workaround to handle situation, when an element emerges with name of element that already exists.
  * In this case we destroy entire structure of the former element and replace with the new one.
  *
  * @param Layout\ScheduledStructure $scheduledStructure
  * @param string $name
  * @param string $path
  * @return void
  */
 protected function _overrideElementWorkaround(Layout\ScheduledStructure $scheduledStructure, $name, $path)
 {
     if ($scheduledStructure->hasStructureElement($name)) {
         $scheduledStructure->setStructureElementData($name, []);
         foreach ($scheduledStructure->getPaths() as $potentialChild => $childPath) {
             if (0 === strpos($childPath, "{$path}/")) {
                 $scheduledStructure->unsetPathElement($potentialChild);
                 $scheduledStructure->unsetStructureElement($potentialChild);
             }
         }
     }
 }
Esempio n. 3
0
 /**
  * Destroy previous element with same name and all its children, if new element overrides it
  *
  * This is a workaround to handle situation, when an element emerges with name of element that already exists.
  * In this case we destroy entire structure of the former element and replace with the new one.
  *
  * @param string $name
  * @param string $path
  * @return void
  */
 protected function _overrideElementWorkaround($name, $path)
 {
     if ($this->_scheduledStructure->hasStructureElement($name)) {
         foreach ($this->_scheduledStructure->getPaths() as $potentialChild => $childPath) {
             if (0 === strpos($childPath, "{$path}/")) {
                 $this->_scheduledStructure->unsetPathElement($potentialChild);
                 $this->_scheduledStructure->unsetStructureElement($potentialChild);
             }
         }
     }
 }