Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Edit.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
15 
17 {
22 
26  protected $dataObjectHelper;
27 
31  protected $session;
32 
36  protected $resultPageFactory;
37 
45  public function __construct(
46  Context $context,
47  Session $customerSession,
51  ) {
52  $this->session = $customerSession;
53  $this->resultPageFactory = $resultPageFactory;
54  $this->customerRepository = $customerRepository;
55  $this->dataObjectHelper = $dataObjectHelper;
56  parent::__construct($context);
57  }
58 
64  public function execute()
65  {
67  $resultPage = $this->resultPageFactory->create();
68 
69  $block = $resultPage->getLayout()->getBlock('customer_edit');
70  if ($block) {
71  $block->setRefererUrl($this->_redirect->getRefererUrl());
72  }
73 
74  $data = $this->session->getCustomerFormData(true);
75  $customerId = $this->session->getCustomerId();
76  $customerDataObject = $this->customerRepository->getById($customerId);
77  if (!empty($data)) {
78  $this->dataObjectHelper->populateWithArray(
79  $customerDataObject,
80  $data,
81  \Magento\Customer\Api\Data\CustomerInterface::class
82  );
83  }
84  $this->session->setCustomerData($customerDataObject);
85  $this->session->setChangePassword($this->getRequest()->getParam('changepass') == 1);
86 
87  $resultPage->getConfig()->getTitle()->set(__('Account Information'));
88  return $resultPage;
89  }
90 }
_redirect($path, $arguments=[])
Definition: Action.php:167
__()
Definition: __.php:13
$block
Definition: block.php:8
__construct(Context $context, Session $customerSession, PageFactory $resultPageFactory, CustomerRepositoryInterface $customerRepository, DataObjectHelper $dataObjectHelper)
Definition: Edit.php:45