Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SetWeeeRendererInFormObserver.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Weee\Observer;
7 
9 
11 {
15  protected $weeeTax;
16 
20  protected $layout;
21 
26  public function __construct(
27  \Magento\Framework\View\LayoutInterface $layout,
28  \Magento\Weee\Model\Tax $weeeTax
29  ) {
30  $this->layout = $layout;
31  $this->weeeTax = $weeeTax;
32  }
33 
40  public function execute(\Magento\Framework\Event\Observer $observer)
41  {
43  $form = $observer->getEvent()->getForm();
44 
45  $attributes = $this->weeeTax->getWeeeAttributeCodes(true);
46  foreach ($attributes as $code) {
47  $weeeTax = $form->getElement($code);
48  if ($weeeTax) {
49  $weeeTax->setRenderer($this->layout->createBlock(\Magento\Weee\Block\Renderer\Weee\Tax::class));
50  }
51  }
52 
53  return $this;
54  }
55 }
__construct(\Magento\Framework\View\LayoutInterface $layout, \Magento\Weee\Model\Tax $weeeTax)
$attributes
Definition: matrix.phtml:13
$code
Definition: info.phtml:12