コード例 #1
0
ファイル: Mysql.php プロジェクト: vegas-cmf/acl
 /**
  * {@inheritdoc}
  * Example:
  * <code>$acl->addRole(new Phalcon\Acl\Role('administrator'), 'consultor');</code>
  * <code>$acl->addRole('administrator', 'consultor');</code>
  *
  * @param string $role
  * @param array $accessInherits
  * @return boolean
  */
 public function addRole($role, $accessInherits = null)
 {
     if (!$role instanceof Role) {
         $role = new Role($role, '');
     }
     try {
         $this->getRole($role->getName());
     } catch (RoleDoesNotExistException $e) {
         $roleModel = new AclRole();
         $roleModel->create(['name' => $role->getName(), 'description' => $role->getDescription(), 'removable' => (int) $role->isRemovable()]);
     }
     if ($accessInherits) {
         return $this->addInherit($role->getName(), $accessInherits);
     }
     return true;
 }