/** * {@inheritdoc} */ public function getId() { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getId'); if (!$pluginInfo) { return parent::getId(); } else { return $this->___callPlugins('getId', func_get_args(), $pluginInfo); } }
/** * @magentoDataFixture roleDataFixture */ public function testGetRole() { $this->_model->loadByUsername(\Magento\TestFramework\Bootstrap::ADMIN_NAME); $role = $this->_model->getRole(); $this->assertInstanceOf('Magento\\Authorization\\Model\\Role', $role); $this->assertEquals(1, $role->getId()); $this->_model->setRoleId(self::$_newRole->getId())->save(); $role = $this->_model->getRole(); $this->assertEquals(self::$_newRole->getId(), $role->getId()); }
/** * @param \Magento\Authorization\Model\Role $role * @param array $data * @param \Magento\Backend\Model\View\Result\Redirect $resultRedirect * @return \Magento\Backend\Model\View\Result\Redirect */ protected function saveDataToSessionAndRedirect($role, $data, $resultRedirect) { $this->_getSession()->setData(self::ROLE_EDIT_FORM_DATA_SESSION_KEY, ['rolename' => $data['rolename']]); $this->_getSession()->setData(self::IN_ROLE_USER_FORM_DATA_SESSION_KEY, $data['in_role_user']); $this->_getSession()->setData(self::IN_ROLE_OLD_USER_FORM_DATA_SESSION_KEY, $data['in_role_user_old']); if ($data['all']) { $this->_getSession()->setData(self::RESOURCE_ALL_FORM_DATA_SESSION_KEY, $data['all']); } else { $resource = isset($data['resource']) ? $data['resource'] : []; $this->_getSession()->setData(self::RESOURCE_FORM_DATA_SESSION_KEY, $resource); } $arguments = $role->getId() ? ['rid' => $role->getId()] : []; return $resultRedirect->setPath('*/*/editrole', $arguments); }
/** * Get role users * * @param \Magento\Authorization\Model\Role $role * @return array */ public function getRoleUsers(\Magento\Authorization\Model\Role $role) { $connection = $this->getConnection(); $binds = ['role_id' => $role->getId(), 'role_type' => RoleUser::ROLE_TYPE]; $select = $connection->select()->from($this->getMainTable(), ['user_id'])->where('parent_id = :role_id')->where('role_type = :role_type')->where('user_id > 0'); return $connection->fetchCol($select, $binds); }
/** * Associate resources with the specified role. All resources previously assigned to the role will be unassigned. * * @param \Magento\Authorization\Model\Role $role * @param string[] $resources * @return void * @throws \LogicException */ protected function _associateResourcesWithRole($role, $resources) { /** @var \Magento\Authorization\Model\Rules $rules */ $rules = $this->_rulesFactory->create(); $rules->setRoleId($role->getId())->setResources($resources)->saveRel(); }
/** * Get role users * * @param \Magento\Authorization\Model\Role $role * @return array */ public function getRoleUsers(\Magento\Authorization\Model\Role $role) { $read = $this->_getReadAdapter(); $binds = array('role_id' => $role->getId(), 'role_type' => RoleUser::ROLE_TYPE); $select = $read->select()->from($this->getMainTable(), array('user_id'))->where('parent_id = :role_id')->where('role_type = :role_type')->where('user_id > 0'); return $read->fetchCol($select, $binds); }