Skip to content

Commit

Permalink
Security\DefaultType: fixed admin form
Browse files Browse the repository at this point in the history
  • Loading branch information
pepakriz committed Oct 25, 2014
1 parent f412ccb commit cb3ab40
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/Security/DefaultType/AdminFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down
2 changes: 1 addition & 1 deletion src/Security/DefaultType/AdminFormService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
26 changes: 12 additions & 14 deletions src/Security/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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.
*
Expand Down

0 comments on commit cb3ab40

Please sign in to comment.