CollectData.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Analytics\Cron;
  7. use Magento\Analytics\Model\ExportDataHandlerInterface;
  8. use Magento\Analytics\Model\SubscriptionStatusProvider;
  9. /**
  10. * Cron for data collection by a schedule for MBI.
  11. */
  12. class CollectData
  13. {
  14. /**
  15. * Resource for the handling of a new data collection.
  16. *
  17. * @var ExportDataHandlerInterface
  18. */
  19. private $exportDataHandler;
  20. /**
  21. * Resource which provides a status of subscription.
  22. *
  23. * @var SubscriptionStatusProvider
  24. */
  25. private $subscriptionStatus;
  26. /**
  27. * @param ExportDataHandlerInterface $exportDataHandler
  28. * @param SubscriptionStatusProvider $subscriptionStatus
  29. */
  30. public function __construct(
  31. ExportDataHandlerInterface $exportDataHandler,
  32. SubscriptionStatusProvider $subscriptionStatus
  33. ) {
  34. $this->exportDataHandler = $exportDataHandler;
  35. $this->subscriptionStatus = $subscriptionStatus;
  36. }
  37. /**
  38. * @return bool
  39. */
  40. public function execute()
  41. {
  42. if ($this->subscriptionStatus->getStatus() === SubscriptionStatusProvider::ENABLED) {
  43. $this->exportDataHandler->prepareExportData();
  44. }
  45. return true;
  46. }
  47. }