GridAsyncInsertObserver.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Observer;
  7. use Magento\Framework\Event\ObserverInterface;
  8. /**
  9. * Sales entity grids indexing observer.
  10. *
  11. * Performs handling of events related to indexing
  12. * of Order, Invoice, Shipment and Creditmemo grids.
  13. */
  14. class GridAsyncInsertObserver implements ObserverInterface
  15. {
  16. /**
  17. * @var \Magento\Sales\Model\GridAsyncInsert
  18. */
  19. protected $asyncInsert;
  20. /**
  21. * @param \Magento\Sales\Model\GridAsyncInsert $asyncInsert
  22. */
  23. public function __construct(
  24. \Magento\Sales\Model\GridAsyncInsert $asyncInsert
  25. ) {
  26. $this->asyncInsert = $asyncInsert;
  27. }
  28. /**
  29. * Handles asynchronous insertion of the new entity into
  30. * corresponding grid during cron job.
  31. *
  32. * Also method is used in the next events:
  33. *
  34. * - config_data_dev_grid_async_indexing_disabled
  35. *
  36. * Works only if asynchronous grid indexing is enabled
  37. * in global settings.
  38. *
  39. * @param \Magento\Framework\Event\Observer $observer
  40. * @return void
  41. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  42. */
  43. public function execute(\Magento\Framework\Event\Observer $observer)
  44. {
  45. $this->asyncInsert->asyncInsert();
  46. }
  47. }