Guest User

Untitled

a guest
Jun 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. /**
  2. * @var BlockFactory
  3. */
  4. protected $blockWrapperFactory;
  5.  
  6. /**
  7. * Constructor
  8. *
  9. * @param TemplateContext $context
  10. * @param UiComponentInterface $component
  11. * @param BlockFactory $blockWrapperFactory
  12. * @param array $data
  13. */
  14. public function __construct(
  15. TemplateContext $context,
  16. UiComponentInterface $component,
  17. BlockFactory $blockWrapperFactory,
  18. array $data = []
  19. ) {
  20. $this->component = $component;
  21. $this->blockWrapperFactory = $blockWrapperFactory;
  22. $this->setNameInLayout($this->component->getName());
  23. parent::__construct($context, $data);
  24. }
  25.  
  26. /**
  27. * Render block HTML
  28. *
  29. * @return string
  30. */
  31. protected function _toHtml()
  32. {
  33. foreach ($this->getChildNames() as $childName) {
  34. $childBlock = $this->getLayout()->getBlock($childName);
  35. if ($childBlock) {
  36. $wrapper = $this->blockWrapperFactory->create([
  37. 'block' => $childBlock,
  38. 'data' => [
  39. 'name' => 'block_' . $childName
  40. ]
  41. ]);
  42. $this->component->addComponent('block_' . $childName, $wrapper);
  43. }
  44. }
  45.  
  46. $result = $this->component->render();
  47. return (string)$result;
  48. }
Add Comment
Please, Sign In to add comment