Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
HtmlContent.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Ui\Component;
7 
11 
13 {
14  const NAME = 'html_content';
15 
19  protected $block;
20 
27  public function __construct(
30  array $components = [],
31  array $data = []
32  ) {
33  parent::__construct($context, $components, $data);
34  $this->block = $block;
35  }
36 
42  public function getBlock()
43  {
44  return $this->block;
45  }
46 
52  public function getComponentName()
53  {
54  return static::NAME;
55  }
56 
60  public function render()
61  {
62  return $this->getData('config/content') ?: $this->block->toHtml();
63  }
64 
68  public function getConfiguration()
69  {
70  $configuration = parent::getConfiguration();
71  if ($this->getData('wrapper/canShow') !== false) {
72  if ($this->getData('isAjaxLoaded')) {
73  $configuration['url'] = $this->getData('url');
74  } else {
75  if (!$this->getData('config/content')) { //add html block cony into cache
76  $content = $this->block->toHtml();
77  $this->addData(['config' => ['content' => $content]]);
78  }
79 
80  $configuration['content'] = $this->getData('config/content');
81  }
82  if ($this->getData('wrapper')) {
83  $configuration = array_merge($this->getData(), $this->getData('wrapper'));
84  }
85  }
86  return $configuration;
87  }
88 }
$configuration
Definition: index.php:33
__construct(ContextInterface $context, BlockInterface $block, array $components=[], array $data=[])
Definition: HtmlContent.php:27