CheckConfig.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\NewRelicReporting\Model\Observer;
  7. use Magento\Framework\Event\Observer;
  8. use Magento\Framework\Event\ObserverInterface;
  9. use Magento\NewRelicReporting\Model\Config;
  10. use Magento\Framework\Message\ManagerInterface;
  11. use Magento\NewRelicReporting\Model\NewRelicWrapper;
  12. /**
  13. * Class CheckConfig
  14. */
  15. class CheckConfig implements ObserverInterface
  16. {
  17. /**
  18. * @var Config
  19. */
  20. protected $config;
  21. /**
  22. * @var NewRelicWrapper
  23. */
  24. protected $newRelicWrapper;
  25. /**
  26. * @var ManagerInterface
  27. */
  28. protected $messageManager;
  29. /**
  30. * @param Config $config
  31. * @param NewRelicWrapper $newRelicWrapper
  32. * @param ManagerInterface $messageManager
  33. */
  34. public function __construct(
  35. Config $config,
  36. NewRelicWrapper $newRelicWrapper,
  37. ManagerInterface $messageManager
  38. ) {
  39. $this->config = $config;
  40. $this->newRelicWrapper = $newRelicWrapper;
  41. $this->messageManager = $messageManager;
  42. }
  43. /**
  44. * Update items stock status and low stock date.
  45. *
  46. * @param Observer $observer
  47. * @return void
  48. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  49. */
  50. public function execute(Observer $observer)
  51. {
  52. if ($this->config->isNewRelicEnabled()) {
  53. if (!$this->newRelicWrapper->isExtensionInstalled()) {
  54. $this->config->disableModule();
  55. $this->messageManager->addError(
  56. __(
  57. 'The New Relic integration requires the newrelic-php5 agent, which is not installed. More
  58. information on installing the agent is available <a target="_blank" href="%1">here</a>.',
  59. 'https://docs.newrelic.com/docs/agents/php-agent/installation/php-agent-installation-overview'
  60. ),
  61. $this->messageManager->getDefaultGroup()
  62. );
  63. }
  64. }
  65. }
  66. }