SourceItemsDeleteInterfacePlugin.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\InventoryLowQuantityNotification\Plugin\InventoryApi;
  8. use Magento\InventoryApi\Api\SourceItemsDeleteInterface;
  9. use Magento\InventoryLowQuantityNotificationApi\Api\DeleteSourceItemsConfigurationInterface;
  10. /**
  11. * This plugin keeps consistency between SourceItem and SourceItemConfiguration while deleting
  12. */
  13. class SourceItemsDeleteInterfacePlugin
  14. {
  15. /**
  16. * @var DeleteSourceItemsConfigurationInterface
  17. */
  18. private $deleteSourceItemsConfiguration;
  19. /**
  20. * SourceItemsDeleteInterfacePlugin constructor.
  21. * @param DeleteSourceItemsConfigurationInterface $deleteSourceItemsConfiguration
  22. * @SuppressWarnings(PHPMD.LongVariable)
  23. */
  24. public function __construct(
  25. DeleteSourceItemsConfigurationInterface $deleteSourceItemsConfiguration
  26. ) {
  27. $this->deleteSourceItemsConfiguration = $deleteSourceItemsConfiguration;
  28. }
  29. /**
  30. * Keep database consistency while a source item is removed
  31. *
  32. * @param SourceItemsDeleteInterface $subject
  33. * @param void $result
  34. * @param array $sourceItems
  35. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  36. */
  37. public function afterExecute(
  38. SourceItemsDeleteInterface $subject,
  39. $result,
  40. array $sourceItems
  41. ) {
  42. $this->deleteSourceItemsConfiguration->execute($sourceItems);
  43. }
  44. }