CatalogCheckIsUsingStaticUrlsAllowedObserver.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Catalog\Observer;
  7. use Magento\Framework\Event\ObserverInterface;
  8. class CatalogCheckIsUsingStaticUrlsAllowedObserver implements ObserverInterface
  9. {
  10. /**
  11. * Catalog data
  12. *
  13. * @var \Magento\Catalog\Helper\Data
  14. */
  15. protected $catalogData;
  16. /**
  17. * @param \Magento\Catalog\Helper\Data $catalogData
  18. */
  19. public function __construct(\Magento\Catalog\Helper\Data $catalogData)
  20. {
  21. $this->catalogData = $catalogData;
  22. }
  23. /**
  24. * Checking whether the using static urls in WYSIWYG allowed event
  25. *
  26. * @param \Magento\Framework\Event\Observer $observer
  27. * @return void
  28. */
  29. public function execute(\Magento\Framework\Event\Observer $observer)
  30. {
  31. $storeId = $observer->getEvent()->getData('store_id');
  32. $result = $observer->getEvent()->getData('result');
  33. $result->isAllowed = $this->catalogData->setStoreId($storeId)->isUsingStaticUrlsAllowed();
  34. }
  35. }