CartItemProcessorsPool.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Quote\Model\Quote\Item;
  7. use Magento\Framework\App\ObjectManager;
  8. use Magento\Framework\ObjectManager\ConfigInterface;
  9. /**
  10. * @deprecated 100.1.0
  11. */
  12. class CartItemProcessorsPool
  13. {
  14. /**
  15. * @var CartItemProcessorInterface[]
  16. */
  17. private $cartItemProcessors = [];
  18. /**
  19. * @var ConfigInterface
  20. */
  21. private $objectManagerConfig;
  22. /**
  23. * @param ConfigInterface $objectManagerConfig
  24. * @deprecated 100.1.0
  25. */
  26. public function __construct(ConfigInterface $objectManagerConfig)
  27. {
  28. $this->objectManagerConfig = $objectManagerConfig;
  29. }
  30. /**
  31. * @return CartItemProcessorInterface[]
  32. * @deprecated 100.1.0
  33. */
  34. public function getCartItemProcessors()
  35. {
  36. if (!empty($this->cartItemProcessors)) {
  37. return $this->cartItemProcessors;
  38. }
  39. $typePreference = $this->objectManagerConfig->getPreference(Repository::class);
  40. $arguments = $this->objectManagerConfig->getArguments($typePreference);
  41. if (isset($arguments['cartItemProcessors'])) {
  42. // Workaround for compiled mode.
  43. $processors = isset($arguments['cartItemProcessors']['_vac_'])
  44. ? $arguments['cartItemProcessors']['_vac_']
  45. : $arguments['cartItemProcessors'];
  46. foreach ($processors as $name => $processor) {
  47. $className = isset($processor['instance']) ? $processor['instance'] : $processor['_i_'];
  48. $this->cartItemProcessors[$name] = ObjectManager::getInstance()->get($className);
  49. }
  50. }
  51. return $this->cartItemProcessors;
  52. }
  53. }