示例#1
0
 public function testSetElementAttribute()
 {
     $elementName1 = 'elementName1';
     $attributeName1 = 'attributeName1';
     $attributeValue1 = 'attributeValue1';
     $elementName2 = 'elementName2';
     $attributeName2 = 'attributeName2';
     $attributeValue2 = 'attributeValue2';
     $expected = ['elementName1' => ['attributeName1' => 'attributeValue1'], 'elementName2' => ['attributeName2' => 'attributeValue2']];
     $this->structure->setElementAttribute($elementName1, $attributeName1, $attributeValue1);
     $this->structure->setElementAttribute($elementName2, $attributeName2, $attributeValue2);
     $this->assertEquals($expected, $this->structure->getElementAttributes());
     $expectedAfterRemove = ['elementName2' => ['attributeName2' => 'attributeValue2']];
     $this->structure->setElementAttribute($elementName1, $attributeName1, false);
     $this->structure->processRemoveElementAttributes();
     $this->assertEquals($expectedAfterRemove, $this->structure->getElementAttributes());
 }
示例#2
0
 /**
  * Process all element attributes
  *
  * @param \Magento\Framework\View\Page\Config\Structure $pageStructure
  * @return $this
  */
 protected function processElementAttributes(Structure $pageStructure)
 {
     foreach ($pageStructure->getElementAttributes() as $element => $attributes) {
         foreach ($attributes as $name => $value) {
             $this->pageConfig->setElementAttribute($element, $name, $value);
         }
     }
     return $this;
 }