Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @var BlockFactory
- */
- protected $blockWrapperFactory;
- /**
- * Constructor
- *
- * @param TemplateContext $context
- * @param UiComponentInterface $component
- * @param BlockFactory $blockWrapperFactory
- * @param array $data
- */
- public function __construct(
- TemplateContext $context,
- UiComponentInterface $component,
- BlockFactory $blockWrapperFactory,
- array $data = []
- ) {
- $this->component = $component;
- $this->blockWrapperFactory = $blockWrapperFactory;
- $this->setNameInLayout($this->component->getName());
- parent::__construct($context, $data);
- }
- /**
- * Render block HTML
- *
- * @return string
- */
- protected function _toHtml()
- {
- foreach ($this->getChildNames() as $childName) {
- $childBlock = $this->getLayout()->getBlock($childName);
- if ($childBlock) {
- $wrapper = $this->blockWrapperFactory->create([
- 'block' => $childBlock,
- 'data' => [
- 'name' => 'block_' . $childName
- ]
- ]);
- $this->component->addComponent('block_' . $childName, $wrapper);
- }
- }
- $result = $this->component->render();
- return (string)$result;
- }
Add Comment
Please, Sign In to add comment