Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ChangeQuoteControl.php
Go to the documentation of this file.
1 <?php
7 declare(strict_types=1);
8 
9 namespace Magento\Quote\Model;
10 
14 
19 {
23  private $userContext;
24 
28  public function __construct(UserContextInterface $userContext)
29  {
30  $this->userContext = $userContext;
31  }
32 
36  public function isAllowed(CartInterface $quote): bool
37  {
38  switch ($this->userContext->getUserType()) {
40  $isAllowed = ($quote->getCustomerId() == $this->userContext->getUserId());
41  break;
43  $isAllowed = ($quote->getCustomerId() === null);
44  break;
47  $isAllowed = true;
48  break;
49  default:
50  $isAllowed = false;
51  }
52 
53  return $isAllowed;
54  }
55 }
$quote
$isAllowed
Definition: get.php:20
__construct(UserContextInterface $userContext)