Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc updates #72

Merged
merged 10 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Upgrade guide

## From LmcRbac v1 to LmcRbac v2

LmcRbac v2 is a major version upgrade with many breaking changes that prevent
straightforward upgrading.

### Namespace change

The namespace has been changed from LmcRbac to Lmc\Rbac. Please review your code to replace `LmcRbac` namespace
by `Lmc\Rbac` namespace.

### Deprecations

- `Lmc\Rbac\HierarchicalRole` has been deprecated since `Lmc\Rbac\Role` now supports hierarchical roles. Flat roles
are just a simplified version of a hierarchical roles. Use `Lmc\Rbac\Role` instead.
- The factories for services have been refactored from the `src/Container` folder
to be colocated with the service that a factory is creating. All factories in the `src/Container` has been deprecated.
- The `AssertionContainer` class, interface and factory have been deprecated and replaced by `AssertionPluginManager` class, interface and factory.

## From ZfcRbac v3 to LmcRbac v1

The ZF-Commons organisation has been moved to LM-Commons and ZfcRbac has been split into two repositories.
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
"friendsofphp/php-cs-fixer": "^3.43",
"php-coveralls/php-coveralls": "^2.0",
"doctrine/orm": "^2.13 | ^3.0",
"symfony/cache": "^4.0| ^5.0 |^6.0"
"symfony/cache": "^4.0 | ^5.0 | ^6.0"
},
"autoload": {
"psr-4": {
"LmcRbac\\": "src/"
"Lmc\\Rbac\\": "src/"
}
},
"autoload-dev": {
Expand Down
4 changes: 2 additions & 2 deletions data/FlatRole.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ declare(strict_types=1);
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use LmcRbac\Permission\PermissionInterface;
use LmcRbac\Role\RoleInterface;
use Lmc\Rbac\Permission\PermissionInterface;
use Lmc\Rbac\Role\RoleInterface;

/**
* @ORM\Entity
Expand Down
6 changes: 3 additions & 3 deletions data/HierarchicalRole.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ declare(strict_types=1);
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use LmcRbac\Role\RoleInterface;
use Lmc\Rbac\Role\RoleInterface;

/**
* @ORM\Entity
Expand Down Expand Up @@ -120,7 +120,7 @@ class HierarchicalRole implements RoleInterface
* @param string|Permission $permission
* @return void
*/
public function addPermission(string|Permission|\LmcRbac\Permission\PermissionInterface $permission): void
public function addPermission(string|Permission|\Lmc\Rbac\Permission\PermissionInterface $permission): void
{
if (is_string($permission)) {
$permission = new Permission($permission);
Expand All @@ -133,7 +133,7 @@ class HierarchicalRole implements RoleInterface
* @param $permission
* @return bool
*/
public function hasPermission(string|\LmcRbac\Permission\PermissionInterface $permission): bool
public function hasPermission(string|\Lmc\Rbac\Permission\PermissionInterface $permission): bool
{
// This can be a performance problem if your role has a lot of permissions. Please refer
// to the cookbook to an elegant way to solve this issue
Expand Down
2 changes: 1 addition & 1 deletion data/Permission.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ declare(strict_types=1);
*/

use Doctrine\ORM\Mapping as ORM;
use LmcRbac\Permission\PermissionInterface;
use Lmc\Rbac\Permission\PermissionInterface;

/**
* @ORM\Entity
Expand Down
5 changes: 2 additions & 3 deletions data/Role.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ declare(strict_types=1);
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use LmcRbac\Permission\PermissionInterface;
use LmcRbac\Role\RoleInterface;
use LmcRbacTest\Asset\Permission;
use Lmc\Rbac\Permission\PermissionInterface;
use Lmc\Rbac\Role\RoleInterface;

/**
* @ORM\Entity
Expand Down
28 changes: 14 additions & 14 deletions docs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3063,11 +3063,11 @@ brace-expansion@^1.1.7:
concat-map "0.0.1"

braces@^3.0.2, braces@~3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
version "3.0.3"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==
dependencies:
fill-range "^7.0.1"
fill-range "^7.1.1"

browserslist@^4.0.0, browserslist@^4.18.1, browserslist@^4.21.10, browserslist@^4.22.2, browserslist@^4.23.0:
version "4.23.0"
Expand Down Expand Up @@ -4300,10 +4300,10 @@ filesize@^8.0.6:
resolved "https://registry.yarnpkg.com/filesize/-/filesize-8.0.7.tgz#695e70d80f4e47012c132d57a059e80c6b580bd8"
integrity sha512-pjmC+bkIF8XI7fWaH8KxHcZL3DPybs1roSKP4rKDvy20tAWwIObE4+JIseG2byfGKhud5ZnM4YSGKBz7Sh0ndQ==

fill-range@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==
fill-range@^7.1.1:
version "7.1.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292"
integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==
dependencies:
to-regex-range "^5.0.1"

Expand Down Expand Up @@ -8607,14 +8607,14 @@ write-file-atomic@^3.0.3:
typedarray-to-buffer "^3.1.5"

ws@^7.3.1:
version "7.5.9"
resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.9.tgz#54fa7db29f4c7cec68b1ddd3a89de099942bb591"
integrity sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==
version "7.5.10"
resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.10.tgz#58b5c20dc281633f6c19113f39b349bd8bd558d9"
integrity sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==

ws@^8.13.0:
version "8.16.0"
resolved "https://registry.yarnpkg.com/ws/-/ws-8.16.0.tgz#d1cd774f36fbc07165066a60e40323eab6446fd4"
integrity sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==
version "8.18.0"
resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc"
integrity sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==

xdg-basedir@^5.0.1, xdg-basedir@^5.1.0:
version "5.1.0"
Expand Down
7 changes: 7 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended"
],
"baseBranches": ["master", "2.x"],
"packageRules": [
{
"matchPackageNames": ["phpunit/phpunit"],
"allowedVersions": "<11.0"
}
]
}
2 changes: 1 addition & 1 deletion src/Assertion/AssertionContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

declare(strict_types=1);

namespace LmcRbac\Assertion;
namespace Lmc\Rbac\Assertion;

use Laminas\ServiceManager\AbstractPluginManager;

Expand Down
2 changes: 1 addition & 1 deletion src/Assertion/AssertionContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

declare(strict_types=1);

namespace LmcRbac\Assertion;
namespace Lmc\Rbac\Assertion;

use Psr\Container\ContainerInterface;

Expand Down
2 changes: 1 addition & 1 deletion src/Assertion/AssertionContainerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

declare(strict_types=1);

namespace LmcRbac\Assertion;
namespace Lmc\Rbac\Assertion;

use Psr\Container\ContainerInterface;

Expand Down
6 changes: 3 additions & 3 deletions src/Assertion/AssertionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

declare(strict_types=1);

namespace LmcRbac\Assertion;
namespace Lmc\Rbac\Assertion;

use LmcRbac\Identity\IdentityInterface;
use LmcRbac\Permission\PermissionInterface;
use Lmc\Rbac\Identity\IdentityInterface;
use Lmc\Rbac\Permission\PermissionInterface;

/**
* Interface that you can implement for dynamic assertions
Expand Down
4 changes: 2 additions & 2 deletions src/Assertion/AssertionPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace LmcRbac\Assertion;
namespace Lmc\Rbac\Assertion;

use Laminas\ServiceManager\AbstractPluginManager;
use Laminas\ServiceManager\Exception\InvalidServiceException;
Expand All @@ -19,7 +19,7 @@ public function validate(mixed $instance): void
return;
}
throw new InvalidServiceException(sprintf(
'Assertions must implement "LmcRbac\Assertion\AssertionInterface", but "%s" was given',
'Assertions must implement "Lmc\Rbac\Assertion\AssertionInterface", but "%s" was given',
get_class($instance)
));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Assertion/AssertionPluginManagerFactory.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace LmcRbac\Assertion;
namespace Lmc\Rbac\Assertion;

use Laminas\ServiceManager\Factory\FactoryInterface;
use Psr\Container\ContainerInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Assertion/AssertionPluginManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

declare(strict_types=1);

namespace LmcRbac\Assertion;
namespace Lmc\Rbac\Assertion;

use Psr\Container\ContainerInterface;

Expand Down
10 changes: 5 additions & 5 deletions src/Assertion/AssertionSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
* and is licensed under the MIT license.
*/

namespace LmcRbac\Assertion;
namespace Lmc\Rbac\Assertion;

use LmcRbac\Exception;
use LmcRbac\Identity\IdentityInterface;
use LmcRbac\Permission\PermissionInterface;
use Lmc\Rbac\Exception;
use Lmc\Rbac\Identity\IdentityInterface;
use Lmc\Rbac\Permission\PermissionInterface;

class AssertionSet implements AssertionInterface
{
Expand Down Expand Up @@ -89,7 +89,7 @@ public function assert(PermissionInterface|string $permission, IdentityInterface
break;
default:
throw new Exception\InvalidArgumentException(sprintf(
'Assertion must be callable, string, array or implement LmcRbac\Assertion\AssertionInterface, "%s" given',
'Assertion must be callable, string, array or implement Lmc\Rbac\Assertion\AssertionInterface, "%s" given',
is_object($assertion) ? get_class($assertion) : gettype($assertion)
));
}
Expand Down
20 changes: 10 additions & 10 deletions src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

declare(strict_types=1);

namespace LmcRbac;
namespace Lmc\Rbac;

use LmcRbac\Assertion\AssertionPluginManager;
use LmcRbac\Identity\AuthenticationIdentityProvider;
use Lmc\Rbac\Assertion\AssertionPluginManager;
use Lmc\Rbac\Identity\AuthenticationIdentityProvider;

/**
* The configuration provider for the LmcRbac module
Expand All @@ -43,13 +43,13 @@ public function getDependencyConfig(): array
{
return [
'factories' => [
\LmcRbac\Assertion\AssertionPluginManager::class => \LmcRbac\Assertion\AssertionPluginManagerFactory::class,
\LmcRbac\Options\ModuleOptions::class => \LmcRbac\Options\ModuleOptionsFactory::class,
\LmcRbac\Role\InMemoryRoleProvider::class => \LmcRbac\Role\InMemoryRoleProviderFactory::class,
\LmcRbac\Role\ObjectRepositoryRoleProvider::class => \LmcRbac\Role\ObjectRepositoryRoleProviderFactory::class,
\LmcRbac\Service\AuthorizationServiceInterface::class => \LmcRbac\Service\AuthorizationServiceFactory::class,
\LmcRbac\Service\RoleServiceInterface::class => \LmcRbac\Service\RoleServiceFactory::class,
\LmcRbac\Rbac::class => \Laminas\ServiceManager\Factory\InvokableFactory::class,
\Lmc\Rbac\Assertion\AssertionPluginManager::class => \Lmc\Rbac\Assertion\AssertionPluginManagerFactory::class,
\Lmc\Rbac\Options\ModuleOptions::class => \Lmc\Rbac\Options\ModuleOptionsFactory::class,
\Lmc\Rbac\Role\InMemoryRoleProvider::class => \Lmc\Rbac\Role\InMemoryRoleProviderFactory::class,
\Lmc\Rbac\Role\ObjectRepositoryRoleProvider::class => \Lmc\Rbac\Role\ObjectRepositoryRoleProviderFactory::class,
\Lmc\Rbac\Service\AuthorizationServiceInterface::class => \Lmc\Rbac\Service\AuthorizationServiceFactory::class,
\Lmc\Rbac\Service\RoleServiceInterface::class => \Lmc\Rbac\Service\RoleServiceFactory::class,
\Lmc\Rbac\Rbac::class => \Laminas\ServiceManager\Factory\InvokableFactory::class,
],
];
}
Expand Down
8 changes: 4 additions & 4 deletions src/Container/AssertionContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@

declare(strict_types=1);

namespace LmcRbac\Container;
namespace Lmc\Rbac\Container;

use LmcRbac\Assertion\AssertionContainer;
use Lmc\Rbac\Assertion\AssertionContainer;
use Psr\Container\ContainerInterface;

/**
* Factory to create a assertion plugin manager
*
* @author Aeneas Rekkas
* @licence MIT
* @deprecated Replaced by LmcRbac\Assertion\AssertionContainerFactory
* @deprecated Replaced by Lmc\Rbac\Assertion\AssertionContainerFactory
*/
final class AssertionContainerFactory extends \LmcRbac\Assertion\AssertionContainerFactory
final class AssertionContainerFactory extends \Lmc\Rbac\Assertion\AssertionContainerFactory
{
}
16 changes: 8 additions & 8 deletions src/Container/AuthorizationServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@

declare(strict_types=1);

namespace LmcRbac\Container;
namespace Lmc\Rbac\Container;

use LmcRbac\Assertion\AssertionContainerInterface;
use LmcRbac\Options\ModuleOptions;
use LmcRbac\Rbac;
use LmcRbac\Service\AuthorizationService;
use LmcRbac\Service\RoleServiceInterface;
use Lmc\Rbac\Assertion\AssertionContainerInterface;
use Lmc\Rbac\Options\ModuleOptions;
use Lmc\Rbac\Rbac;
use Lmc\Rbac\Service\AuthorizationService;
use Lmc\Rbac\Service\RoleServiceInterface;
use Psr\Container\ContainerInterface;

/**
* Factory to create the authorization service
*
* @author Michaël Gallego <[email protected]>
* @licence MIT
* @deprecated Replaced by LmcRbac\Service\AuthorizationServiceFactory
* @deprecated Replaced by Lmc\Rbac\Service\AuthorizationServiceFactory
*/
final class AuthorizationServiceFactory extends \LmcRbac\Service\AuthorizationServiceFactory
final class AuthorizationServiceFactory extends \Lmc\Rbac\Service\AuthorizationServiceFactory
{
}
10 changes: 5 additions & 5 deletions src/Container/InMemoryRoleProviderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@

declare(strict_types=1);

namespace LmcRbac\Container;
namespace Lmc\Rbac\Container;

use LmcRbac\Options\ModuleOptions;
use LmcRbac\Role\InMemoryRoleProvider;
use Lmc\Rbac\Options\ModuleOptions;
use Lmc\Rbac\Role\InMemoryRoleProvider;
use Psr\Container\ContainerInterface;

/**
* Factory used to create an in memory role provider
*
* @author Vytautas Stankus
* @licence MIT
* @deprecated Replaced by LmcRbac\Role\InMemoryRoleProviderFactory
* @deprecated Replaced by Lmc\Rbac\Role\InMemoryRoleProviderFactory
*/
final class InMemoryRoleProviderFactory extends \LmcRbac\Role\InMemoryRoleProviderFactory
final class InMemoryRoleProviderFactory extends \Lmc\Rbac\Role\InMemoryRoleProviderFactory
{
}
8 changes: 4 additions & 4 deletions src/Container/ModuleOptionsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@

declare(strict_types=1);

namespace LmcRbac\Container;
namespace Lmc\Rbac\Container;

use LmcRbac\Options\ModuleOptions;
use Lmc\Rbac\Options\ModuleOptions;
use Psr\Container\ContainerInterface;

/**
* Factory for the module options
*
* @author Michaël Gallego <[email protected]>
* @licence MIT
* @deprecated Replaced by LmcRbac\Options\ModuleOptionsFactory
* @deprecated Replaced by Lmc\Rbac\Options\ModuleOptionsFactory
*/
final class ModuleOptionsFactory extends \LmcRbac\Options\ModuleOptionsFactory
final class ModuleOptionsFactory extends \Lmc\Rbac\Options\ModuleOptionsFactory
{
}
Loading