Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
EditRole.php
Go to the documentation of this file.
1 <?php
8 
12 class EditRole extends \Magento\User\Controller\Adminhtml\User\Role
13 {
19  public function execute()
20  {
23 
24  $role = $this->_initRole();
25  $this->restoreFormDataFromSession($role);
26 
27  $this->_initAction();
28 
29  if ($role->getId()) {
30  $breadCrumb = __('Edit Role');
31  $breadCrumbTitle = __('Edit Role');
32  } else {
33  $breadCrumb = __('Add New Role');
34  $breadCrumbTitle = __('Add New Role');
35  }
36 
37  $this->_view->getPage()->getConfig()->getTitle()->prepend(__('Roles'));
38  $this->_view->getPage()->getConfig()->getTitle()->prepend(
39  $role->getId() ? $role->getRoleName() : __('New Role')
40  );
41 
42  $this->_addBreadcrumb($breadCrumb, $breadCrumbTitle);
43 
44  $this->_view->getLayout()->getBlock(
45  'adminhtml.user.role.buttons'
46  )->setRoleId(
47  $role->getId()
48  )->setRoleInfo(
49  $role
50  );
51 
52  $this->_view->renderLayout();
53  }
54 
60  protected function restoreUsersDataFromSession()
61  {
62  $this->_coreRegistry->register(
64  $this->_session->getData(SaveRole::IN_ROLE_USER_FORM_DATA_SESSION_KEY, true)
65  );
66  $this->_coreRegistry->register(
68  $this->_session->getData(SaveRole::IN_ROLE_OLD_USER_FORM_DATA_SESSION_KEY, true)
69  );
70  }
71 
77  protected function restoreResourcesDataFromSession()
78  {
79  $this->_coreRegistry->register(
81  $this->_session->getData(SaveRole::RESOURCE_ALL_FORM_DATA_SESSION_KEY, true)
82  );
83  $this->_coreRegistry->register(
85  $this->_session->getData(SaveRole::RESOURCE_FORM_DATA_SESSION_KEY, true)
86  );
87  }
88 
95  protected function restoreFormDataFromSession(\Magento\Authorization\Model\Role $role)
96  {
98  if (!empty($data['rolename'])) {
99  $role->setRoleName($data['rolename']);
100  }
101 
102  return $this;
103  }
104 }
__()
Definition: __.php:13
_initRole($requestVariable='rid')
Definition: Role.php:107
_addBreadcrumb($label, $title, $link=null)
restoreFormDataFromSession(\Magento\Authorization\Model\Role $role)
Definition: EditRole.php:95