SavePortoLicense.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Copyright © 2015 Magento. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Smartwave\Porto\Observer;
  7. use Magento\Framework\Event\ObserverInterface;
  8. class SavePortoLicense implements ObserverInterface
  9. {
  10. protected $_messageManager;
  11. protected $_cssGenerator;
  12. private $_helper;
  13. /**
  14. * @param \Magento\Backend\Helper\Data $backendData
  15. * @param \Magento\Framework\Registry $coreRegistry
  16. * @param \Magento\Backend\Model\Auth\Session $authSession
  17. * @param \Magento\Framework\App\ResponseInterface $response
  18. */
  19. public function __construct(
  20. \Smartwave\Porto\Model\Cssconfig\Generator $cssenerator,
  21. \Magento\Framework\Message\ManagerInterface $messageManager,
  22. \Smartwave\Porto\Helper\Data $helper
  23. ) {
  24. $this->_cssGenerator = $cssenerator;
  25. $this->_messageManager = $messageManager;
  26. $this->_helper = $helper;
  27. }
  28. /**
  29. * Log out user and redirect to new admin custom url
  30. *
  31. * @param \Magento\Framework\Event\Observer $observer
  32. * @return void
  33. * @SuppressWarnings(PHPMD.ExitExpression)
  34. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  35. */
  36. public function execute(\Magento\Framework\Event\Observer $observer)
  37. {
  38. $check = $this->_helper->checkPurchaseCode(true);
  39. if($check && $check != "localhost") {
  40. $this->_messageManager->getMessages(true);
  41. $this->_messageManager->addSuccess( 'Smartwave Porto Theme was activated!' );
  42. }
  43. }
  44. }