Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DelegateCreate.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
10 use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
15 
19 class DelegateCreate extends Action implements HttpGetActionInterface
20 {
24  private $delegateService;
25 
29  private $session;
30 
36  public function __construct(
37  Context $context,
38  OrderCustomerDelegateInterface $customerDelegation,
39  Session $session
40  ) {
41  parent::__construct($context);
42  $this->delegateService = $customerDelegation;
43  $this->session = $session;
44  }
45 
49  public function execute()
50  {
52  $orderId = $this->session->getLastOrderId();
53  if (!$orderId) {
54  return $this->resultRedirectFactory->create()->setPath('/');
55  }
56 
57  return $this->delegateService->delegateNew((int)$orderId);
58  }
59 }
__construct(Context $context, OrderCustomerDelegateInterface $customerDelegation, Session $session)