Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
QuoteIdToMaskedQuoteId.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
8 namespace Magento\Quote\Model;
9 
11 
13 {
17  private $quoteIdMaskFactory;
18 
22  private $cartRepository;
23 
28  public function __construct(
29  QuoteIdMaskFactory $quoteIdMaskFactory,
30  CartRepositoryInterface $cartRepository
31  ) {
32  $this->quoteIdMaskFactory = $quoteIdMaskFactory;
33  $this->cartRepository = $cartRepository;
34  }
35 
39  public function execute(int $quoteId): string
40  {
41  /* Check the quote exists to avoid database constraint issues */
42  $this->cartRepository->get($quoteId);
43 
44  $quoteIdMask = $this->quoteIdMaskFactory->create();
45  $quoteIdMask->setQuoteId($quoteId)->save();
46 
47  return $quoteIdMask->getMaskedId();
48  }
49 }
$cartRepository
Definition: quote.php:18
__construct(QuoteIdMaskFactory $quoteIdMaskFactory, CartRepositoryInterface $cartRepository)