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 
10 
12 {
16  public function execute()
17  {
18  $userId = $this->getRequest()->getParam('user_id');
20  $model = $this->_userFactory->create();
21 
22  if ($userId) {
23  $model->load($userId);
24  if (!$model->getId()) {
25  $this->messageManager->addError(__('This user no longer exists.'));
26  $this->_redirect('adminhtml/*/');
27  return;
28  }
29  } else {
30  $model->setInterfaceLocale(Resolver::DEFAULT_LOCALE);
31  }
32 
33  // Restore previously entered form data from session
34  $data = $this->_session->getUserData(true);
35  if (!empty($data)) {
36  $model->setData($data);
37  }
38 
39  $this->_coreRegistry->register('permissions_user', $model);
40 
41  if (isset($userId)) {
42  $breadcrumb = __('Edit User');
43  } else {
44  $breadcrumb = __('New User');
45  }
46  $this->_initAction()->_addBreadcrumb($breadcrumb, $breadcrumb);
47  $this->_view->getPage()->getConfig()->getTitle()->prepend(__('Users'));
48  $this->_view->getPage()->getConfig()->getTitle()->prepend($model->getId() ? $model->getName() : __('New User'));
49  $this->_view->renderLayout();
50  }
51 }
__()
Definition: __.php:13