Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CheckThemeIsAssignedObserver.php
Go to the documentation of this file.
1 <?php
7 namespace Magento\Theme\Observer;
8 
12 
14 {
18  protected $themeConfig;
19 
23  protected $eventDispatcher;
24 
29  public function __construct(
30  \Magento\Theme\Model\Config\Customization $themeConfig,
31  \Magento\Framework\Event\ManagerInterface $eventDispatcher
32  ) {
33  $this->themeConfig = $themeConfig;
34  $this->eventDispatcher = $eventDispatcher;
35  }
36 
43  public function execute(EventObserver $observer)
44  {
45  $theme = $observer->getEvent()->getData('theme');
46  if ($theme instanceof \Magento\Framework\View\Design\ThemeInterface) {
48  if ($this->themeConfig->isThemeAssignedToStore($theme)) {
49  $this->eventDispatcher->dispatch('assigned_theme_changed', ['theme' => $theme]);
50  }
51  }
52  }
53 }
$theme
__construct(\Magento\Theme\Model\Config\Customization $themeConfig, \Magento\Framework\Event\ManagerInterface $eventDispatcher)