diff --git a/src/Security/DefaultType/AdminFormFactory.php b/src/Security/DefaultType/AdminFormFactory.php index f4919cc1..98097a1c 100755 --- a/src/Security/DefaultType/AdminFormFactory.php +++ b/src/Security/DefaultType/AdminFormFactory.php @@ -45,7 +45,7 @@ public function create() $user->addText('name', 'Name'); $user->addTextArea('notation', 'Notation', 40, 4) ->getControlPrototype()->attrs['class'] = 'input-block-level'; - $user->addMultiSelect('entityRoles', 'Roles') + $user->addMultiSelect('roleEntities', 'Roles') ->setOption(IComponentMapper::ITEMS_TITLE, 'name'); $user->addText('key', 'Lock key') ->setOption('description', 'If is set user cannot log in.'); diff --git a/src/Security/DefaultType/AdminFormService.php b/src/Security/DefaultType/AdminFormService.php index 9f43ee85..9a86745e 100644 --- a/src/Security/DefaultType/AdminFormService.php +++ b/src/Security/DefaultType/AdminFormService.php @@ -60,7 +60,7 @@ protected function save(Form $form, $entity) protected function error(Form $form, \Exception $e) { if ($e instanceof \Kdyby\Doctrine\DuplicateEntryException) { - $form['name']->addError($form->getTranslator()->translate('Name must be unique.')); + $form['user']['name']->addError($form->getTranslator()->translate('Name must be unique.')); return; } diff --git a/src/Security/User.php b/src/Security/User.php index dc42ad49..3c1a0477 100644 --- a/src/Security/User.php +++ b/src/Security/User.php @@ -289,17 +289,26 @@ public function __toString() /** * @return ArrayCollection|Role[] */ - public function getEntityRoles() + public function getRoleEntities() { return $this->roleEntities->toArray(); } - public function addEntityRole(Role $role) + public function addRoleEntity(Role $role) { $this->roleEntities[] = $role; } - public function removeRole(Role $role) + /** + * @param \Venne\Security\Role $role + * @return boolean + */ + public function hasRoleEntity(Role $role) + { + return $this->roleEntities->contains($role); + } + + public function removeRoleEntity(Role $role) { $this->roleEntities->removeElement($role); } @@ -338,17 +347,6 @@ public function getNotation() return $this->notation; } - /** - * @param \Venne\Security\Role $roleEntity - * @return $this - */ - public function addRoleEntity(Role $roleEntity) - { - $this->roleEntities->add($roleEntity); - - return $this; - } - /** * Returns a list of roles that the user is a member of. *