抽象クラス Phalcon\Acl\Adapter\AbstractAdapter
GitHub上のソース
Namespace |
Phalcon\Acl\Adapter |
|
Uses |
Phalcon\Acl\Enum, Phalcon\Events\AbstractEventsAware, Phalcon\Events\EventsAwareInterface |
|
Extends |
AbstractEventsAware |
|
Implements |
AdapterInterface, EventsAwareInterface |
Phalcon\Acl 用アダプター
Properties
/**
* Access Granted
*
* @var bool
*/
protected accessGranted = false;
/**
* Active access which the list is checking if some role can access it
*
* @var string|null
*/
protected activeAccess;
/**
* Component which the list is checking if some role can access it
*
* @var string|null
*/
protected activeComponent;
/**
* Role which the list is checking if it's allowed to certain
* component/access
*
* @var string|null
*/
protected activeRole;
/**
* Default access
*
* @var int
*/
protected defaultAccess;
メソッド
public function getActiveAccess(): string | null;
Active access which the list is checking if some role can access it
public function getActiveComponent(): string | null;
Component which the list is checking if some role can access it
public function getActiveRole(): string | null;
Role which the list is checking if it’s allowed to certain component/access
public function getDefaultAction(): int;
デフォルトのACLアクセスレベルを返します
public function setDefaultAction( int $defaultAccess ): void;
Sets the default access level (Phalcon\Acl\Enum::ALLOW or Phalcon\Acl\Enum::DENY)
インターフェース Phalcon\Acl\Adapter\AdapterInterface
GitHub上のソース
Namespace |
Phalcon\Acl\Adapter |
|
Uses |
Phalcon\Acl\ComponentInterface, Phalcon\Acl\RoleInterface |
Phalcon\Acl adapters用のインターフェース
メソッド
public function addComponent( mixed $componentValue, mixed $accessList ): bool;
アクセス制御リストにコンポーネントを追加します。
Access names can be a particular action, by example search, update, delete, etc. or a list of them
public function addComponentAccess( string $componentName, mixed $accessList ): bool;
コンポーネントへのアクセスの追加
public function addInherit( string $roleName, mixed $roleToInherits ): bool;
既存のロールからロールを継承する。
public function addRole( mixed $role, mixed $accessInherits = null ): bool;
アクセス制御リストにロールを追加します。 第二引数は、その他の既存のロールからアクセスデータを継承します。
public function allow( string $roleName, string $componentName, mixed $access, mixed $func = null ): void;
コンポーネント上のロールへのアクセスを許可します。
public function deny( string $roleName, string $componentName, mixed $access, mixed $func = null ): void;
コンポーネント上のロールへのアクセスを拒否
public function dropComponentAccess( string $componentName, mixed $accessList ): void;
Removes access from a component
public function getActiveAccess(): null | string;
ロールによるアクセス権の使用可否をチェックし、アクセス権のリストを返します。
public function getActiveComponent(): null | string;
ロールによるコンポーネントのアクセス可否をチェックし、コンポーネントのリストを返します。
public function getActiveRole(): null | string;
ロールによる特定のコンポーネントまたはアクセス権に対する使用可否をチェックし、ロールのリストを返します。
public function getComponents(): ComponentInterface[];
リストに登録されている全コンポーネントの配列を返します。
public function getDefaultAction(): int;
デフォルトのACLアクセスレベルを返します
public function getInheritedRoles( string $roleName = string ): array;
Returns the inherited roles for a passed role name. If no role name has been specified it will return the whole array. If the role has not been found it returns an empty array
public function getNoArgumentsDefaultAction(): int;
isAllowedアクションに引数が指定されていなかった際のデフォルトのアクセスレベルを返します。ただしaccessKeyのfuncは存在しているものとします。
public function getRoles(): RoleInterface[];
リストに登録されている全ロールの配列を返します。
public function isAllowed( mixed $roleName, mixed $componentName, string $access, array $parameters = null ): bool;
コンポーネントへのアクションが、ロールに対して許可されているかどうかを確認します。
public function isComponent( string $componentName ): bool;
コンポーネントリストにコンポーネントが存在するかどうかをチェックします。
public function isRole( string $roleName ): bool;
ロールリストにロールが存在するかどうかをチェックします。
public function setDefaultAction( int $defaultAccess ): void;
デフォルトのアクセスレベル (Phalcon\Acl\Enum::ALLOW または Phalcon\Acl\Enum::DENY)をセットします。
public function setNoArgumentsDefaultAction( int $defaultAccess ): void;
isAllowedアクションに引数が指定されていなかった際のデフォルトのアクセスレベル(Phalcon\Acl\Enum::ALLOW または Phalcon\Acl\Enum::DENY)を設定します。ただしaccessKeyのfuncは存在しているものとします。
Phalcon\Acl\Adapter\Memoryクラス
GitHub上のソース
Namespace |
Phalcon\Acl\Adapter |
|
Uses |
Phalcon\Acl\Enum, Phalcon\Acl\Role, Phalcon\Acl\RoleInterface, Phalcon\Acl\Component, Phalcon\Acl\Exception, Phalcon\Acl\RoleAwareInterface, Phalcon\Acl\ComponentAwareInterface, Phalcon\Acl\ComponentInterface, ReflectionClass, ReflectionFunction |
|
Extends |
AbstractAdapter |
メモリ上のアクセス制御リストを管理します
$acl = new \Phalcon\Acl\Adapter\Memory();
$acl->setDefaultAction(
\Phalcon\Acl\Enum::DENY
);
// Register roles
$roles = [
"users" => new \Phalcon\Acl\Role("Users"),
"guests" => new \Phalcon\Acl\Role("Guests"),
];
foreach ($roles as $role) {
$acl->addRole($role);
}
// Private area components
$privateComponents = [
"companies" => ["index", "search", "new", "edit", "save", "create", "delete"],
"products" => ["index", "search", "new", "edit", "save", "create", "delete"],
"invoices" => ["index", "profile"],
];
foreach ($privateComponents as $componentName => $actions) {
$acl->addComponent(
new \Phalcon\Acl\Component($componentName),
$actions
);
}
// Public area components
$publicComponents = [
"index" => ["index"],
"about" => ["index"],
"session" => ["index", "register", "start", "end"],
"contact" => ["index", "send"],
];
foreach ($publicComponents as $componentName => $actions) {
$acl->addComponent(
new \Phalcon\Acl\Component($componentName),
$actions
);
}
// Grant access to public areas to both users and guests
foreach ($roles as $role) {
foreach ($publicComponents as $component => $actions) {
$acl->allow($role->getName(), $component, "*");
}
}
// Grant access to private area to role Users
foreach ($privateComponents as $component => $actions) {
foreach ($actions as $action) {
$acl->allow("Users", $component, $action);
}
}
Properties
/**
* Access
*
* @var mixed
*/
protected access;
/**
* Access List
*
* @var mixed
*/
protected accessList;
/**
* Returns the latest function used to acquire access
*
* @var mixed
*/
protected activeFunction;
/**
* Returns number of additional arguments(excluding role and resource) for active function
*
* @var int
*/
protected activeFunctionCustomArgumentsCount = 0;
/**
* Returns the latest key used to acquire access
*
* @var string|null
*/
protected activeKey;
/**
* Components
*
* @var mixed
*/
protected components;
/**
* Component Names
*
* @var mixed
*/
protected componentsNames;
/**
* Function List
*
* @var mixed
*/
protected func;
/**
* Default action for no arguments is `allow`
*
* @var mixed
*/
protected noArgumentsDefaultAction;
/**
* Roles
*
* @var mixed
*/
protected roles;
/**
* Role Inherits
*
* @var mixed
*/
protected roleInherits;
メソッド
public function __construct();
Phalcon\Acl\Adapter\Memory コンストラクタ
public function addComponent( mixed $componentValue, mixed $accessList ): bool;
アクセス制御リストにコンポーネントを追加します。
Access names can be a particular action, by example search, update, delete, etc. or a list of them
例:
// Add a component to the list allowing access to an action
$acl->addComponent(
new Phalcon\Acl\Component("customers"),
"search"
);
$acl->addComponent("customers", "search");
// Add a component with an access list
$acl->addComponent(
new Phalcon\Acl\Component("customers"),
[
"create",
"search",
]
);
$acl->addComponent(
"customers",
[
"create",
"search",
]
);
public function addComponentAccess( string $componentName, mixed $accessList ): bool;
コンポーネントへのアクセスの追加
public function addInherit( string $roleName, mixed $roleToInherits ): bool;
既存のロールからロールを継承する。
$acl->addRole("administrator", "consultant");
$acl->addRole("administrator", ["consultant", "consultant2"]);
public function addRole( mixed $role, mixed $accessInherits = null ): bool;
アクセス制御リストにロールを追加します。 第二引数は、既存の他のロールからアクセスデータを継承します。
$acl->addRole(
new Phalcon\Acl\Role("administrator"),
"consultant"
);
$acl->addRole("administrator", "consultant");
$acl->addRole("administrator", ["consultant", "consultant2"]);
public function allow( string $roleName, string $componentName, mixed $access, mixed $func = null ): void;
コンポーネント上のロールへのアクセスを許可します。 ワイルドカードとして*
を使用できます。
// Allow access to guests to search on customers
$acl->allow("guests", "customers", "search");
// Allow access to guests to search or create on customers
$acl->allow("guests", "customers", ["search", "create"]);
// Allow access to any role to browse on products
$acl->allow("*", "products", "browse");
// Allow access to any role to browse on any component
$acl->allow("*", "*", "browse");
```php
public function deny( string $roleName, string $componentName, mixed $access, mixed $func = null ): void;
コンポーネント上のロールへのアクセスを拒否. ワイルドカードとして*
を使用できます。
// Deny access to guests to search on customers
$acl->deny("guests", "customers", "search");
// Deny access to guests to search or create on customers
$acl->deny("guests", "customers", ["search", "create"]);
// Deny access to any role to browse on products
$acl->deny("*", "products", "browse");
// Deny access to any role to browse on any component
$acl->deny("*", "*", "browse");
public function dropComponentAccess( string $componentName, mixed $accessList ): void;
Removes access from a component
public function getActiveFunction(): mixed;
Returns the latest function used to acquire access
public function getActiveFunctionCustomArgumentsCount(): int;
Returns number of additional arguments(excluding role and resource) for active function
public function getActiveKey(): string | null;
Returns the latest key used to acquire access
public function getComponents(): ComponentInterface[];
リストに登録されている全コンポーネントの配列を返します。
public function getInheritedRoles( string $roleName = string ): array;
Returns the inherited roles for a passed role name. If no role name has been specified it will return the whole array. If the role has not been found it returns an empty array
public function getNoArgumentsDefaultAction(): int;
isAllowed
アクションに引数が指定されていなかった際のデフォルトのACLアクセスレベルを返します。ただし(呼び出し可能な)func
のaccessKey
は存在しているものとします。
public function getRoles(): RoleInterface[];
リストに登録されている全ロールの配列を返します。
public function isAllowed( mixed $roleName, mixed $componentName, string $access, array $parameters = null ): bool;
コンポーネントへのアクションが、ロールに対して許可されているかどうかを確認します。
// Does andres have access to the customers component to create?
$acl->isAllowed("andres", "Products", "create");
// Do guests have access to any component to edit?
$acl->isAllowed("guests", "*", "edit");
public function isComponent( string $componentName ): bool;
コンポーネントリストにコンポーネントが存在するかどうかをチェックします。
public function isRole( string $roleName ): bool;
ロールリストにロールが存在するかどうかをチェックします。
public function setNoArgumentsDefaultAction( int $defaultAccess ): void;
isAllowedアクションに引数が指定されていなかった際のデフォルトのアクセスレベル(Phalcon\Enum::ALLOW または Phalcon\Enum::DENY)を設定します。ただしaccessKeyのfuncは存在しているものとします。
Phalcon\Acl\Componentクラス
GitHub上のソース
Namespace |
Phalcon\Acl |
|
Implements |
ComponentInterface |
このクラスはコンポーネントエントリとその説明を定義します。
Properties
/**
* Component description
*
* @var string
*/
private description;
/**
* Component name
*
* @var string
*/
private name;
メソッド
public function __construct( string $name, string $description = null );
Phalcon\Acl\Component コンストラクタ
public function __toString(): string;
public function getDescription(): string;
public function getName(): string;
Interface Phalcon\Acl\ComponentAwareInterface
GitHub上のソース
Interface for classes which could be used in allow method as RESOURCE
メソッド
public function getComponentName(): string;
コンポーネント名を返します。
Phalcon\Acl\ComponentInterfaceインターフェース
GitHub上のソース
Phalcon\Acl\Componentインターフェース
メソッド
public function __toString(): string;
マジックメソッド __toString
public function getDescription(): string;
コンポーネントの説明を返します。
public function getName(): string;
コンポーネント名を返します。
Phalcon\Acl\Enumクラス
GitHub上のソース
Phalcon\Acl\Adapter アダプタの定数
定数
const ALLOW = 1;
const DENY = 0;
Phalcon\Acl\Exceptionクラス
GitHub上のソース
Namespace |
Phalcon\Acl |
|
Extends |
\Exception |
Phalcon\Aclがスローする例外のクラス
Phalcon\Acl\Role クラス
GitHub上のソース
Namespace |
Phalcon\Acl |
|
Implements |
RoleInterface |
このクラスはロールエントリとその説明を定義します。
Properties
/**
* Role description
*
* @var string
*/
private description;
/**
* Role name
*
* @var string
*/
private name;
メソッド
public function __construct( string $name, string $description = null );
Phalcon\Acl\Role コンストラクタ
public function __toString(): string;
public function getDescription(): string;
public function getName(): string;
Interface Phalcon\Acl\RoleAwareInterface
GitHub上のソース
Interface for classes which could be used in allow method as ROLE
メソッド
public function getRoleName(): string;
ロール名を返します。
Phalcon\Acl\RoleInterfaceインターフェース
GitHub上のソース
Phalcon\Acl\Roleのインターフェース
メソッド
public function __toString(): string;
マジックメソッド __toString
public function getDescription(): string;
ロールの説明を返します。
public function getName(): string;
ロール名を返します。