PredispatchAdminActionControllerObserver.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * Mageplaza
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Mageplaza.com license that is
  8. * available through the world-wide-web at this URL:
  9. * https://www.mageplaza.com/LICENSE.txt
  10. *
  11. * DISCLAIMER
  12. *
  13. * Do not edit or add to this file if you wish to upgrade this extension to newer
  14. * version in the future.
  15. *
  16. * @category Mageplaza
  17. * @package Mageplaza_Core
  18. * @copyright Copyright (c) 2016-2018 Mageplaza (http://www.mageplaza.com/)
  19. * @license https://www.mageplaza.com/LICENSE.txt
  20. */
  21. namespace Mageplaza\Core\Observer;
  22. use Magento\Framework\Event\ObserverInterface;
  23. /**
  24. * Class PredispatchAdminActionControllerObserver
  25. * @package Mageplaza\Core\Observer
  26. */
  27. class PredispatchAdminActionControllerObserver implements ObserverInterface
  28. {
  29. /**
  30. * @type \Mageplaza\Core\Model\FeedFactory
  31. */
  32. protected $_feedFactory;
  33. /**
  34. * @type \Magento\Backend\Model\Auth\Session
  35. */
  36. protected $_backendAuthSession;
  37. /**
  38. * @param \Mageplaza\Core\Model\FeedFactory $feedFactory
  39. * @param \Magento\Backend\Model\Auth\Session $backendAuthSession
  40. */
  41. public function __construct(
  42. \Mageplaza\Core\Model\FeedFactory $feedFactory,
  43. \Magento\Backend\Model\Auth\Session $backendAuthSession
  44. )
  45. {
  46. $this->_feedFactory = $feedFactory;
  47. $this->_backendAuthSession = $backendAuthSession;
  48. }
  49. /**
  50. * @param \Magento\Framework\Event\Observer $observer
  51. */
  52. public function execute(\Magento\Framework\Event\Observer $observer)
  53. {
  54. if ($this->_backendAuthSession->isLoggedIn()) {
  55. /* @var $feedModel \Mageplaza\Core\Model\Feed */
  56. $feedModel = $this->_feedFactory->create();
  57. $feedModel->checkUpdate();
  58. }
  59. }
  60. }