QuoteRepository.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License").
  6. * You may not use this file except in compliance with the License.
  7. * A copy of the License is located at
  8. *
  9. * http://aws.amazon.com/apache2.0
  10. *
  11. * or in the "license" file accompanying this file. This file is distributed
  12. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  13. * express or implied. See the License for the specific language governing
  14. * permissions and limitations under the License.
  15. */
  16. namespace Amazon\Payment\Plugin;
  17. use Amazon\Core\Helper\Data;
  18. use Amazon\Payment\Api\QuoteLinkManagementInterface;
  19. use Magento\Quote\Api\CartRepositoryInterface;
  20. use Magento\Quote\Api\Data\CartInterface;
  21. class QuoteRepository
  22. {
  23. /**
  24. * @var QuoteLinkManagementInterface
  25. */
  26. private $quoteLinkManagement;
  27. /**
  28. * @var Data
  29. */
  30. private $coreHelper;
  31. public function __construct(
  32. QuoteLinkManagementInterface $quoteLinkManagement,
  33. Data $coreHelper
  34. ) {
  35. $this->quoteLinkManagement = $quoteLinkManagement;
  36. $this->coreHelper = $coreHelper;
  37. }
  38. /**
  39. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  40. */
  41. public function afterGet(CartRepositoryInterface $cartRepository, CartInterface $cart)
  42. {
  43. if ($this->coreHelper->isPwaEnabled()) {
  44. $this->quoteLinkManagement->setAmazonOrderReferenceIdExtensionAttribute($cart);
  45. }
  46. return $cart;
  47. }
  48. /**
  49. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  50. */
  51. public function afterGetForCustomer(CartRepositoryInterface $cartRepository, CartInterface $cart)
  52. {
  53. if ($this->coreHelper->isPwaEnabled()) {
  54. $this->quoteLinkManagement->setAmazonOrderReferenceIdExtensionAttribute($cart);
  55. }
  56. return $cart;
  57. }
  58. /**
  59. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  60. */
  61. public function afterGetActive(CartRepositoryInterface $cartRepository, CartInterface $cart)
  62. {
  63. if ($this->coreHelper->isPwaEnabled()) {
  64. $this->quoteLinkManagement->setAmazonOrderReferenceIdExtensionAttribute($cart);
  65. }
  66. return $cart;
  67. }
  68. /**
  69. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  70. */
  71. public function afterGetActiveForCustomer(CartRepositoryInterface $cartRepository, CartInterface $cart)
  72. {
  73. if ($this->coreHelper->isPwaEnabled()) {
  74. $this->quoteLinkManagement->setAmazonOrderReferenceIdExtensionAttribute($cart);
  75. }
  76. return $cart;
  77. }
  78. }