PredispatchAdminActionControllerObserver.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\AdminNotification\Observer;
  7. use Magento\Framework\Event\ObserverInterface;
  8. /**
  9. * AdminNotification observer
  10. *
  11. * @author Magento Core Team <core@magentocommerce.com>
  12. */
  13. class PredispatchAdminActionControllerObserver implements ObserverInterface
  14. {
  15. /**
  16. * @var \Magento\AdminNotification\Model\FeedFactory
  17. */
  18. protected $_feedFactory;
  19. /**
  20. * @var \Magento\Backend\Model\Auth\Session
  21. */
  22. protected $_backendAuthSession;
  23. /**
  24. * @param \Magento\AdminNotification\Model\FeedFactory $feedFactory
  25. * @param \Magento\Backend\Model\Auth\Session $backendAuthSession
  26. */
  27. public function __construct(
  28. \Magento\AdminNotification\Model\FeedFactory $feedFactory,
  29. \Magento\Backend\Model\Auth\Session $backendAuthSession
  30. ) {
  31. $this->_feedFactory = $feedFactory;
  32. $this->_backendAuthSession = $backendAuthSession;
  33. }
  34. /**
  35. * Predispatch admin action controller
  36. *
  37. * @param \Magento\Framework\Event\Observer $observer
  38. * @return void
  39. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  40. */
  41. public function execute(\Magento\Framework\Event\Observer $observer)
  42. {
  43. if ($this->_backendAuthSession->isLoggedIn()) {
  44. $feedModel = $this->_feedFactory->create();
  45. /* @var $feedModel \Magento\AdminNotification\Model\Feed */
  46. $feedModel->checkUpdate();
  47. }
  48. }
  49. }