Cron.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\NewRelicReporting\Model;
  7. use Magento\NewRelicReporting\Model\Cron\ReportCounts;
  8. use Magento\NewRelicReporting\Model\Cron\ReportModulesInfo;
  9. use Magento\NewRelicReporting\Model\Cron\ReportNewRelicCron;
  10. class Cron
  11. {
  12. /**
  13. * @var Config
  14. */
  15. protected $config;
  16. /**
  17. * @var ReportModulesInfo
  18. */
  19. protected $reportModulesInfo;
  20. /**
  21. * @var ReportCounts
  22. */
  23. protected $reportCounts;
  24. /**
  25. * @var ReportNewRelicCron
  26. */
  27. protected $reportNewRelicCron;
  28. /**
  29. * Constructor
  30. *
  31. * @param Config $config
  32. * @param ReportModulesInfo $reportModulesInfo
  33. * @param ReportCounts $reportCounts
  34. * @param ReportNewRelicCron $reportNewRelicCron
  35. */
  36. public function __construct(
  37. Config $config,
  38. ReportModulesInfo $reportModulesInfo,
  39. ReportCounts $reportCounts,
  40. ReportNewRelicCron $reportNewRelicCron
  41. ) {
  42. $this->config = $config;
  43. $this->reportModulesInfo = $reportModulesInfo;
  44. $this->reportCounts = $reportCounts;
  45. $this->reportNewRelicCron = $reportNewRelicCron;
  46. }
  47. /**
  48. * The method run by the cron that fires all required events.
  49. *
  50. * @return \Magento\NewRelicReporting\Model\Cron
  51. */
  52. public function runCron()
  53. {
  54. if ($this->config->isCronEnabled()) {
  55. $this->reportNewRelicCron->report();
  56. $this->reportModulesInfo->report();
  57. $this->reportCounts->report();
  58. }
  59. return $this;
  60. }
  61. }