123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Quote\Model\GuestCart;
- use Magento\Quote\Api\GuestCartRepositoryInterface;
- use Magento\Quote\Model\QuoteIdMask;
- use Magento\Quote\Api\CartRepositoryInterface;
- use Magento\Quote\Model\QuoteIdMaskFactory;
- /**
- * Cart Repository class for guest carts.
- */
- class GuestCartRepository implements GuestCartRepositoryInterface
- {
- /**
- * @var QuoteIdMaskFactory
- */
- protected $quoteIdMaskFactory;
- /**
- * @var CartRepositoryInterface
- */
- protected $quoteRepository;
- /**
- * Initialize dependencies.
- *
- * @param CartRepositoryInterface $quoteRepository
- * @param QuoteIdMaskFactory $quoteIdMaskFactory
- */
- public function __construct(
- CartRepositoryInterface $quoteRepository,
- QuoteIdMaskFactory $quoteIdMaskFactory
- ) {
- $this->quoteIdMaskFactory = $quoteIdMaskFactory;
- $this->quoteRepository = $quoteRepository;
- }
- /**
- * {@inheritdoc}
- */
- public function get($cartId)
- {
- /** @var $quoteIdMask QuoteIdMask */
- $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id');
- return $this->quoteRepository->get($quoteIdMask->getQuoteId());
- }
- }
|