PredispathAdminActionControllerObserver.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved.
  4. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
  5. *
  6. * Glory to Ukraine! Glory to the heroes!
  7. */
  8. namespace Magefan\Blog\Observer;
  9. use Magento\Framework\Event\ObserverInterface;
  10. /**
  11. * Blog observer
  12. */
  13. class PredispathAdminActionControllerObserver implements ObserverInterface
  14. {
  15. /**
  16. * @var \Magefan\Blog\Model\AdminNotificationFeedFactory
  17. */
  18. protected $_feedFactory;
  19. /**
  20. * @var \Magento\Backend\Model\Auth\Session
  21. */
  22. protected $_backendAuthSession;
  23. /**
  24. * @param \Magefan\Blog\Model\AdminNotificationFeedFactory $feedFactory
  25. * @param \Magento\Backend\Model\Auth\Session $backendAuthSession
  26. */
  27. public function __construct(
  28. \Magefan\Blog\Model\AdminNotificationFeedFactory $feedFactory,
  29. \Magento\Backend\Model\Auth\Session $backendAuthSession
  30. ) {
  31. $this->_feedFactory = $feedFactory;
  32. $this->_backendAuthSession = $backendAuthSession;
  33. }
  34. /**
  35. * Predispath 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 \Magefan\Blog\Model\AdminNotificationFeed */
  46. $feedModel->checkUpdate();
  47. }
  48. }
  49. }