/** * Set container-specific data to structure element * * @param \Magento\Framework\View\Layout\Data\Structure $structure * @param string $elementName * @param array $options * @return void */ public function generateContainer(Layout\Data\Structure $structure, $elementName, $options) { $structure->setAttribute($elementName, Layout\Element::CONTAINER_OPT_LABEL, $options[Layout\Element::CONTAINER_OPT_LABEL]); unset($options[Layout\Element::CONTAINER_OPT_LABEL]); unset($options['type']); $this->validateOptions($options); foreach ($options as $key => $value) { $structure->setAttribute($elementName, $key, $value); } }
/** * Create block and set related data * * @param \Magento\Framework\View\Layout\ScheduledStructure $scheduledStructure * @param \Magento\Framework\View\Layout\Data\Structure $structure * @param string $elementName * @return \Magento\Framework\View\Element\AbstractBlock */ protected function generateBlock(Layout\ScheduledStructure $scheduledStructure, Layout\Data\Structure $structure, $elementName) { list(, $data) = $scheduledStructure->getElement($elementName); $attributes = $data['attributes']; if (!empty($attributes['group'])) { $structure->addToParentGroup($elementName, $attributes['group']); } if (!empty($attributes['display'])) { $structure->setAttribute($elementName, 'display', $attributes['display']); } // create block $className = $attributes['class']; $block = $this->createBlock($className, $elementName, ['data' => $this->evaluateArguments($data['arguments'])]); if (!empty($attributes['template'])) { $block->setTemplate($attributes['template']); } if (!empty($attributes['ttl'])) { $ttl = (int) $attributes['ttl']; $block->setTtl($ttl); } return $block; }