From 0e81125ca0b1af848aec9d105ed9c77dfcba4eaa Mon Sep 17 00:00:00 2001 From: laminas-bot Date: Thu, 21 Nov 2024 21:59:21 +0000 Subject: [PATCH] Automated deployment: Thu Nov 21 21:59:21 UTC 2024 3.7.0 --- examples/index.html | 23 ++++++----------------- index.html | 27 ++++++++------------------- intro/index.html | 23 ++++++----------------- methods/index.html | 23 ++++++----------------- migration/to-v3-0/index.html | 23 ++++++----------------- pages/404.html | 23 ++++++----------------- search/search_index.json | 2 +- sitemap.xml | 15 +++++---------- sitemap.xml.gz | Bin 259 -> 242 bytes 9 files changed, 44 insertions(+), 115 deletions(-) diff --git a/examples/index.html b/examples/index.html index e8248e7..710f27f 100644 --- a/examples/index.html +++ b/examples/index.html @@ -82,17 +82,6 @@ - -
-
- -
-
- API Tools
- Build RESTful APIs in Minutes -
-
-
@@ -233,7 +222,7 @@

Search - GitHub + GitHub

@@ -590,7 +579,7 @@
Laminas
  • Laminas Project The new foundation for the community-supported, open source continuation of Zend Framework
  • Laminas Components and MVC Components and MVC for enterprise applications
  • Mezzio PSR-15 middleware in minutes
  • -
  • Laminas API Tools Build RESTful APIs in minutes
  • +
  • Maintenance Overview Current maintenance status of Laminas & Mezzio packages
  • @@ -607,13 +596,13 @@
  • - +
  • - +
  • - +
  • @@ -639,7 +628,7 @@

    - © 2023 Laminas Project a Series of LF Projects, LLC. + © 2024 Laminas Project a Series of LF Projects, LLC.

    diff --git a/index.html b/index.html index c95013d..90d965d 100644 --- a/index.html +++ b/index.html @@ -82,17 +82,6 @@ - -
    -
    - -
    -
    - API Tools
    - Build RESTful APIs in Minutes -
    -
    -
    @@ -424,7 +413,7 @@
    Laminas
  • Laminas Project The new foundation for the community-supported, open source continuation of Zend Framework
  • Laminas Components and MVC Components and MVC for enterprise applications
  • Mezzio PSR-15 middleware in minutes
  • -
  • Laminas API Tools Build RESTful APIs in minutes
  • +
  • Maintenance Overview Current maintenance status of Laminas & Mezzio packages
  • @@ -441,13 +430,13 @@
  • - +
  • - +
  • - +
  • @@ -473,7 +462,7 @@

    - © 2023 Laminas Project a Series of LF Projects, LLC. + © 2024 Laminas Project a Series of LF Projects, LLC.

    @@ -520,6 +509,6 @@ diff --git a/intro/index.html b/intro/index.html index 8c84451..431c62f 100644 --- a/intro/index.html +++ b/intro/index.html @@ -82,17 +82,6 @@ - -
    -
    - -
    -
    - API Tools
    - Build RESTful APIs in Minutes -
    -
    -
    @@ -480,7 +469,7 @@
    Laminas
  • Laminas Project The new foundation for the community-supported, open source continuation of Zend Framework
  • Laminas Components and MVC Components and MVC for enterprise applications
  • Mezzio PSR-15 middleware in minutes
  • -
  • Laminas API Tools Build RESTful APIs in minutes
  • +
  • Maintenance Overview Current maintenance status of Laminas & Mezzio packages
  • @@ -497,13 +486,13 @@
  • - +
  • - +
  • - +
  • @@ -529,7 +518,7 @@

    - © 2023 Laminas Project a Series of LF Projects, LLC. + © 2024 Laminas Project a Series of LF Projects, LLC.

    diff --git a/methods/index.html b/methods/index.html index 764220d..ca0c6c4 100644 --- a/methods/index.html +++ b/methods/index.html @@ -82,17 +82,6 @@ - -
    -
    - -
    -
    - API Tools
    - Build RESTful APIs in Minutes -
    -
    -
    @@ -565,7 +554,7 @@
    Laminas
  • Laminas Project The new foundation for the community-supported, open source continuation of Zend Framework
  • Laminas Components and MVC Components and MVC for enterprise applications
  • Mezzio PSR-15 middleware in minutes
  • -
  • Laminas API Tools Build RESTful APIs in minutes
  • +
  • Maintenance Overview Current maintenance status of Laminas & Mezzio packages
  • @@ -582,13 +571,13 @@
  • - +
  • - +
  • - +
  • @@ -614,7 +603,7 @@

    - © 2023 Laminas Project a Series of LF Projects, LLC. + © 2024 Laminas Project a Series of LF Projects, LLC.

    diff --git a/migration/to-v3-0/index.html b/migration/to-v3-0/index.html index aeb4801..51f294f 100644 --- a/migration/to-v3-0/index.html +++ b/migration/to-v3-0/index.html @@ -82,17 +82,6 @@ - -
    -
    - -
    -
    - API Tools
    - Build RESTful APIs in Minutes -
    -
    -
    @@ -515,7 +504,7 @@
    Laminas
  • Laminas Project The new foundation for the community-supported, open source continuation of Zend Framework
  • Laminas Components and MVC Components and MVC for enterprise applications
  • Mezzio PSR-15 middleware in minutes
  • -
  • Laminas API Tools Build RESTful APIs in minutes
  • +
  • Maintenance Overview Current maintenance status of Laminas & Mezzio packages
  • @@ -532,13 +521,13 @@
  • - +
  • - +
  • - +
  • @@ -564,7 +553,7 @@

    - © 2023 Laminas Project a Series of LF Projects, LLC. + © 2024 Laminas Project a Series of LF Projects, LLC.

    diff --git a/pages/404.html b/pages/404.html index ce373ac..e611cf8 100644 --- a/pages/404.html +++ b/pages/404.html @@ -82,17 +82,6 @@ - -
    -
    - -
    -
    - API Tools
    - Build RESTful APIs in Minutes -
    -
    -
    @@ -377,7 +366,7 @@
    Laminas
  • Laminas Project The new foundation for the community-supported, open source continuation of Zend Framework
  • Laminas Components and MVC Components and MVC for enterprise applications
  • Mezzio PSR-15 middleware in minutes
  • -
  • Laminas API Tools Build RESTful APIs in minutes
  • +
  • Maintenance Overview Current maintenance status of Laminas & Mezzio packages
  • @@ -394,13 +383,13 @@
  • - +
  • - +
  • - +
  • @@ -426,7 +415,7 @@

    - © 2023 Laminas Project a Series of LF Projects, LLC. + © 2024 Laminas Project a Series of LF Projects, LLC.

    diff --git a/search/search_index.json b/search/search_index.json index 3baa6a4..b8559b2 100644 --- a/search/search_index.json +++ b/search/search_index.json @@ -1 +1 @@ -{"config":{"indexing":"full","lang":["en"],"min_search_length":3,"prebuild_index":false,"separator":"[\\s\\-]+"},"docs":[{"location":"","text":"../../README.md","title":"Home"},{"location":"examples/","text":"Examples The following is a list of common use-case examples for laminas-permission-rbac. Roles Extending and adding roles via instantiation: use Laminas\\Permissions\\Rbac\\Rbac; use Laminas\\Permissions\\Rbac\\Role; class MyRole extends Role { // .. implementation } // Creating roles manually $foo = new MyRole('foo'); $rbac = new Rbac(); $rbac->addRole($foo); var_dump($rbac->hasRole('foo')); // true Adding roles directly to RBAC with the default Laminas\\Permission\\Rbac\\Role : use Laminas\\Permissions\\Rbac\\Rbac; $rbac = new Rbac(); $rbac->addRole('foo'); var_dump($rbac->hasRole('foo')); // true Handling roles with children: use Laminas\\Permissions\\Rbac\\Rbac; use Laminas\\Permissions\\Rbac\\Role; $rbac = new Rbac(); $rbac->setCreateMissingRoles(true); $foo = new Role('foo'); $bar = new Role('bar'); // 1 - Add a role with child role directly with instantiated classes. $foo->addChild($bar); $rbac->addRole($foo); // 2 - Same as one, only via rbac container. $rbac->addRole('boo', 'baz'); // baz is a parent of boo $rbac->addRole('baz', ['out', 'of', 'roles']); // create several parents of baz Permissions use Laminas\\Permissions\\Rbac\\Rbac; use Laminas\\Permissions\\Rbac\\Role; $rbac = new Rbac(); $foo = new Role('foo'); $foo->addPermission('bar'); var_dump($foo->hasPermission('bar')); // true $rbac->addRole($foo); $rbac->isGranted('foo', 'bar'); // true $rbac->isGranted('foo', 'baz'); // false $rbac->getRole('foo')->addPermission('baz'); $rbac->isGranted('foo', 'baz'); // true Dynamic Assertions Checking permission using isGranted() with a class implementing Laminas\\Permissions\\Rbac\\AssertionInterface : use App\\Model\\Article; use Laminas\\Permissions\\Rbac\\AssertionInterface; use Laminas\\Permissions\\Rbac\\Rbac; use Laminas\\Permissions\\Rbac\\RoleInterface; class AssertUserRoleMatches implements AssertionInterface { protected $userId; protected $article; public function __construct(string $userId) { $this->userId = $userId; } public function setArticle(Article $article) { $this->article = $article; } public function assert(Rbac $rbac, RoleInterface $role = null, string $permission = null) : bool { if (! $this->article) { return false; } return ($this->userId === $this->article->getUserId()); } } // User is assigned the foo role with id 5 // News article belongs to userId 5 // Jazz article belongs to userId 6 $rbac = new Rbac(); $user = $mySessionObject->getUser(); $news = $articleService->getArticle(5); $jazz = $articleService->getArticle(6); $rbac->addRole($user->getRole()); $rbac->getRole($user->getRole())->addPermission('edit.article'); $assertion = new AssertUserRoleMatches($user->getId()); $assertion->setArticle($news); // true always - bad! if ($rbac->isGranted($user->getRole(), 'edit.article')) { // hacks another user's article } // true for user id 5, because he belongs to write group and user id matches if ($rbac->isGranted($user->getRole(), 'edit.article', $assertion)) { // edits his own article } $assertion->setArticle($jazz); // false for user id 5 if ($rbac->isGranted($user->getRole(), 'edit.article', $assertion)) { // can not edit another user's article } Performing the same as above with a closure: // assume same variables from previous example $assertion = function ($rbac) use ($user, $news) { return $user->getId() === $news->getUserId(); }; // true if ($rbac->isGranted($user->getRole(), 'edit.article', $assertion)) { // edits his own article }","title":"Examples"},{"location":"examples/#examples","text":"The following is a list of common use-case examples for laminas-permission-rbac.","title":"Examples"},{"location":"examples/#roles","text":"Extending and adding roles via instantiation: use Laminas\\Permissions\\Rbac\\Rbac; use Laminas\\Permissions\\Rbac\\Role; class MyRole extends Role { // .. implementation } // Creating roles manually $foo = new MyRole('foo'); $rbac = new Rbac(); $rbac->addRole($foo); var_dump($rbac->hasRole('foo')); // true Adding roles directly to RBAC with the default Laminas\\Permission\\Rbac\\Role : use Laminas\\Permissions\\Rbac\\Rbac; $rbac = new Rbac(); $rbac->addRole('foo'); var_dump($rbac->hasRole('foo')); // true Handling roles with children: use Laminas\\Permissions\\Rbac\\Rbac; use Laminas\\Permissions\\Rbac\\Role; $rbac = new Rbac(); $rbac->setCreateMissingRoles(true); $foo = new Role('foo'); $bar = new Role('bar'); // 1 - Add a role with child role directly with instantiated classes. $foo->addChild($bar); $rbac->addRole($foo); // 2 - Same as one, only via rbac container. $rbac->addRole('boo', 'baz'); // baz is a parent of boo $rbac->addRole('baz', ['out', 'of', 'roles']); // create several parents of baz","title":"Roles"},{"location":"examples/#permissions","text":"use Laminas\\Permissions\\Rbac\\Rbac; use Laminas\\Permissions\\Rbac\\Role; $rbac = new Rbac(); $foo = new Role('foo'); $foo->addPermission('bar'); var_dump($foo->hasPermission('bar')); // true $rbac->addRole($foo); $rbac->isGranted('foo', 'bar'); // true $rbac->isGranted('foo', 'baz'); // false $rbac->getRole('foo')->addPermission('baz'); $rbac->isGranted('foo', 'baz'); // true","title":"Permissions"},{"location":"examples/#dynamic-assertions","text":"Checking permission using isGranted() with a class implementing Laminas\\Permissions\\Rbac\\AssertionInterface : use App\\Model\\Article; use Laminas\\Permissions\\Rbac\\AssertionInterface; use Laminas\\Permissions\\Rbac\\Rbac; use Laminas\\Permissions\\Rbac\\RoleInterface; class AssertUserRoleMatches implements AssertionInterface { protected $userId; protected $article; public function __construct(string $userId) { $this->userId = $userId; } public function setArticle(Article $article) { $this->article = $article; } public function assert(Rbac $rbac, RoleInterface $role = null, string $permission = null) : bool { if (! $this->article) { return false; } return ($this->userId === $this->article->getUserId()); } } // User is assigned the foo role with id 5 // News article belongs to userId 5 // Jazz article belongs to userId 6 $rbac = new Rbac(); $user = $mySessionObject->getUser(); $news = $articleService->getArticle(5); $jazz = $articleService->getArticle(6); $rbac->addRole($user->getRole()); $rbac->getRole($user->getRole())->addPermission('edit.article'); $assertion = new AssertUserRoleMatches($user->getId()); $assertion->setArticle($news); // true always - bad! if ($rbac->isGranted($user->getRole(), 'edit.article')) { // hacks another user's article } // true for user id 5, because he belongs to write group and user id matches if ($rbac->isGranted($user->getRole(), 'edit.article', $assertion)) { // edits his own article } $assertion->setArticle($jazz); // false for user id 5 if ($rbac->isGranted($user->getRole(), 'edit.article', $assertion)) { // can not edit another user's article } Performing the same as above with a closure: // assume same variables from previous example $assertion = function ($rbac) use ($user, $news) { return $user->getId() === $news->getUserId(); }; // true if ($rbac->isGranted($user->getRole(), 'edit.article', $assertion)) { // edits his own article }","title":"Dynamic Assertions"},{"location":"intro/","text":"Introduction laminas-permissions-rbac provides a lightweight Role-Based Access Control (RBAC) implementation in PHP. RBAC differs from access control lists (ACL) by putting the emphasis on roles and their permissions rather than objects (resources). For the purposes of this documentation: an identity has one or more roles. a role requests access to a permission. a permission is given to a role. Thus, RBAC has the following model: many to many relationship between identities and roles . many to many relationship between roles and permissions . roles can have parent and child roles (hierarchy of roles). Roles To create a role, create a new class that implements Laminas\\Permission\\Rbac\\RoleInterface or use the default role class, Laminas\\Permission\\Rbac\\Role . You can instantiate a role and add it to the RBAC container or add a role directly using the RBAC container addRole() method. Permissions Each role can have zero or more permissions and can be set directly to the role or by first retrieving the role from the RBAC container. Any parent role will inherit the permissions of their children. Dynamic Assertions In certain situations simply checking a permission key for access may not be enough. For example, assume two users, Foo and Bar, both have article.edit permission. What's to stop Bar from editing Foo's articles? The answer is dynamic assertions which allow you to specify extra runtime credentials that must pass for access to be granted.","title":"Intro"},{"location":"intro/#introduction","text":"laminas-permissions-rbac provides a lightweight Role-Based Access Control (RBAC) implementation in PHP. RBAC differs from access control lists (ACL) by putting the emphasis on roles and their permissions rather than objects (resources). For the purposes of this documentation: an identity has one or more roles. a role requests access to a permission. a permission is given to a role. Thus, RBAC has the following model: many to many relationship between identities and roles . many to many relationship between roles and permissions . roles can have parent and child roles (hierarchy of roles).","title":"Introduction"},{"location":"intro/#roles","text":"To create a role, create a new class that implements Laminas\\Permission\\Rbac\\RoleInterface or use the default role class, Laminas\\Permission\\Rbac\\Role . You can instantiate a role and add it to the RBAC container or add a role directly using the RBAC container addRole() method.","title":"Roles"},{"location":"intro/#permissions","text":"Each role can have zero or more permissions and can be set directly to the role or by first retrieving the role from the RBAC container. Any parent role will inherit the permissions of their children.","title":"Permissions"},{"location":"intro/#dynamic-assertions","text":"In certain situations simply checking a permission key for access may not be enough. For example, assume two users, Foo and Bar, both have article.edit permission. What's to stop Bar from editing Foo's articles? The answer is dynamic assertions which allow you to specify extra runtime credentials that must pass for access to be granted.","title":"Dynamic Assertions"},{"location":"methods/","text":"Methods Laminas\\Permissions\\Rbac\\Role The Role provides the base functionality required by the RoleInterface . Method signature Description __construct(string $name) : void Create a new instance with the provided name. getName() : string Retrieve the name assigned to this role. addPermission(string $name) : void Add a permission for the current role. hasPermission(string $name) : bool Does the role have the given permission? getPermissions(bool $children = true) : array Retrieve all permissions, including child permissions if $children is true. addChild(RoleInterface $child) : Role Add a child role to the current instance. getChildren() : RoleInterface[] Get all child roles. addParent(RoleInterface $parent) : Role Add a parent role to the current instance. getParents() : RoleInterface[] Get all parent roles. Laminas\\Permissions\\Rbac\\AssertionInterface Custom assertions can be provided to Rbac::isGranted() (see below); such assertions are provided the Rbac instance on invocation, along with the role and permission being tested against. Method signature Description assert(Rbac $rbac, RoleInterface $role, string $permission) : bool Given an RBAC, a role, and a permission, determine if permission is granted. Laminas\\Permissions\\Rbac\\Rbac Rbac is the object with which you will interact within your application in order to query for permissions. Method signature Description addRole(string\\|RoleInterface $child, array\\|RoleInterface $parents = null) Add a role to the RBAC. If $parents is non-null, the $child is also added to any parents provided. getRole(string $role) : RoleInterface Get the role specified by name, raising an exception if not found. getRoles(): RoleInterface[] Retrieve all the roles. hasRole(string\\|RoleInterface $role) : bool Recursively queries the RBAC for the given role, returning true if found, false otherwise. getCreateMissingRoles() : bool Retrieve the flag that determines whether or not $parent roles are added automatically if not present when calling addRole() . setCreateMissingRoles(bool $flag) : void Set the flag that determines whether or not $parent roles are added automatically if not present when calling addRole() . isGranted(string\\|RoleInterface $role, string $permission, $assert = null) Determine if the role has the given permission. If $assert is provided and either an AssertInterface instance or callable, it will be queried before checking against the given role.","title":"Methods"},{"location":"methods/#methods","text":"","title":"Methods"},{"location":"methods/#laminaspermissionsrbacrole","text":"The Role provides the base functionality required by the RoleInterface . Method signature Description __construct(string $name) : void Create a new instance with the provided name. getName() : string Retrieve the name assigned to this role. addPermission(string $name) : void Add a permission for the current role. hasPermission(string $name) : bool Does the role have the given permission? getPermissions(bool $children = true) : array Retrieve all permissions, including child permissions if $children is true. addChild(RoleInterface $child) : Role Add a child role to the current instance. getChildren() : RoleInterface[] Get all child roles. addParent(RoleInterface $parent) : Role Add a parent role to the current instance. getParents() : RoleInterface[] Get all parent roles.","title":"Laminas\\Permissions\\Rbac\\Role"},{"location":"methods/#laminaspermissionsrbacassertioninterface","text":"Custom assertions can be provided to Rbac::isGranted() (see below); such assertions are provided the Rbac instance on invocation, along with the role and permission being tested against. Method signature Description assert(Rbac $rbac, RoleInterface $role, string $permission) : bool Given an RBAC, a role, and a permission, determine if permission is granted.","title":"Laminas\\Permissions\\Rbac\\AssertionInterface"},{"location":"methods/#laminaspermissionsrbacrbac","text":"Rbac is the object with which you will interact within your application in order to query for permissions. Method signature Description addRole(string\\|RoleInterface $child, array\\|RoleInterface $parents = null) Add a role to the RBAC. If $parents is non-null, the $child is also added to any parents provided. getRole(string $role) : RoleInterface Get the role specified by name, raising an exception if not found. getRoles(): RoleInterface[] Retrieve all the roles. hasRole(string\\|RoleInterface $role) : bool Recursively queries the RBAC for the given role, returning true if found, false otherwise. getCreateMissingRoles() : bool Retrieve the flag that determines whether or not $parent roles are added automatically if not present when calling addRole() . setCreateMissingRoles(bool $flag) : void Set the flag that determines whether or not $parent roles are added automatically if not present when calling addRole() . isGranted(string\\|RoleInterface $role, string $permission, $assert = null) Determine if the role has the given permission. If $assert is provided and either an AssertInterface instance or callable, it will be queried before checking against the given role.","title":"Laminas\\Permissions\\Rbac\\Rbac"},{"location":"migration/to-v3-0/","text":"Upgrading to 3.0 If you upgrade from version 2 releases, you will notice a few changes. This document details the changes Minimum supported PHP version Version 3 drops support for PHP versions prior to PHP 7.1. AssertionInterface The primary change is the Laminas\\Permissions\\Rbac\\AssertionInterface::assert() method definition. The new assert method has the following signature: namespace Laminas\\Permissions\\Rbac; public function assert( Rbac $rbac, RoleInterface $role, string $permission ) : bool The version 2 releases defined the method such that it only accepted a single parameter, Rbac $rbac . Version 3 adds the $role and $permission parameters. This simplifies implementation of dynamic assertions using the role and the permission information. For instance, imagine you want to disable a specific permission foo for an admin role; you can implement that as follows: public function assert(Rbac $rbac, RoleInterface $role, string $permission) : bool { return ! ($permission === 'foo' && $role->getName() === 'admin'); } If you were previously implementing AssertionInterface , you will need to update the assert() signature to match the changes in version 3. If you were creating assertions as PHP callables, you may continue to use the existing signature; however, you may also expand them to accept the new arguments should they assist you in creating more complex, dynamic assertions. RoleInterface Laminas\\Permissions\\Rbac\\RoleInterface also received a number of changes, including type hints and method name changes. Type hints With the update to PHP 7.1 , we also updated the RoleInterface to provide: scalar type hints where applicable ( addPermission() and hasPermission() ). add return type hints (including scalar type hints) to all methods. You will need to examine the RoleInterface definitions to determine what changes to make to your implementations. setParent becomes addParent In version 3, we renamed the method Role::setParent() to Role::addParent() . This naming is more consistent with other method names, such as Role::addChild() , and also makes clear that more than one parent may be provided to any given role. getParent becomes getParents In line with the previous change, getParent() was also renamed to getParents() , which returns an array of RoleInterface instances. Removed support for string arguments in Role::addChild Version 3 no longer allows adding a child using a string role name; you may only provide RoleInterface instances. Adds getChildren Since roles may have multiple children, the method getChildren() was added; it returns an array of RoleInterface instances.","title":"v2.X to v3.0"},{"location":"migration/to-v3-0/#upgrading-to-30","text":"If you upgrade from version 2 releases, you will notice a few changes. This document details the changes","title":"Upgrading to 3.0"},{"location":"migration/to-v3-0/#minimum-supported-php-version","text":"Version 3 drops support for PHP versions prior to PHP 7.1.","title":"Minimum supported PHP version"},{"location":"migration/to-v3-0/#assertioninterface","text":"The primary change is the Laminas\\Permissions\\Rbac\\AssertionInterface::assert() method definition. The new assert method has the following signature: namespace Laminas\\Permissions\\Rbac; public function assert( Rbac $rbac, RoleInterface $role, string $permission ) : bool The version 2 releases defined the method such that it only accepted a single parameter, Rbac $rbac . Version 3 adds the $role and $permission parameters. This simplifies implementation of dynamic assertions using the role and the permission information. For instance, imagine you want to disable a specific permission foo for an admin role; you can implement that as follows: public function assert(Rbac $rbac, RoleInterface $role, string $permission) : bool { return ! ($permission === 'foo' && $role->getName() === 'admin'); } If you were previously implementing AssertionInterface , you will need to update the assert() signature to match the changes in version 3. If you were creating assertions as PHP callables, you may continue to use the existing signature; however, you may also expand them to accept the new arguments should they assist you in creating more complex, dynamic assertions.","title":"AssertionInterface"},{"location":"migration/to-v3-0/#roleinterface","text":"Laminas\\Permissions\\Rbac\\RoleInterface also received a number of changes, including type hints and method name changes.","title":"RoleInterface"}]} \ No newline at end of file +{"config":{"indexing":"full","lang":["en"],"min_search_length":3,"prebuild_index":false,"separator":"[\\s\\-]+"},"docs":[{"location":"","text":"laminas-permissions-rbac πŸ‡·πŸ‡Ί Русским Π³Ρ€Π°ΠΆΠ΄Π°Π½Π°ΠΌ ΠœΡ‹, участники Laminas, Ρ€ΠΎΠ΄ΠΈΠ»ΠΈΡΡŒ ΠΈ ΠΆΠΈΠ²Π΅ΠΌ Π² Ρ€Π°Π·Π½Ρ‹Ρ… странах. Π£ ΠΌΠ½ΠΎΠ³ΠΈΡ… ΠΈΠ· нас Π΅ΡΡ‚ΡŒ Π΄Ρ€ΡƒΠ·ΡŒΡ, родствСнники ΠΈ ΠΊΠΎΠ»Π»Π΅Π³ΠΈ ΠΊΠ°ΠΊ Π² России, Ρ‚Π°ΠΊ ΠΈ Π² Π£ΠΊΡ€Π°ΠΈΠ½Π΅. НСкоторыС ΠΈΠ· нас Ρ€ΠΎΠ΄ΠΈΠ»ΠΈΡΡŒ Π² России. НСкоторыС ΠΈΠ· нас ΠΆΠΈΠ²ΡƒΡ‚ Π² России. Π£ Π½Π΅ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Ρ… Π±Π°Π±ΡƒΡˆΠΊΠΈ ΠΈ Π΄Π΅Π΄ΡƒΡˆΠΊΠΈ ΡΡ€Π°ΠΆΠ°Π»ΠΈΡΡŒ с Ρ„Π°ΡˆΠΈΡΡ‚Π°ΠΌΠΈ Π²ΠΎ Π’Ρ‚ΠΎΡ€ΠΎΠΉ ΠΌΠΈΡ€ΠΎΠ²ΠΎΠΉ Π²ΠΎΠΉΠ½Π΅. Π—Π΄Π΅ΡΡŒ Π½ΠΈΠΊΡ‚ΠΎ Π½Π΅ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΈΠ²Π°Π΅Ρ‚ Ρ„Π°ΡˆΠΈΠ·ΠΌ. Π£ ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΠΈΠ· нас Π΅ΡΡ‚ΡŒ украинская родствСнница, которая спаслась ΠΈΠ· Π΄ΠΎΠΌΠ° вмСстС с сыном. ПоСзд задСрТался ΠΈΠ·-Π·Π° Π±ΠΎΠΌΠ±Π΅ΠΆΠΊΠΈ Π½Π° Π΄ΠΎΡ€ΠΎΠ³Π΅ Π²ΠΏΠ΅Ρ€Π΅Π΄ΠΈ. Π£ нас Π΅ΡΡ‚ΡŒ Π΄Ρ€ΡƒΠ·ΡŒΡ, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ прячутся Π² Π±ΠΎΠΌΠ±ΠΎΡƒΠ±Π΅ΠΆΠΈΡ‰Π°Ρ…. ΠœΡ‹ с Ρ‚Ρ€Π΅Π²ΠΎΠ³ΠΎΠΉ ΠΆΠ΄Π΅ΠΌ вСсточки ΠΎΡ‚ Π½ΠΈΡ… послС Π²ΠΎΠ·Π΄ΡƒΡˆΠ½Ρ‹Ρ… Π½Π°Π»Π΅Ρ‚ΠΎΠ², ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ бСспорядочно наносят ΡƒΠ΄Π°Ρ€Ρ‹ ΠΈ ΠΏΠΎΠΏΠ°Π΄Π°ΡŽΡ‚ ΠΏΠΎ Π±ΠΎΠ»ΡŒΠ½ΠΈΡ†Π°ΠΌ, школам, дСтским садам ΠΈ Π΄ΠΎΠΌΠ°ΠΌ. ΠœΡ‹ Π½Π΅ Π±Π΅Ρ€Π΅ΠΌ это ΠΈΠ· ΠΊΠ°ΠΊΠΈΡ…-Π»ΠΈΠ±ΠΎ БМИ. ΠœΡ‹ наблюдаСм это Π½Π°ΠΏΡ€ΡΠΌΡƒΡŽ. Π’Ρ‹ довСряСтС Π½Π°ΠΌ достаточно, Ρ‡Ρ‚ΠΎΠ± ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ наши ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΡ‹, ΠΈ ΠΌΡ‹ просим вас Π΄ΠΎΠ²Π΅Ρ€ΠΈΡ‚ΡŒΡΡ Π½Π°ΠΌ вновь. ΠœΡ‹ нуТдаСмся Π² ΠΏΠΎΠΌΠΎΡ‰ΠΈ. Π’Ρ‹Ρ…ΠΎΠ΄ΠΈΡ‚Π΅ ΠΈ протСстуйтС ΠΏΡ€ΠΎΡ‚ΠΈΠ² этой бСсполСзной Π²ΠΎΠΉΠ½Ρ‹. ΠžΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚Π΅ ΠΊΡ€ΠΎΠ²ΠΎΠΏΡ€ΠΎΠ»ΠΈΡ‚ΠΈΠ΅. Π‘ΠΊΠ°ΠΆΠΈΡ‚Π΅ \"НСт Π²ΠΎΠΉΠ½Π΅!\" πŸ‡ΊπŸ‡Έ To Citizens of Russia We at Laminas come from all over the world. Many of us have friends, family and colleagues in both Russia and Ukraine. Some of us were born in Russia. Some of us currently live in Russia. Some have grandparents who fought Nazis in World War II. Nobody here supports fascism. One team member has a Ukrainian relative who fled her home with her son. The train was delayed due to bombing on the road ahead. We have friends who are hiding in bomb shelters. We anxiously follow up on them after the air raids, which indiscriminately fire at hospitals, schools, kindergartens and houses. We're not taking this from any media. These are our actual experiences. You trust us enough to use our software. We ask that you trust us to say the truth on this. We need your help. Go out and protest this unnecessary war. Stop the bloodshed. Say \"stop the war!\" Provides Role-Based Access Control (RBAC) permissions management. File issues at https://github.com/laminas/laminas-permissions-rbac/issues Documentation is at https://docs.laminas.dev/laminas-permissions-rbac/","title":"Home"},{"location":"#laminas-permissions-rbac","text":"","title":"laminas-permissions-rbac"},{"location":"#_1","text":"ΠœΡ‹, участники Laminas, Ρ€ΠΎΠ΄ΠΈΠ»ΠΈΡΡŒ ΠΈ ΠΆΠΈΠ²Π΅ΠΌ Π² Ρ€Π°Π·Π½Ρ‹Ρ… странах. Π£ ΠΌΠ½ΠΎΠ³ΠΈΡ… ΠΈΠ· нас Π΅ΡΡ‚ΡŒ Π΄Ρ€ΡƒΠ·ΡŒΡ, родствСнники ΠΈ ΠΊΠΎΠ»Π»Π΅Π³ΠΈ ΠΊΠ°ΠΊ Π² России, Ρ‚Π°ΠΊ ΠΈ Π² Π£ΠΊΡ€Π°ΠΈΠ½Π΅. НСкоторыС ΠΈΠ· нас Ρ€ΠΎΠ΄ΠΈΠ»ΠΈΡΡŒ Π² России. НСкоторыС ΠΈΠ· нас ΠΆΠΈΠ²ΡƒΡ‚ Π² России. Π£ Π½Π΅ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Ρ… Π±Π°Π±ΡƒΡˆΠΊΠΈ ΠΈ Π΄Π΅Π΄ΡƒΡˆΠΊΠΈ ΡΡ€Π°ΠΆΠ°Π»ΠΈΡΡŒ с Ρ„Π°ΡˆΠΈΡΡ‚Π°ΠΌΠΈ Π²ΠΎ Π’Ρ‚ΠΎΡ€ΠΎΠΉ ΠΌΠΈΡ€ΠΎΠ²ΠΎΠΉ Π²ΠΎΠΉΠ½Π΅. Π—Π΄Π΅ΡΡŒ Π½ΠΈΠΊΡ‚ΠΎ Π½Π΅ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΈΠ²Π°Π΅Ρ‚ Ρ„Π°ΡˆΠΈΠ·ΠΌ. Π£ ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΠΈΠ· нас Π΅ΡΡ‚ΡŒ украинская родствСнница, которая спаслась ΠΈΠ· Π΄ΠΎΠΌΠ° вмСстС с сыном. ПоСзд задСрТался ΠΈΠ·-Π·Π° Π±ΠΎΠΌΠ±Π΅ΠΆΠΊΠΈ Π½Π° Π΄ΠΎΡ€ΠΎΠ³Π΅ Π²ΠΏΠ΅Ρ€Π΅Π΄ΠΈ. Π£ нас Π΅ΡΡ‚ΡŒ Π΄Ρ€ΡƒΠ·ΡŒΡ, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ прячутся Π² Π±ΠΎΠΌΠ±ΠΎΡƒΠ±Π΅ΠΆΠΈΡ‰Π°Ρ…. ΠœΡ‹ с Ρ‚Ρ€Π΅Π²ΠΎΠ³ΠΎΠΉ ΠΆΠ΄Π΅ΠΌ вСсточки ΠΎΡ‚ Π½ΠΈΡ… послС Π²ΠΎΠ·Π΄ΡƒΡˆΠ½Ρ‹Ρ… Π½Π°Π»Π΅Ρ‚ΠΎΠ², ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ бСспорядочно наносят ΡƒΠ΄Π°Ρ€Ρ‹ ΠΈ ΠΏΠΎΠΏΠ°Π΄Π°ΡŽΡ‚ ΠΏΠΎ Π±ΠΎΠ»ΡŒΠ½ΠΈΡ†Π°ΠΌ, школам, дСтским садам ΠΈ Π΄ΠΎΠΌΠ°ΠΌ. ΠœΡ‹ Π½Π΅ Π±Π΅Ρ€Π΅ΠΌ это ΠΈΠ· ΠΊΠ°ΠΊΠΈΡ…-Π»ΠΈΠ±ΠΎ БМИ. ΠœΡ‹ наблюдаСм это Π½Π°ΠΏΡ€ΡΠΌΡƒΡŽ. Π’Ρ‹ довСряСтС Π½Π°ΠΌ достаточно, Ρ‡Ρ‚ΠΎΠ± ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ наши ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΡ‹, ΠΈ ΠΌΡ‹ просим вас Π΄ΠΎΠ²Π΅Ρ€ΠΈΡ‚ΡŒΡΡ Π½Π°ΠΌ вновь. ΠœΡ‹ нуТдаСмся Π² ΠΏΠΎΠΌΠΎΡ‰ΠΈ. Π’Ρ‹Ρ…ΠΎΠ΄ΠΈΡ‚Π΅ ΠΈ протСстуйтС ΠΏΡ€ΠΎΡ‚ΠΈΠ² этой бСсполСзной Π²ΠΎΠΉΠ½Ρ‹. ΠžΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚Π΅ ΠΊΡ€ΠΎΠ²ΠΎΠΏΡ€ΠΎΠ»ΠΈΡ‚ΠΈΠ΅. Π‘ΠΊΠ°ΠΆΠΈΡ‚Π΅ \"НСт Π²ΠΎΠΉΠ½Π΅!\"","title":"πŸ‡·πŸ‡Ί Русским Π³Ρ€Π°ΠΆΠ΄Π°Π½Π°ΠΌ"},{"location":"#to-citizens-of-russia","text":"We at Laminas come from all over the world. Many of us have friends, family and colleagues in both Russia and Ukraine. Some of us were born in Russia. Some of us currently live in Russia. Some have grandparents who fought Nazis in World War II. Nobody here supports fascism. One team member has a Ukrainian relative who fled her home with her son. The train was delayed due to bombing on the road ahead. We have friends who are hiding in bomb shelters. We anxiously follow up on them after the air raids, which indiscriminately fire at hospitals, schools, kindergartens and houses. We're not taking this from any media. These are our actual experiences. You trust us enough to use our software. We ask that you trust us to say the truth on this. We need your help. Go out and protest this unnecessary war. Stop the bloodshed. Say \"stop the war!\" Provides Role-Based Access Control (RBAC) permissions management. File issues at https://github.com/laminas/laminas-permissions-rbac/issues Documentation is at https://docs.laminas.dev/laminas-permissions-rbac/","title":"πŸ‡ΊπŸ‡Έ To Citizens of Russia"},{"location":"examples/","text":"Examples The following is a list of common use-case examples for laminas-permission-rbac. Roles Extending and adding roles via instantiation: use Laminas\\Permissions\\Rbac\\Rbac; use Laminas\\Permissions\\Rbac\\Role; class MyRole extends Role { // .. implementation } // Creating roles manually $foo = new MyRole('foo'); $rbac = new Rbac(); $rbac->addRole($foo); var_dump($rbac->hasRole('foo')); // true Adding roles directly to RBAC with the default Laminas\\Permission\\Rbac\\Role : use Laminas\\Permissions\\Rbac\\Rbac; $rbac = new Rbac(); $rbac->addRole('foo'); var_dump($rbac->hasRole('foo')); // true Handling roles with children: use Laminas\\Permissions\\Rbac\\Rbac; use Laminas\\Permissions\\Rbac\\Role; $rbac = new Rbac(); $rbac->setCreateMissingRoles(true); $foo = new Role('foo'); $bar = new Role('bar'); // 1 - Add a role with child role directly with instantiated classes. $foo->addChild($bar); $rbac->addRole($foo); // 2 - Same as one, only via rbac container. $rbac->addRole('boo', 'baz'); // baz is a parent of boo $rbac->addRole('baz', ['out', 'of', 'roles']); // create several parents of baz Permissions use Laminas\\Permissions\\Rbac\\Rbac; use Laminas\\Permissions\\Rbac\\Role; $rbac = new Rbac(); $foo = new Role('foo'); $foo->addPermission('bar'); var_dump($foo->hasPermission('bar')); // true $rbac->addRole($foo); $rbac->isGranted('foo', 'bar'); // true $rbac->isGranted('foo', 'baz'); // false $rbac->getRole('foo')->addPermission('baz'); $rbac->isGranted('foo', 'baz'); // true Dynamic Assertions Checking permission using isGranted() with a class implementing Laminas\\Permissions\\Rbac\\AssertionInterface : use App\\Model\\Article; use Laminas\\Permissions\\Rbac\\AssertionInterface; use Laminas\\Permissions\\Rbac\\Rbac; use Laminas\\Permissions\\Rbac\\RoleInterface; class AssertUserRoleMatches implements AssertionInterface { protected $userId; protected $article; public function __construct(string $userId) { $this->userId = $userId; } public function setArticle(Article $article) { $this->article = $article; } public function assert(Rbac $rbac, RoleInterface $role = null, string $permission = null) : bool { if (! $this->article) { return false; } return ($this->userId === $this->article->getUserId()); } } // User is assigned the foo role with id 5 // News article belongs to userId 5 // Jazz article belongs to userId 6 $rbac = new Rbac(); $user = $mySessionObject->getUser(); $news = $articleService->getArticle(5); $jazz = $articleService->getArticle(6); $rbac->addRole($user->getRole()); $rbac->getRole($user->getRole())->addPermission('edit.article'); $assertion = new AssertUserRoleMatches($user->getId()); $assertion->setArticle($news); // true always - bad! if ($rbac->isGranted($user->getRole(), 'edit.article')) { // hacks another user's article } // true for user id 5, because he belongs to write group and user id matches if ($rbac->isGranted($user->getRole(), 'edit.article', $assertion)) { // edits his own article } $assertion->setArticle($jazz); // false for user id 5 if ($rbac->isGranted($user->getRole(), 'edit.article', $assertion)) { // can not edit another user's article } Performing the same as above with a closure: // assume same variables from previous example $assertion = function ($rbac) use ($user, $news) { return $user->getId() === $news->getUserId(); }; // true if ($rbac->isGranted($user->getRole(), 'edit.article', $assertion)) { // edits his own article }","title":"Examples"},{"location":"examples/#examples","text":"The following is a list of common use-case examples for laminas-permission-rbac.","title":"Examples"},{"location":"examples/#roles","text":"Extending and adding roles via instantiation: use Laminas\\Permissions\\Rbac\\Rbac; use Laminas\\Permissions\\Rbac\\Role; class MyRole extends Role { // .. implementation } // Creating roles manually $foo = new MyRole('foo'); $rbac = new Rbac(); $rbac->addRole($foo); var_dump($rbac->hasRole('foo')); // true Adding roles directly to RBAC with the default Laminas\\Permission\\Rbac\\Role : use Laminas\\Permissions\\Rbac\\Rbac; $rbac = new Rbac(); $rbac->addRole('foo'); var_dump($rbac->hasRole('foo')); // true Handling roles with children: use Laminas\\Permissions\\Rbac\\Rbac; use Laminas\\Permissions\\Rbac\\Role; $rbac = new Rbac(); $rbac->setCreateMissingRoles(true); $foo = new Role('foo'); $bar = new Role('bar'); // 1 - Add a role with child role directly with instantiated classes. $foo->addChild($bar); $rbac->addRole($foo); // 2 - Same as one, only via rbac container. $rbac->addRole('boo', 'baz'); // baz is a parent of boo $rbac->addRole('baz', ['out', 'of', 'roles']); // create several parents of baz","title":"Roles"},{"location":"examples/#permissions","text":"use Laminas\\Permissions\\Rbac\\Rbac; use Laminas\\Permissions\\Rbac\\Role; $rbac = new Rbac(); $foo = new Role('foo'); $foo->addPermission('bar'); var_dump($foo->hasPermission('bar')); // true $rbac->addRole($foo); $rbac->isGranted('foo', 'bar'); // true $rbac->isGranted('foo', 'baz'); // false $rbac->getRole('foo')->addPermission('baz'); $rbac->isGranted('foo', 'baz'); // true","title":"Permissions"},{"location":"examples/#dynamic-assertions","text":"Checking permission using isGranted() with a class implementing Laminas\\Permissions\\Rbac\\AssertionInterface : use App\\Model\\Article; use Laminas\\Permissions\\Rbac\\AssertionInterface; use Laminas\\Permissions\\Rbac\\Rbac; use Laminas\\Permissions\\Rbac\\RoleInterface; class AssertUserRoleMatches implements AssertionInterface { protected $userId; protected $article; public function __construct(string $userId) { $this->userId = $userId; } public function setArticle(Article $article) { $this->article = $article; } public function assert(Rbac $rbac, RoleInterface $role = null, string $permission = null) : bool { if (! $this->article) { return false; } return ($this->userId === $this->article->getUserId()); } } // User is assigned the foo role with id 5 // News article belongs to userId 5 // Jazz article belongs to userId 6 $rbac = new Rbac(); $user = $mySessionObject->getUser(); $news = $articleService->getArticle(5); $jazz = $articleService->getArticle(6); $rbac->addRole($user->getRole()); $rbac->getRole($user->getRole())->addPermission('edit.article'); $assertion = new AssertUserRoleMatches($user->getId()); $assertion->setArticle($news); // true always - bad! if ($rbac->isGranted($user->getRole(), 'edit.article')) { // hacks another user's article } // true for user id 5, because he belongs to write group and user id matches if ($rbac->isGranted($user->getRole(), 'edit.article', $assertion)) { // edits his own article } $assertion->setArticle($jazz); // false for user id 5 if ($rbac->isGranted($user->getRole(), 'edit.article', $assertion)) { // can not edit another user's article } Performing the same as above with a closure: // assume same variables from previous example $assertion = function ($rbac) use ($user, $news) { return $user->getId() === $news->getUserId(); }; // true if ($rbac->isGranted($user->getRole(), 'edit.article', $assertion)) { // edits his own article }","title":"Dynamic Assertions"},{"location":"intro/","text":"Introduction laminas-permissions-rbac provides a lightweight Role-Based Access Control (RBAC) implementation in PHP. RBAC differs from access control lists (ACL) by putting the emphasis on roles and their permissions rather than objects (resources). For the purposes of this documentation: an identity has one or more roles. a role requests access to a permission. a permission is given to a role. Thus, RBAC has the following model: many to many relationship between identities and roles . many to many relationship between roles and permissions . roles can have parent and child roles (hierarchy of roles). Roles To create a role, create a new class that implements Laminas\\Permission\\Rbac\\RoleInterface or use the default role class, Laminas\\Permission\\Rbac\\Role . You can instantiate a role and add it to the RBAC container or add a role directly using the RBAC container addRole() method. Permissions Each role can have zero or more permissions and can be set directly to the role or by first retrieving the role from the RBAC container. Any parent role will inherit the permissions of their children. Dynamic Assertions In certain situations simply checking a permission key for access may not be enough. For example, assume two users, Foo and Bar, both have article.edit permission. What's to stop Bar from editing Foo's articles? The answer is dynamic assertions which allow you to specify extra runtime credentials that must pass for access to be granted.","title":"Intro"},{"location":"intro/#introduction","text":"laminas-permissions-rbac provides a lightweight Role-Based Access Control (RBAC) implementation in PHP. RBAC differs from access control lists (ACL) by putting the emphasis on roles and their permissions rather than objects (resources). For the purposes of this documentation: an identity has one or more roles. a role requests access to a permission. a permission is given to a role. Thus, RBAC has the following model: many to many relationship between identities and roles . many to many relationship between roles and permissions . roles can have parent and child roles (hierarchy of roles).","title":"Introduction"},{"location":"intro/#roles","text":"To create a role, create a new class that implements Laminas\\Permission\\Rbac\\RoleInterface or use the default role class, Laminas\\Permission\\Rbac\\Role . You can instantiate a role and add it to the RBAC container or add a role directly using the RBAC container addRole() method.","title":"Roles"},{"location":"intro/#permissions","text":"Each role can have zero or more permissions and can be set directly to the role or by first retrieving the role from the RBAC container. Any parent role will inherit the permissions of their children.","title":"Permissions"},{"location":"intro/#dynamic-assertions","text":"In certain situations simply checking a permission key for access may not be enough. For example, assume two users, Foo and Bar, both have article.edit permission. What's to stop Bar from editing Foo's articles? The answer is dynamic assertions which allow you to specify extra runtime credentials that must pass for access to be granted.","title":"Dynamic Assertions"},{"location":"methods/","text":"Methods Laminas\\Permissions\\Rbac\\Role The Role provides the base functionality required by the RoleInterface . Method signature Description __construct(string $name) : void Create a new instance with the provided name. getName() : string Retrieve the name assigned to this role. addPermission(string $name) : void Add a permission for the current role. hasPermission(string $name) : bool Does the role have the given permission? getPermissions(bool $children = true) : array Retrieve all permissions, including child permissions if $children is true. addChild(RoleInterface $child) : Role Add a child role to the current instance. getChildren() : RoleInterface[] Get all child roles. addParent(RoleInterface $parent) : Role Add a parent role to the current instance. getParents() : RoleInterface[] Get all parent roles. Laminas\\Permissions\\Rbac\\AssertionInterface Custom assertions can be provided to Rbac::isGranted() (see below); such assertions are provided the Rbac instance on invocation, along with the role and permission being tested against. Method signature Description assert(Rbac $rbac, RoleInterface $role, string $permission) : bool Given an RBAC, a role, and a permission, determine if permission is granted. Laminas\\Permissions\\Rbac\\Rbac Rbac is the object with which you will interact within your application in order to query for permissions. Method signature Description addRole(string\\|RoleInterface $child, array\\|RoleInterface $parents = null) Add a role to the RBAC. If $parents is non-null, the $child is also added to any parents provided. getRole(string $role) : RoleInterface Get the role specified by name, raising an exception if not found. getRoles(): RoleInterface[] Retrieve all the roles. hasRole(string\\|RoleInterface $role) : bool Recursively queries the RBAC for the given role, returning true if found, false otherwise. getCreateMissingRoles() : bool Retrieve the flag that determines whether or not $parent roles are added automatically if not present when calling addRole() . setCreateMissingRoles(bool $flag) : void Set the flag that determines whether or not $parent roles are added automatically if not present when calling addRole() . isGranted(string\\|RoleInterface $role, string $permission, $assert = null) Determine if the role has the given permission. If $assert is provided and either an AssertInterface instance or callable, it will be queried before checking against the given role.","title":"Methods"},{"location":"methods/#methods","text":"","title":"Methods"},{"location":"methods/#laminaspermissionsrbacrole","text":"The Role provides the base functionality required by the RoleInterface . Method signature Description __construct(string $name) : void Create a new instance with the provided name. getName() : string Retrieve the name assigned to this role. addPermission(string $name) : void Add a permission for the current role. hasPermission(string $name) : bool Does the role have the given permission? getPermissions(bool $children = true) : array Retrieve all permissions, including child permissions if $children is true. addChild(RoleInterface $child) : Role Add a child role to the current instance. getChildren() : RoleInterface[] Get all child roles. addParent(RoleInterface $parent) : Role Add a parent role to the current instance. getParents() : RoleInterface[] Get all parent roles.","title":"Laminas\\Permissions\\Rbac\\Role"},{"location":"methods/#laminaspermissionsrbacassertioninterface","text":"Custom assertions can be provided to Rbac::isGranted() (see below); such assertions are provided the Rbac instance on invocation, along with the role and permission being tested against. Method signature Description assert(Rbac $rbac, RoleInterface $role, string $permission) : bool Given an RBAC, a role, and a permission, determine if permission is granted.","title":"Laminas\\Permissions\\Rbac\\AssertionInterface"},{"location":"methods/#laminaspermissionsrbacrbac","text":"Rbac is the object with which you will interact within your application in order to query for permissions. Method signature Description addRole(string\\|RoleInterface $child, array\\|RoleInterface $parents = null) Add a role to the RBAC. If $parents is non-null, the $child is also added to any parents provided. getRole(string $role) : RoleInterface Get the role specified by name, raising an exception if not found. getRoles(): RoleInterface[] Retrieve all the roles. hasRole(string\\|RoleInterface $role) : bool Recursively queries the RBAC for the given role, returning true if found, false otherwise. getCreateMissingRoles() : bool Retrieve the flag that determines whether or not $parent roles are added automatically if not present when calling addRole() . setCreateMissingRoles(bool $flag) : void Set the flag that determines whether or not $parent roles are added automatically if not present when calling addRole() . isGranted(string\\|RoleInterface $role, string $permission, $assert = null) Determine if the role has the given permission. If $assert is provided and either an AssertInterface instance or callable, it will be queried before checking against the given role.","title":"Laminas\\Permissions\\Rbac\\Rbac"},{"location":"migration/to-v3-0/","text":"Upgrading to 3.0 If you upgrade from version 2 releases, you will notice a few changes. This document details the changes Minimum supported PHP version Version 3 drops support for PHP versions prior to PHP 7.1. AssertionInterface The primary change is the Laminas\\Permissions\\Rbac\\AssertionInterface::assert() method definition. The new assert method has the following signature: namespace Laminas\\Permissions\\Rbac; public function assert( Rbac $rbac, RoleInterface $role, string $permission ) : bool The version 2 releases defined the method such that it only accepted a single parameter, Rbac $rbac . Version 3 adds the $role and $permission parameters. This simplifies implementation of dynamic assertions using the role and the permission information. For instance, imagine you want to disable a specific permission foo for an admin role; you can implement that as follows: public function assert(Rbac $rbac, RoleInterface $role, string $permission) : bool { return ! ($permission === 'foo' && $role->getName() === 'admin'); } If you were previously implementing AssertionInterface , you will need to update the assert() signature to match the changes in version 3. If you were creating assertions as PHP callables, you may continue to use the existing signature; however, you may also expand them to accept the new arguments should they assist you in creating more complex, dynamic assertions. RoleInterface Laminas\\Permissions\\Rbac\\RoleInterface also received a number of changes, including type hints and method name changes. Type hints With the update to PHP 7.1 , we also updated the RoleInterface to provide: scalar type hints where applicable ( addPermission() and hasPermission() ). add return type hints (including scalar type hints) to all methods. You will need to examine the RoleInterface definitions to determine what changes to make to your implementations. setParent becomes addParent In version 3, we renamed the method Role::setParent() to Role::addParent() . This naming is more consistent with other method names, such as Role::addChild() , and also makes clear that more than one parent may be provided to any given role. getParent becomes getParents In line with the previous change, getParent() was also renamed to getParents() , which returns an array of RoleInterface instances. Removed support for string arguments in Role::addChild Version 3 no longer allows adding a child using a string role name; you may only provide RoleInterface instances. Adds getChildren Since roles may have multiple children, the method getChildren() was added; it returns an array of RoleInterface instances.","title":"v2.X to v3.0"},{"location":"migration/to-v3-0/#upgrading-to-30","text":"If you upgrade from version 2 releases, you will notice a few changes. This document details the changes","title":"Upgrading to 3.0"},{"location":"migration/to-v3-0/#minimum-supported-php-version","text":"Version 3 drops support for PHP versions prior to PHP 7.1.","title":"Minimum supported PHP version"},{"location":"migration/to-v3-0/#assertioninterface","text":"The primary change is the Laminas\\Permissions\\Rbac\\AssertionInterface::assert() method definition. The new assert method has the following signature: namespace Laminas\\Permissions\\Rbac; public function assert( Rbac $rbac, RoleInterface $role, string $permission ) : bool The version 2 releases defined the method such that it only accepted a single parameter, Rbac $rbac . Version 3 adds the $role and $permission parameters. This simplifies implementation of dynamic assertions using the role and the permission information. For instance, imagine you want to disable a specific permission foo for an admin role; you can implement that as follows: public function assert(Rbac $rbac, RoleInterface $role, string $permission) : bool { return ! ($permission === 'foo' && $role->getName() === 'admin'); } If you were previously implementing AssertionInterface , you will need to update the assert() signature to match the changes in version 3. If you were creating assertions as PHP callables, you may continue to use the existing signature; however, you may also expand them to accept the new arguments should they assist you in creating more complex, dynamic assertions.","title":"AssertionInterface"},{"location":"migration/to-v3-0/#roleinterface","text":"Laminas\\Permissions\\Rbac\\RoleInterface also received a number of changes, including type hints and method name changes.","title":"RoleInterface"}]} \ No newline at end of file diff --git a/sitemap.xml b/sitemap.xml index 895adee..b65c15e 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -2,27 +2,22 @@ https://docs.laminas.dev/laminas-permissions-rbac/ - 2023-11-27 - daily + 2024-11-21 https://docs.laminas.dev/laminas-permissions-rbac/examples/ - 2023-11-27 - daily + 2024-11-21 https://docs.laminas.dev/laminas-permissions-rbac/intro/ - 2023-11-27 - daily + 2024-11-21 https://docs.laminas.dev/laminas-permissions-rbac/methods/ - 2023-11-27 - daily + 2024-11-21 https://docs.laminas.dev/laminas-permissions-rbac/migration/to-v3-0/ - 2023-11-27 - daily + 2024-11-21 \ No newline at end of file diff --git a/sitemap.xml.gz b/sitemap.xml.gz index bff9d820d7f74c3857c8e1c8c21d108697a3bb67..6d83cfdb7c970a8d7a91b055b2abd3566cbf7a8d 100644 GIT binary patch literal 242 zcmVo?HM%B*K4)Mhwvj6_ca(BK5U(Gg=!`QP%)U2{mqj7QQ+2!Y(f3UMW zbhqTm=BhMD>e-m{^aZdiiy)V6P!kDE1CSm|La-H~7N1NWs$#3aD|%YzQOi|@ii|-` z!mHq-B4O+dTg)e$f}@p;c)BVL9jtS|WfbLrMz(c(;!VTbrnGFe*Isxp{vQN;S7Gv& s_Q2v|PPhk%T)iUHN+X0C{BIZY2W%0IeQ(RR910 literal 259 zcmV+e0sQ_SiwFo&5oKip|8r?{Wo=<_E_iKh0M(OCZiFxlh4*s`lzn1g7X1-qc0ECR zfHZL-QhsQh!u0kHGpOPK?E-IXKRrKvij?kh^{$#Rk&U5eji_0LK}Tc5(6hJK7yigD z^3;7LN0_T(4%D+T=jj<>Sr$PyqgNA&m{`Z`2)up J+MMkJ000fLdG-JR