src/Component/AuthManager.php
public function addChildPermission(Role $role, Permission $permission)
    {
        $rolePermission = new RolePermission();

        $rolePermission->setPermission($permission);
        $rolePermission->setRole($role);

        try {
            $this->saveEntity($rolePermission);
        } catch (UniqueConstraintViolationException $e) {
            throw new NotUniqueException('Permission ' . $permission->getName() . ' is already assigned to role ' . $role->getName());
        }
    }
public function addChildPermission(Role $role, Permission $permission)
    {
        $rolePermission = new RolePermission();

        $rolePermission->setPermission($permission);
        $rolePermission->setRole($role);

        try {
            $this->saveEntity($rolePermission);
        } catch (UniqueConstraintViolationException $e) {
            throw new NotUniqueException('Permission ' . $permission->getName() . ' is already assigned to role ' . $role->getName());
        }
    }
public function addChildPermission ( Role $ role , Permission $ permission ) { $ rolePermission = new RolePermission ( ) ; $ rolePermission -> setPermission ( $ permission ) ; $ rolePermission -> setRole ( $ role ) ; try { $ this -> saveEntity ( $ rolePermission ) ; } catch ( UniqueConstraintViolationException $ e ) { throw new NotUniqueException ( 'Permission ' . $ permission -> getName ( ) . ' is already assigned to role ' . $ role -> getName ( ) ) ; } }
Add permission to role
@param Role $role
@param Permission $permission
@throws DatabaseException
@throws NotUniqueException
Add permission to role