From c363eade59b5bdcb2f6124bb33a1110c375c0e55 Mon Sep 17 00:00:00 2001 From: Arminek Date: Tue, 23 Aug 2016 11:14:23 +0200 Subject: [PATCH 1/2] [Rbac] remove rbac bundle and component --- app/config/config_test.yml | 3 - phpspec.yml.dist | 2 - .../Menu/AbstractAdminMenuBuilder.php | 2 +- .../AdminBundle/Resources/config/menu.xml | 2 +- .../Bundle/CoreBundle/Application/Kernel.php | 1 - .../AddAdministratorRoleListener.php | 58 --- .../Factory/AdminUserExampleFactory.php | 31 +- .../Bundle/CoreBundle/Fixture/RbacFixture.php | 51 -- .../Resources/config/app/sylius.yml | 459 ------------------ .../config/doctrine/model/AdminUser.orm.xml | 11 - .../config/doctrine/model/ShopUser.orm.xml | 11 - .../CoreBundle/Resources/config/fixtures.xml | 5 - .../Resources/config/fixtures_factories.xml | 1 - .../CoreBundle/Resources/config/services.xml | 9 - src/Sylius/Bundle/CoreBundle/composer.json | 1 - .../AddAdministratorRoleListenerSpec.php | 74 --- src/Sylius/Bundle/RbacBundle/.gitignore | 5 - .../RbacAuthorizationChecker.php | 50 -- src/Sylius/Bundle/RbacBundle/CHANGELOG.md | 6 - .../RbacBundle/Command/InitializeCommand.php | 50 -- .../DependencyInjection/Configuration.php | 212 -------- .../SyliusRbacExtension.php | 100 ---- .../Doctrine/ORM/PermissionRepository.php | 37 -- .../Doctrine/ORM/RoleRepository.php | 37 -- .../RbacBundle/Doctrine/RbacInitializer.php | 175 ------- .../EventListener/CacheListener.php | 70 --- .../AddParentFormSubscriber.php | 75 --- .../Form/Type/PermissionEntityType.php | 35 -- .../RbacBundle/Form/Type/PermissionType.php | 47 -- .../RbacBundle/Form/Type/RoleEntityType.php | 35 -- .../Bundle/RbacBundle/Form/Type/RoleType.php | 61 --- .../Form/Type/SecurityRoleChoiceType.php | 64 --- .../Provider/SecurityIdentityProvider.php | 60 --- src/Sylius/Bundle/RbacBundle/README.md | 74 --- .../config/doctrine/model/Permission.orm.xml | 66 --- .../config/doctrine/model/Role.orm.xml | 80 --- .../Resources/config/driver/doctrine/orm.xml | 38 -- .../Resources/config/resource_integration.xml | 28 -- .../RbacBundle/Resources/config/services.xml | 78 --- .../Resources/config/templating.xml | 30 -- .../RbacBundle/Resources/config/twig.xml | 30 -- .../Resources/config/validation.xml | 59 --- .../Bundle/RbacBundle/Resources/meta/LICENSE | 19 - .../Resources/translations/messages.ar.yml | 7 - .../Resources/translations/messages.be.yml | 14 - .../Resources/translations/messages.ca.yml | 12 - .../Resources/translations/messages.cs.yml | 15 - .../Resources/translations/messages.da.yml | 14 - .../Resources/translations/messages.de.yml | 15 - .../Resources/translations/messages.de_CH.yml | 10 - .../Resources/translations/messages.el.yml | 12 - .../Resources/translations/messages.en.yml | 12 - .../Resources/translations/messages.es.yml | 15 - .../Resources/translations/messages.fa.yml | 15 - .../Resources/translations/messages.fi.yml | 9 - .../Resources/translations/messages.fr.yml | 15 - .../Resources/translations/messages.hr.yml | 15 - .../Resources/translations/messages.hu.yml | 15 - .../Resources/translations/messages.id.yml | 10 - .../Resources/translations/messages.it.yml | 15 - .../Resources/translations/messages.lt.yml | 15 - .../Resources/translations/messages.nl.yml | 15 - .../Resources/translations/messages.no.yml | 14 - .../Resources/translations/messages.pl.yml | 15 - .../Resources/translations/messages.pt.yml | 11 - .../Resources/translations/messages.pt_BR.yml | 15 - .../Resources/translations/messages.ro.yml | 14 - .../Resources/translations/messages.ru.yml | 15 - .../Resources/translations/messages.sk.yml | 15 - .../Resources/translations/messages.sl.yml | 15 - .../Resources/translations/messages.sq.yml | 15 - .../Resources/translations/messages.sr_CS.yml | 7 - .../Resources/translations/messages.sv.yml | 15 - .../Resources/translations/messages.th.yml | 15 - .../Resources/translations/messages.tr.yml | 15 - .../Resources/translations/messages.uk.yml | 15 - .../Resources/translations/messages.vi.yml | 10 - .../Resources/translations/messages.zh_CN.yml | 15 - .../Resources/translations/validators.cs.yml | 16 - .../Resources/translations/validators.de.yml | 16 - .../Resources/translations/validators.en.yml | 13 - .../Resources/translations/validators.es.yml | 16 - .../Resources/translations/validators.fa.yml | 16 - .../Resources/translations/validators.fr.yml | 16 - .../Resources/translations/validators.hu.yml | 16 - .../Resources/translations/validators.it.yml | 16 - .../Resources/translations/validators.lt.yml | 16 - .../Resources/translations/validators.nl.yml | 16 - .../Resources/translations/validators.pl.yml | 16 - .../Resources/translations/validators.pt.yml | 10 - .../translations/validators.pt_BR.yml | 16 - .../Resources/translations/validators.ru.yml | 16 - .../Resources/translations/validators.sk.yml | 16 - .../Resources/translations/validators.sl.yml | 16 - .../Resources/translations/validators.sq.yml | 16 - .../Resources/translations/validators.th.yml | 16 - .../Resources/translations/validators.tr.yml | 16 - .../translations/validators.zh_CN.yml | 16 - .../Bundle/RbacBundle/SyliusRbacBundle.php | 41 -- .../Templating/Helper/RbacHelper.php | 51 -- .../Bundle/RbacBundle/Twig/RbacExtension.php | 65 --- src/Sylius/Bundle/RbacBundle/composer.json | 58 --- src/Sylius/Bundle/RbacBundle/phpspec.yml.dist | 5 - .../RbacAuthorizationCheckerSpec.php | 57 --- .../Doctrine/ORM/PermissionRepositorySpec.php | 63 --- .../spec/Doctrine/ORM/RoleRepositorySpec.php | 63 --- .../spec/EventListener/CacheListenerSpec.php | 72 --- .../AddParentFormSubscriberSpec.php | 113 ----- .../Form/Type/PermissionEntityTypeSpec.php | 50 -- .../spec/Form/Type/PermissionTypeSpec.php | 82 ---- .../spec/Form/Type/RoleEntityTypeSpec.php | 50 -- .../spec/Form/Type/RoleTypeSpec.php | 94 ---- .../Form/Type/SecurityRoleChoiceTypeSpec.php | 62 --- .../Provider/SecurityIdentityProviderSpec.php | 82 ---- .../spec/Templating/Helper/RbacHelperSpec.php | 46 -- .../spec/Twig/RbacExtensionSpec.php | 36 -- src/Sylius/Component/Core/Model/AdminUser.php | 64 --- .../Core/Model/AdminUserInterface.php | 21 +- src/Sylius/Component/Core/Model/ShopUser.php | 65 +-- .../Core/Model/ShopUserInterface.php | 20 +- .../Core/spec/Model/AdminUserSpec.php | 13 - .../Core/spec/Model/ShopUserSpec.php | 13 - src/Sylius/Component/Rbac/.gitignore | 5 - .../Authorization/AuthorizationChecker.php | 80 --- .../AuthorizationCheckerInterface.php | 27 -- .../Authorization/CachedPermissionMap.php | 92 ---- .../Rbac/Authorization/PermissionMap.php | 95 ---- .../Authorization/PermissionMapInterface.php | 38 -- src/Sylius/Component/Rbac/CHANGELOG.md | 6 - .../Exception/PermissionNotFoundException.php | 25 - src/Sylius/Component/Rbac/LICENSE | 19 - .../Rbac/Model/IdentityInterface.php | 27 -- .../Component/Rbac/Model/Permission.php | 233 --------- .../Rbac/Model/PermissionInterface.php | 102 ---- src/Sylius/Component/Rbac/Model/Role.php | 320 ------------ .../Component/Rbac/Model/RoleInterface.php | 134 ----- .../CurrentIdentityProviderInterface.php | 29 -- .../Rbac/Provider/PermissionProvider.php | 48 -- .../Provider/PermissionProviderInterface.php | 34 -- src/Sylius/Component/Rbac/README.md | 47 -- .../PermissionRepositoryInterface.php | 28 -- .../Repository/RoleRepositoryInterface.php | 28 -- .../Resolver/NestedSetPermissionsResolver.php | 63 --- .../Rbac/Resolver/NestedSetRolesResolver.php | 71 --- .../Rbac/Resolver/PermissionsResolver.php | 44 -- .../Resolver/PermissionsResolverInterface.php | 32 -- .../Resolver/RecursivePermissionIterator.php | 44 -- .../Rbac/Resolver/RecursiveRoleIterator.php | 44 -- .../Component/Rbac/Resolver/RolesResolver.php | 33 -- .../Rbac/Resolver/RolesResolverInterface.php | 31 -- src/Sylius/Component/Rbac/composer.json | 52 -- src/Sylius/Component/Rbac/phpspec.yml.dist | 5 - .../AuthorizationCheckerSpec.php | 87 ---- .../Authorization/CachedPermissionMapSpec.php | 57 --- .../spec/Authorization/PermissionMapSpec.php | 72 --- .../Rbac/spec/Model/PermissionSpec.php | 79 --- .../Component/Rbac/spec/Model/RoleSpec.php | 100 ---- .../spec/Provider/PermissionProviderSpec.php | 53 -- 158 files changed, 8 insertions(+), 6686 deletions(-) delete mode 100644 src/Sylius/Bundle/CoreBundle/EventListener/AddAdministratorRoleListener.php delete mode 100644 src/Sylius/Bundle/CoreBundle/Fixture/RbacFixture.php delete mode 100644 src/Sylius/Bundle/CoreBundle/spec/EventListener/AddAdministratorRoleListenerSpec.php delete mode 100644 src/Sylius/Bundle/RbacBundle/.gitignore delete mode 100644 src/Sylius/Bundle/RbacBundle/Authorization/RbacAuthorizationChecker.php delete mode 100644 src/Sylius/Bundle/RbacBundle/CHANGELOG.md delete mode 100644 src/Sylius/Bundle/RbacBundle/Command/InitializeCommand.php delete mode 100644 src/Sylius/Bundle/RbacBundle/DependencyInjection/Configuration.php delete mode 100644 src/Sylius/Bundle/RbacBundle/DependencyInjection/SyliusRbacExtension.php delete mode 100644 src/Sylius/Bundle/RbacBundle/Doctrine/ORM/PermissionRepository.php delete mode 100644 src/Sylius/Bundle/RbacBundle/Doctrine/ORM/RoleRepository.php delete mode 100644 src/Sylius/Bundle/RbacBundle/Doctrine/RbacInitializer.php delete mode 100644 src/Sylius/Bundle/RbacBundle/EventListener/CacheListener.php delete mode 100644 src/Sylius/Bundle/RbacBundle/Form/EventSubscriber/AddParentFormSubscriber.php delete mode 100644 src/Sylius/Bundle/RbacBundle/Form/Type/PermissionEntityType.php delete mode 100644 src/Sylius/Bundle/RbacBundle/Form/Type/PermissionType.php delete mode 100644 src/Sylius/Bundle/RbacBundle/Form/Type/RoleEntityType.php delete mode 100644 src/Sylius/Bundle/RbacBundle/Form/Type/RoleType.php delete mode 100644 src/Sylius/Bundle/RbacBundle/Form/Type/SecurityRoleChoiceType.php delete mode 100644 src/Sylius/Bundle/RbacBundle/Provider/SecurityIdentityProvider.php delete mode 100644 src/Sylius/Bundle/RbacBundle/README.md delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/config/doctrine/model/Permission.orm.xml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/config/doctrine/model/Role.orm.xml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/config/driver/doctrine/orm.xml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/config/resource_integration.xml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/config/services.xml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/config/templating.xml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/config/twig.xml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/config/validation.xml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/meta/LICENSE delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.ar.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.be.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.ca.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.cs.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.da.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.de.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.de_CH.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.el.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.en.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.es.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.fa.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.fi.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.fr.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.hr.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.hu.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.id.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.it.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.lt.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.nl.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.no.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.pl.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.pt.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.pt_BR.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.ro.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.ru.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.sk.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.sl.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.sq.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.sr_CS.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.sv.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.th.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.tr.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.uk.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.vi.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/messages.zh_CN.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/validators.cs.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/validators.de.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/validators.en.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/validators.es.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/validators.fa.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/validators.fr.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/validators.hu.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/validators.it.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/validators.lt.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/validators.nl.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/validators.pl.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/validators.pt.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/validators.pt_BR.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/validators.ru.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/validators.sk.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/validators.sl.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/validators.sq.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/validators.th.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/validators.tr.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/Resources/translations/validators.zh_CN.yml delete mode 100644 src/Sylius/Bundle/RbacBundle/SyliusRbacBundle.php delete mode 100644 src/Sylius/Bundle/RbacBundle/Templating/Helper/RbacHelper.php delete mode 100644 src/Sylius/Bundle/RbacBundle/Twig/RbacExtension.php delete mode 100644 src/Sylius/Bundle/RbacBundle/composer.json delete mode 100644 src/Sylius/Bundle/RbacBundle/phpspec.yml.dist delete mode 100644 src/Sylius/Bundle/RbacBundle/spec/Authorization/RbacAuthorizationCheckerSpec.php delete mode 100644 src/Sylius/Bundle/RbacBundle/spec/Doctrine/ORM/PermissionRepositorySpec.php delete mode 100644 src/Sylius/Bundle/RbacBundle/spec/Doctrine/ORM/RoleRepositorySpec.php delete mode 100644 src/Sylius/Bundle/RbacBundle/spec/EventListener/CacheListenerSpec.php delete mode 100644 src/Sylius/Bundle/RbacBundle/spec/Form/EventSubscriber/AddParentFormSubscriberSpec.php delete mode 100644 src/Sylius/Bundle/RbacBundle/spec/Form/Type/PermissionEntityTypeSpec.php delete mode 100644 src/Sylius/Bundle/RbacBundle/spec/Form/Type/PermissionTypeSpec.php delete mode 100644 src/Sylius/Bundle/RbacBundle/spec/Form/Type/RoleEntityTypeSpec.php delete mode 100644 src/Sylius/Bundle/RbacBundle/spec/Form/Type/RoleTypeSpec.php delete mode 100644 src/Sylius/Bundle/RbacBundle/spec/Form/Type/SecurityRoleChoiceTypeSpec.php delete mode 100644 src/Sylius/Bundle/RbacBundle/spec/Provider/SecurityIdentityProviderSpec.php delete mode 100644 src/Sylius/Bundle/RbacBundle/spec/Templating/Helper/RbacHelperSpec.php delete mode 100644 src/Sylius/Bundle/RbacBundle/spec/Twig/RbacExtensionSpec.php delete mode 100644 src/Sylius/Component/Rbac/.gitignore delete mode 100644 src/Sylius/Component/Rbac/Authorization/AuthorizationChecker.php delete mode 100644 src/Sylius/Component/Rbac/Authorization/AuthorizationCheckerInterface.php delete mode 100644 src/Sylius/Component/Rbac/Authorization/CachedPermissionMap.php delete mode 100644 src/Sylius/Component/Rbac/Authorization/PermissionMap.php delete mode 100644 src/Sylius/Component/Rbac/Authorization/PermissionMapInterface.php delete mode 100644 src/Sylius/Component/Rbac/CHANGELOG.md delete mode 100644 src/Sylius/Component/Rbac/Exception/PermissionNotFoundException.php delete mode 100644 src/Sylius/Component/Rbac/LICENSE delete mode 100644 src/Sylius/Component/Rbac/Model/IdentityInterface.php delete mode 100644 src/Sylius/Component/Rbac/Model/Permission.php delete mode 100644 src/Sylius/Component/Rbac/Model/PermissionInterface.php delete mode 100644 src/Sylius/Component/Rbac/Model/Role.php delete mode 100644 src/Sylius/Component/Rbac/Model/RoleInterface.php delete mode 100644 src/Sylius/Component/Rbac/Provider/CurrentIdentityProviderInterface.php delete mode 100644 src/Sylius/Component/Rbac/Provider/PermissionProvider.php delete mode 100644 src/Sylius/Component/Rbac/Provider/PermissionProviderInterface.php delete mode 100644 src/Sylius/Component/Rbac/README.md delete mode 100644 src/Sylius/Component/Rbac/Repository/PermissionRepositoryInterface.php delete mode 100644 src/Sylius/Component/Rbac/Repository/RoleRepositoryInterface.php delete mode 100644 src/Sylius/Component/Rbac/Resolver/NestedSetPermissionsResolver.php delete mode 100644 src/Sylius/Component/Rbac/Resolver/NestedSetRolesResolver.php delete mode 100644 src/Sylius/Component/Rbac/Resolver/PermissionsResolver.php delete mode 100644 src/Sylius/Component/Rbac/Resolver/PermissionsResolverInterface.php delete mode 100644 src/Sylius/Component/Rbac/Resolver/RecursivePermissionIterator.php delete mode 100644 src/Sylius/Component/Rbac/Resolver/RecursiveRoleIterator.php delete mode 100644 src/Sylius/Component/Rbac/Resolver/RolesResolver.php delete mode 100644 src/Sylius/Component/Rbac/Resolver/RolesResolverInterface.php delete mode 100644 src/Sylius/Component/Rbac/composer.json delete mode 100644 src/Sylius/Component/Rbac/phpspec.yml.dist delete mode 100644 src/Sylius/Component/Rbac/spec/Authorization/AuthorizationCheckerSpec.php delete mode 100644 src/Sylius/Component/Rbac/spec/Authorization/CachedPermissionMapSpec.php delete mode 100644 src/Sylius/Component/Rbac/spec/Authorization/PermissionMapSpec.php delete mode 100644 src/Sylius/Component/Rbac/spec/Model/PermissionSpec.php delete mode 100644 src/Sylius/Component/Rbac/spec/Model/RoleSpec.php delete mode 100644 src/Sylius/Component/Rbac/spec/Provider/PermissionProviderSpec.php diff --git a/app/config/config_test.yml b/app/config/config_test.yml index a4a2048bdc..96b507414e 100644 --- a/app/config/config_test.yml +++ b/app/config/config_test.yml @@ -56,9 +56,6 @@ sylius_payment: stripe: Stripe paypal_express_checkout: Paypal Express Checkout -sylius_rbac: - authorization_checker: sylius.authorization_checker.toggleable - sylius_theme: sources: test: ~ diff --git a/phpspec.yml.dist b/phpspec.yml.dist index ce581c93af..8b6fa19c2f 100644 --- a/phpspec.yml.dist +++ b/phpspec.yml.dist @@ -20,7 +20,6 @@ suites: Pricing: { namespace: Sylius\Component\Pricing, psr4_prefix: Sylius\Component\Pricing, spec_path: src/Sylius/Component/Pricing, src_path: src/Sylius/Component/Pricing } Product: { namespace: Sylius\Component\Product, psr4_prefix: Sylius\Component\Product, spec_path: src/Sylius/Component/Product, src_path: src/Sylius/Component/Product } Promotion: { namespace: Sylius\Component\Promotion, psr4_prefix: Sylius\Component\Promotion, spec_path: src/Sylius/Component/Promotion, src_path: src/Sylius/Component/Promotion } - Rbac: { namespace: Sylius\Component\Rbac, psr4_prefix: Sylius\Component\Rbac, spec_path: src/Sylius/Component/Rbac, src_path: src/Sylius/Component/Rbac } Registry: { namespace: Sylius\Component\Registry, psr4_prefix: Sylius\Component\Registry, spec_path: src/Sylius/Component/Registry, src_path: src/Sylius/Component/Registry } Report: { namespace: Sylius\Component\Report, psr4_prefix: Sylius\Component\Report, spec_path: src/Sylius/Component/Report, src_path: src/Sylius/Component/Report } Resource: { namespace: Sylius\Component\Resource, psr4_prefix: Sylius\Component\Resource, spec_path: src/Sylius/Component/Resource, src_path: src/Sylius/Component/Resource } @@ -60,7 +59,6 @@ suites: PricingBundle: { namespace: Sylius\Bundle\PricingBundle, psr4_prefix: Sylius\Bundle\PricingBundle, spec_path: src/Sylius/Bundle/PricingBundle, src_path: src/Sylius/Bundle/PricingBundle } ProductBundle: { namespace: Sylius\Bundle\ProductBundle, psr4_prefix: Sylius\Bundle\ProductBundle, spec_path: src/Sylius/Bundle/ProductBundle, src_path: src/Sylius/Bundle/ProductBundle } PromotionBundle: { namespace: Sylius\Bundle\PromotionBundle, psr4_prefix: Sylius\Bundle\PromotionBundle, spec_path: src/Sylius/Bundle/PromotionBundle, src_path: src/Sylius/Bundle/PromotionBundle } - RbacBundle: { namespace: Sylius\Bundle\RbacBundle, psr4_prefix: Sylius\Bundle\RbacBundle, spec_path: src/Sylius/Bundle/RbacBundle, src_path: src/Sylius/Bundle/RbacBundle } ReportBundle: { namespace: Sylius\Bundle\ReportBundle, psr4_prefix: Sylius\Bundle\ReportBundle, spec_path: src/Sylius/Bundle/ReportBundle, src_path: src/Sylius/Bundle/ReportBundle } ResourceBundle: { namespace: Sylius\Bundle\ResourceBundle, psr4_prefix: Sylius\Bundle\ResourceBundle, spec_path: src/Sylius/Bundle/ResourceBundle, src_path: src/Sylius/Bundle/ResourceBundle } ReviewBundle: { namespace: Sylius\Bundle\ReviewBundle, psr4_prefix: Sylius\Bundle\ReviewBundle, spec_path: src/Sylius/Bundle/ReviewBundle, src_path: src/Sylius/Bundle/ReviewBundle } diff --git a/src/Sylius/Bundle/AdminBundle/Menu/AbstractAdminMenuBuilder.php b/src/Sylius/Bundle/AdminBundle/Menu/AbstractAdminMenuBuilder.php index 4b147b8d5e..1afdc471f6 100644 --- a/src/Sylius/Bundle/AdminBundle/Menu/AbstractAdminMenuBuilder.php +++ b/src/Sylius/Bundle/AdminBundle/Menu/AbstractAdminMenuBuilder.php @@ -12,8 +12,8 @@ namespace Sylius\Bundle\AdminBundle\Menu; use Knp\Menu\FactoryInterface; +use Sylius\Bundle\ResourceBundle\Controller\AuthorizationCheckerInterface; use Sylius\Bundle\UiBundle\Menu\AbstractMenuBuilder; -use Sylius\Component\Rbac\Authorization\AuthorizationCheckerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/menu.xml b/src/Sylius/Bundle/AdminBundle/Resources/config/menu.xml index 7fde7926c7..0412512d5b 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/menu.xml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/menu.xml @@ -22,7 +22,7 @@ - + diff --git a/src/Sylius/Bundle/CoreBundle/Application/Kernel.php b/src/Sylius/Bundle/CoreBundle/Application/Kernel.php index ee6eea5653..e8a0e1691d 100644 --- a/src/Sylius/Bundle/CoreBundle/Application/Kernel.php +++ b/src/Sylius/Bundle/CoreBundle/Application/Kernel.php @@ -57,7 +57,6 @@ class Kernel extends HttpKernel new \Sylius\Bundle\FlowBundle\SyliusFlowBundle(), new \Sylius\Bundle\PricingBundle\SyliusPricingBundle(), new \Sylius\Bundle\ContentBundle\SyliusContentBundle(), - new \Sylius\Bundle\RbacBundle\SyliusRbacBundle(), new \Sylius\Bundle\UserBundle\SyliusUserBundle(), new \Sylius\Bundle\CustomerBundle\SyliusCustomerBundle(), new \Sylius\Bundle\UiBundle\SyliusUiBundle(), diff --git a/src/Sylius/Bundle/CoreBundle/EventListener/AddAdministratorRoleListener.php b/src/Sylius/Bundle/CoreBundle/EventListener/AddAdministratorRoleListener.php deleted file mode 100644 index 1b4d1970a6..0000000000 --- a/src/Sylius/Bundle/CoreBundle/EventListener/AddAdministratorRoleListener.php +++ /dev/null @@ -1,58 +0,0 @@ - - */ -final class AddAdministratorRoleListener -{ - /** - * @var RoleRepositoryInterface - */ - private $roleRepository; - - /** - * @param RoleRepositoryInterface $roleRepository - */ - public function __construct(RoleRepositoryInterface $roleRepository) - { - $this->roleRepository = $roleRepository; - } - - /** - * @param GenericEvent $event - * - * @throws \RuntimeException - */ - public function addAdministrationRole(GenericEvent $event) - { - /** @var AdminUserInterface $adminUser */ - $adminUser = $event->getSubject(); - - if (!$adminUser instanceof AdminUserInterface) { - throw new \RuntimeException(sprintf('Expected %s, got %s', AdminUserInterface::class, get_class($adminUser))); - } - - /** @var RoleInterface $administratorRole */ - $administratorRole = $this->roleRepository->findOneBy(['code' => 'administrator']); - - if (null !== $administratorRole) { - $adminUser->addAuthorizationRole($administratorRole); - } - } -} diff --git a/src/Sylius/Bundle/CoreBundle/Fixture/Factory/AdminUserExampleFactory.php b/src/Sylius/Bundle/CoreBundle/Fixture/Factory/AdminUserExampleFactory.php index 9b4ef72c96..891f88829d 100644 --- a/src/Sylius/Bundle/CoreBundle/Fixture/Factory/AdminUserExampleFactory.php +++ b/src/Sylius/Bundle/CoreBundle/Fixture/Factory/AdminUserExampleFactory.php @@ -12,9 +12,7 @@ namespace Sylius\Bundle\CoreBundle\Fixture\Factory; use Sylius\Component\Core\Model\AdminUserInterface; -use Sylius\Component\Rbac\Model\RoleInterface; use Sylius\Component\Resource\Factory\FactoryInterface; -use Sylius\Component\Resource\Repository\RepositoryInterface; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -28,11 +26,6 @@ final class AdminUserExampleFactory implements ExampleFactoryInterface */ private $userFactory; - /** - * @var RepositoryInterface - */ - private $roleRepository; - /** * @var \Faker\Generator */ @@ -45,12 +38,10 @@ final class AdminUserExampleFactory implements ExampleFactoryInterface /** * @param FactoryInterface $userFactory - * @param RepositoryInterface $roleRepository */ - public function __construct(FactoryInterface $userFactory, RepositoryInterface $roleRepository) + public function __construct(FactoryInterface $userFactory) { $this->userFactory = $userFactory; - $this->roleRepository = $roleRepository; $this->faker = \Faker\Factory::create(); $this->optionsResolver = @@ -83,8 +74,7 @@ final class AdminUserExampleFactory implements ExampleFactoryInterface $user->setUsername($options['username']); $user->setPlainPassword($options['password']); $user->setEnabled($options['enabled']); - - $this->addUserRole($user, 'ROLE_ADMINISTRATION_ACCESS', 'administrator'); + $user->addRole('ROLE_ADMINISTRATION_ACCESS'); if ($options['api']) { $this->addUserRole($user, 'ROLE_API_ACCESS', 'api_administrator'); @@ -92,21 +82,4 @@ final class AdminUserExampleFactory implements ExampleFactoryInterface return $user; } - - /** - * @param AdminUserInterface $user - * @param string $role - * @param string $authorizationRole - */ - private function addUserRole(AdminUserInterface $user, $role, $authorizationRole) - { - $user->addRole($role); - - /** @var RoleInterface $adminRole */ - $adminRole = $this->roleRepository->findOneBy(['code' => $authorizationRole]); - - if (null !== $adminRole) { - $user->addAuthorizationRole($adminRole); - } - } } diff --git a/src/Sylius/Bundle/CoreBundle/Fixture/RbacFixture.php b/src/Sylius/Bundle/CoreBundle/Fixture/RbacFixture.php deleted file mode 100644 index 5c4226ba00..0000000000 --- a/src/Sylius/Bundle/CoreBundle/Fixture/RbacFixture.php +++ /dev/null @@ -1,51 +0,0 @@ - - */ -final class RbacFixture extends AbstractFixture -{ - /** - * @var RbacInitializer - */ - private $initializer; - - /** - * @param RbacInitializer $initializer - */ - public function __construct(RbacInitializer $initializer) - { - $this->initializer = $initializer; - } - - /** - * {@inheritdoc} - */ - public function load(array $options) - { - $this->initializer->initialize(); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'rbac'; - } -} diff --git a/src/Sylius/Bundle/CoreBundle/Resources/config/app/sylius.yml b/src/Sylius/Bundle/CoreBundle/Resources/config/app/sylius.yml index 119bef6457..7cb96771f2 100644 --- a/src/Sylius/Bundle/CoreBundle/Resources/config/app/sylius.yml +++ b/src/Sylius/Bundle/CoreBundle/Resources/config/app/sylius.yml @@ -182,465 +182,6 @@ sylius_promotion: classes: factory: Sylius\Component\Core\Factory\ActionFactory -sylius_rbac: - resources: - role: - classes: - form: - choice: Sylius\Bundle\RbacBundle\Form\Type\RoleEntityType - permission: - classes: - form: - choice: Sylius\Bundle\RbacBundle\Form\Type\PermissionEntityType - permissions: - sylius.manage.admin_user: Manage administrators - sylius.admin_user.show: Show administrators - sylius.admin_user.index: List administrators - sylius.admin_user.create: Create administrators - sylius.admin_user.update: Update administrators - sylius.admin_user.delete: Delete administrators - - sylius.manage.customer: Manage customers - sylius.customer.show: Show customer - sylius.customer.index: List customers - sylius.customer.create: Create customer - sylius.customer.update: Edit customer - - sylius.manage.user: Manage users - sylius.user.show: Show user - sylius.user.index: List user - sylius.user.create: Create user - sylius.user.update: Edit user - sylius.user.delete: Delete user - - sylius.manage.group: Manage groups - sylius.group.show: Show group - sylius.group.index: List groups - sylius.group.create: Create group - sylius.group.update: Edit group - sylius.group.delete: Delete group - - sylius.manage.metadata_container: Manage metadata - sylius.metadata_container.show: Show metadata - sylius.metadata_container.index: List metadata - sylius.metadata_container.create: Create metadata - sylius.metadata_container.update: Edit metadata - sylius.metadata_container.delete: Delete metadata - - sylius.manage.channel: Manage channels - sylius.channel.show: Show channel - sylius.channel.index: List channels - sylius.channel.create: Create channel - sylius.channel.update: Edit channel - sylius.channel.delete: Delete channel - - sylius.manage.role: Manage roles - sylius.role.show: Show role - sylius.role.index: List roles - sylius.role.create: Create role - sylius.role.update: Edit role - sylius.role.delete: Delete role - - sylius.manage.permission: Manage permissions - sylius.permission.show: Show permission - sylius.permission.index: List permissions - sylius.permission.create: Create permission - sylius.permission.update: Edit permission - sylius.permission.delete: Delete permission - - sylius.manage.product: Manage products - sylius.product.show: Show product - sylius.product.index: List products - sylius.product.create: Create product - sylius.product.update: Edit product - sylius.product.delete: Delete product - - sylius.manage.product_attribute: Manage product attributes - sylius.product_attribute.show: Show product attribute - sylius.product_attribute.index: List product attributes - sylius.product_attribute.create: Create product attribute - sylius.product_attribute.update: Edit product attribute - sylius.product_attribute.delete: Delete product attribute - - sylius.manage.product_option: Manage product options - sylius.product_option.show: Show product option - sylius.product_option.index: List product options - sylius.product_option.create: Create product option - sylius.product_option.update: Edit product option - sylius.product_option.delete: Delete product option - - sylius.manage.product_variant: Manage product variants - sylius.product_variant.show: Show product variant - sylius.product_variant.index: List product variants - sylius.product_variant.create: Create product variant - sylius.product_variant.update: Edit product variant - sylius.product_variant.delete: Delete product variant - - sylius.manage.taxon: Manage taxons - sylius.taxon.show: Show taxon - sylius.taxon.index: List taxons - sylius.taxon.create: Create taxon - sylius.taxon.update: Edit taxon - sylius.taxon.delete: Delete taxon - - sylius.manage.adjustment: Manage adjustments - sylius.adjustment.show: Show adjustment - sylius.adjustment.index: List adjustments - sylius.adjustment.create: Create adjustment - sylius.adjustment.update: Edit adjustment - sylius.adjustment.delete: Delete adjustment - - sylius.manage.order: Manage orders - sylius.order.show: Show order - sylius.order.index: List orders - sylius.order.create: Create order - sylius.order.update: Edit order - sylius.order.delete: Delete order - sylius.inventory_unit.update: Update order unit state - - sylius.manage.order_item: Manage order items - sylius.order_item.show: Show order item - sylius.order_item.index: List order items - sylius.order_item.create: Create order item - sylius.order_item.update: Edit order item - sylius.order_item.delete: Delete order item - - sylius.manage.shipment: Manage shipments - sylius.shipment.show: Show shipment - sylius.shipment.index: List shipments - sylius.shipment.create: Create shipment - sylius.shipment.update: Edit shipment - sylius.shipment.delete: Delete shipment - - sylius.manage.promotion: Manage promotions - sylius.promotion.show: Show promotion - sylius.promotion.index: List promotions - sylius.promotion.create: Create promotion - sylius.promotion.update: Edit promotion - sylius.promotion.delete: Delete promotion - sylius.promotion_rule.delete: Delete promotion rule - sylius.promotion_action.delete: Delete promotion action - - sylius.manage.promotion_coupon: Manage promotion coupons - sylius.promotion_coupon.show: Show coupon - sylius.promotion_coupon.index: List coupons - sylius.promotion_coupon.create: Create new coupon - sylius.promotion_coupon.update: Edit coupon - sylius.promotion_coupon.delete: Delete coupon - - sylius.manage.locale: Manage locales - sylius.locale.show: Show locale - sylius.locale.index: List locales - sylius.locale.create: Create locale - sylius.locale.update: Edit locale - sylius.locale.delete: Delete locale - - sylius.manage.payment: Manage payments - sylius.payment.show: Show payment - sylius.payment.index: List payments - sylius.payment.create: Create payment - sylius.payment.update: Edit payment - sylius.payment.delete: Delete payment - - sylius.manage.payment_method: Manage payment methods - sylius.payment_method.show: Show payment method - sylius.payment_method.index: List payment methods - sylius.payment_method.create: Create payment method - sylius.payment_method.update: Edit payment method - sylius.payment_method.delete: Delete payment method - - sylius.manage.currency: Manage currencies - sylius.currency.show: Show currency - sylius.currency.index: List currencies - sylius.currency.create: Create currency - sylius.currency.update: Edit currency - sylius.currency.delete: Delete currency - - sylius.manage.tax_category: Manage tax categories - sylius.tax_category.show: Show tax category - sylius.tax_category.index: List tax categories - sylius.tax_category.create: Create tax category - sylius.tax_category.update: Edit tax category - sylius.tax_category.delete: Delete tax category - - sylius.manage.tax_rate: Manage tax rates - sylius.tax_rate.show: Show tax rate - sylius.tax_rate.index: List tax rates - sylius.tax_rate.create: Create tax rate - sylius.tax_rate.update: Edit tax rate - sylius.tax_rate.delete: Delete tax rate - - sylius.manage.shipping_method: Manage shipping methods - sylius.shipping_method.show: Show shipping method - sylius.shipping_method.index: List shipping methods - sylius.shipping_method.create: Create shipping method - sylius.shipping_method.update: Edit shipping method - sylius.shipping_method.delete: Delete shipping method - - sylius.manage.shipping_category: Manage shipping categories - sylius.shipping_category.show: Show shipping category - sylius.shipping_category.index: List shipping categories - sylius.shipping_category.create: Create shipping category - sylius.shipping_category.update: Edit shipping category - sylius.shipping_category.delete: Delete shipping category - - sylius.manage.country: Manage countries - sylius.country.show: Show country - sylius.country.index: List countries - sylius.country.create: Create country - sylius.country.update: Edit country - sylius.country.delete: Delete country - - sylius.manage.province: Manage provinces - sylius.province.show: Show province - sylius.province.index: List provinces - sylius.province.create: Create province - sylius.province.update: Edit province - sylius.province.delete: Delete province - - sylius.manage.zone: Manage zones - sylius.zone.show: Show zone - sylius.zone.index: List zones - sylius.zone.create: Create zone - sylius.zone.update: Edit zone - sylius.zone.delete: Delete zone - - sylius.manage.api_client: Manage API clients - sylius.api_client.show: Show API client - sylius.api_client.index: List API clients - sylius.api_client.create: Create API client - sylius.api_client.update: Edit API client - sylius.api_client.delete: Delete API client - - sylius.manage.static_content: Manage static contents - sylius.static_content.show: Show static content - sylius.static_content.index: List static contents - sylius.static_content.create: Create static content - sylius.static_content.update: Edit static content - sylius.static_content.delete: Delete static content - - sylius.manage.menu: Manage menus - sylius.menu.show: Show menu - sylius.menu.index: List menus - sylius.menu.create: Create menu - sylius.menu.update: Edit menu - sylius.menu.delete: Delete menu - - sylius.manage.route: Manage routes - sylius.route.show: Show route - sylius.route.index: List routes - sylius.route.create: Create route - sylius.route.update: Edit route - sylius.route.delete: Delete route - - sylius.manage.simple_block: Manage simple blocks - sylius.simple_block.show: Show simple block - sylius.simple_block.index: List simple blocks - sylius.simple_block.create: Create simple block - sylius.simple_block.update: Edit simple block - sylius.simple_block.delete: Delete simple block - - sylius.manage.string_block: Manage string blocks - sylius.string_block.show: Show string block - sylius.string_block.index: List string blocks - sylius.string_block.create: Create string block - sylius.string_block.update: Edit string block - sylius.string_block.delete: Delete string block - - sylius.manage.imagine_block: Manage imagine blocks - sylius.imagine_block.show: Show imagine block - sylius.imagine_block.index: List imagine blocks - sylius.imagine_block.create: Create imagine block - sylius.imagine_block.update: Edit imagine block - sylius.imagine_block.delete: Delete imagine block - - sylius.manage.slideshow_block: Manage slideshow blocks - sylius.slideshow_block.show: Show slideshow block - sylius.slideshow_block.index: List slideshow blocks - sylius.slideshow_block.create: Create slideshow block - sylius.slideshow_block.update: Edit slideshow block - sylius.slideshow_block.delete: Delete slideshow block - - sylius.manage.slideshow: Manage slideshows - sylius.slideshow.show: Show slideshow - sylius.slideshow.index: List slideshows - sylius.slideshow.create: Create slideshow - sylius.slideshow.update: Edit slideshow - sylius.slideshow.delete: Delete slideshow - - sylius.manage.email: Manage emails - sylius.email.show: Show email - sylius.email.index: List emails - sylius.email.create: Create email - sylius.email.update: Edit email - sylius.email.delete: Delete email - - sylius.manage.report: Manage reports - sylius.report.show: Show report - sylius.report.index: List reports - sylius.report.create: Create report - sylius.report.update: Edit report - sylius.report.delete: Delete report - - sylius.manage.product_association_type: Manage association types - sylius.product_association_type.show: Show association type - sylius.product_association_type.index: List association types - sylius.product_association_type.create: Create association type - sylius.product_association_type.update: Edit association type - sylius.product_association_type.delete: Delete association type - - sylius.manage.settings: Manage settings - sylius.settings.sylius_general: Manage general settings - sylius.settings.sylius_security: Manage security settings - sylius.settings.sylius_taxation: Manage taxation settings - - sylius.manage.product_review: Manage product reviews - sylius.product_review.show: Show product review - sylius.product_review.index: List product reviews - sylius.product_review.create: Create product review - sylius.product_review.update: Edit product review - sylius.product_review.delete: Delete product review - - sylius.catalog: Manage products catalog - sylius.sales: Manage sales - sylius.shipping: Manage shipping - sylius.marketing: Manage marketing campaigns - sylius.content: Manage contents - sylius.security: Manage site security - sylius.accounts: Manage user accounts - sylius.taxes: Manage taxes - sylius.support: Manage customer support - - permissions_hierarchy: - sylius.manage.admin_user: [sylius.admin_user.show, sylius.admin_user.index, sylius.admin_user.create, sylius.admin_user.update, sylius.admin_user.delete] - sylius.manage.metadata_container: [sylius.metadata_container.show, sylius.metadata_container.index, sylius.metadata_container.create, sylius.metadata_container.update, sylius.metadata_container.delete] - sylius.manage.channel: [sylius.channel.show, sylius.channel.index, sylius.channel.create, sylius.channel.update, sylius.channel.delete] - sylius.manage.customer: [sylius.customer.show, sylius.customer.index, sylius.customer.create, sylius.customer.update] - sylius.manage.user: [sylius.user.show, sylius.user.index, sylius.user.create, sylius.user.update, sylius.user.delete] - sylius.manage.group: [sylius.group.show, sylius.group.index, sylius.group.create, sylius.group.update, sylius.group.delete] - sylius.manage.role: [sylius.role.show, sylius.role.index, sylius.role.create, sylius.role.update, sylius.role.delete] - sylius.manage.permission: [sylius.permission.show, sylius.permission.index, sylius.permission.create, sylius.permission.update, sylius.permission.delete] - sylius.manage.product: [sylius.product.show, sylius.product.index, sylius.product.create, sylius.product.update, sylius.product.delete] - sylius.manage.product_attribute: [sylius.product_attribute.show, sylius.product_attribute.index, sylius.product_attribute.create, sylius.product_attribute.update, sylius.product_attribute.delete] - sylius.manage.product_option: [sylius.product_option.show, sylius.product_option.index, sylius.product_option.create, sylius.product_option.update, sylius.product_option.delete] - sylius.manage.product_variant: [sylius.product_variant.show, sylius.product_variant.index, sylius.product_variant.create, sylius.product_variant.update, sylius.product_variant.delete] - sylius.manage.taxon: [sylius.taxon.show, sylius.taxon.index, sylius.taxon.create, sylius.taxon.update, sylius.taxon.delete] - sylius.manage.adjustment: [sylius.adjustment.show, sylius.adjustment.index, sylius.adjustment.create, sylius.adjustment.update, sylius.adjustment.delete] - sylius.manage.order: [sylius.order.show, sylius.order.index, sylius.order.create, sylius.order.update, sylius.order.delete] - sylius.manage.order_item: [sylius.order_item.show, sylius.order_item.index, sylius.order_item.create, sylius.order_item.update, sylius.order_item.delete] - sylius.manage.adjustment: [sylius.adjustment.show, sylius.adjustment.index, sylius.adjustment.create, sylius.adjustment.update, sylius.adjustment.delete] - sylius.manage.shipment: [sylius.shipment.show, sylius.shipment.index, sylius.shipment.create, sylius.shipment.update, sylius.shipment.delete] - sylius.manage.promotion: [sylius.promotion.show, sylius.promotion.index, sylius.promotion.create, sylius.promotion.update, sylius.promotion.delete, sylius.promotion_rule.delete, sylius.promotion_action.delete] - sylius.manage.promotion_coupon: [sylius.promotion_coupon.show, sylius.promotion_coupon.index, sylius.promotion_coupon.create, sylius.promotion_coupon.update, sylius.promotion_coupon.delete] - sylius.manage.locale: [sylius.locale.show, sylius.locale.index, sylius.locale.create, sylius.locale.update, sylius.locale.delete] - sylius.manage.payment: [sylius.payment.show, sylius.payment.index, sylius.payment.create, sylius.payment.update, sylius.payment.delete] - sylius.manage.payment_method: [sylius.payment_method.show, sylius.payment_method.index, sylius.payment_method.create, sylius.payment_method.update, sylius.payment_method.delete] - sylius.manage.currency: [sylius.currency.show, sylius.currency.index, sylius.currency.create, sylius.currency.update, sylius.currency.delete] - sylius.manage.tax_category: [sylius.tax_category.show, sylius.tax_category.index, sylius.tax_category.create, sylius.tax_category.update, sylius.tax_category.delete] - sylius.manage.tax_rate: [sylius.tax_rate.show, sylius.tax_rate.index, sylius.tax_rate.create, sylius.tax_rate.update, sylius.tax_rate.delete] - sylius.manage.shipping_method: [sylius.shipping_method.show, sylius.shipping_method.index, sylius.shipping_method.create, sylius.shipping_method.update, sylius.shipping_method.delete] - sylius.manage.shipping_category: [sylius.shipping_category.show, sylius.shipping_category.index, sylius.shipping_category.create, sylius.shipping_category.update, sylius.shipping_category.delete] - sylius.manage.country: [sylius.country.show, sylius.country.index, sylius.country.create, sylius.country.update, sylius.country.delete] - sylius.manage.province: [sylius.province.show, sylius.province.index, sylius.province.create, sylius.province.update, sylius.province.delete] - sylius.manage.zone: [sylius.zone.show, sylius.zone.index, sylius.zone.create, sylius.zone.update, sylius.zone.delete] - sylius.manage.api_client: [sylius.api_client.show, sylius.api_client.index, sylius.api_client.create, sylius.api_client.update, sylius.api_client.delete] - sylius.manage.static_content: [sylius.static_content.show, sylius.static_content.index, sylius.static_content.create, sylius.static_content.update, sylius.static_content.delete] - sylius.manage.menu: [sylius.menu.show, sylius.menu.index, sylius.menu.create, sylius.menu.update, sylius.menu.delete] - sylius.manage.route: [sylius.route.show, sylius.route.index, sylius.route.create, sylius.route.update, sylius.route.delete] - sylius.manage.simple_block: [sylius.simple_block.show, sylius.simple_block.index, sylius.simple_block.create, sylius.simple_block.update, sylius.simple_block.delete] - sylius.manage.string_block: [sylius.string_block.show, sylius.string_block.index, sylius.string_block.create, sylius.string_block.update, sylius.string_block.delete] - sylius.manage.imagine_block: [sylius.imagine_block.show, sylius.imagine_block.index, sylius.imagine_block.create, sylius.imagine_block.update, sylius.imagine_block.delete] - sylius.manage.slideshow_block: [sylius.slideshow_block.show, sylius.slideshow_block.index, sylius.slideshow_block.create, sylius.slideshow_block.update, sylius.slideshow_block.delete] - sylius.manage.slideshow: [sylius.slideshow.show, sylius.slideshow.index, sylius.slideshow.create, sylius.slideshow.update, sylius.slideshow.delete] - sylius.manage.email: [sylius.email.show, sylius.email.index, sylius.email.create, sylius.email.update, sylius.email.delete] - sylius.manage.report: [sylius.report.show, sylius.report.index, sylius.report.create, sylius.report.update, sylius.report.delete] - sylius.manage.product_review: [sylius.product_review.show, sylius.product_review.index, sylius.product_review.create, sylius.product_review.update, sylius.product_review.delete] - sylius.manage.settings: [sylius.settings.sylius_general, sylius.settings.sylius_security, sylius.settings.sylius_taxation] - sylius.manage.product_association_type: [sylius.product_association_type.show, sylius.product_association_type.index, sylius.product_association_type.create, sylius.product_association_type.update, sylius.product_association_type.delete] - sylius.catalog: [sylius.manage.product, sylius.manage.product_attribute, sylius.manage.product_option, sylius.manage.product_variant, sylius.manage.taxon, sylius.manage.metadata_container, sylius.manage.product_association_type] - sylius.marketing: [sylius.manage.promotion, sylius.manage.promotion_coupon, sylius.manage.email, sylius.manage.metadata_container] - sylius.sales: [sylius.manage.adjustment, sylius.manage.order, sylius.manage.order_item, sylius.manage.adjustment, sylius.manage.payment, sylius.manage.report, sylius.manage.product_review] - sylius.shipping: [sylius.manage.shipment, sylius.manage.shipping_method, sylius.manage.shipping_category] - sylius.content: [sylius.manage.static_content, sylius.manage.route, sylius.manage.simple_block, sylius.manage.menu, sylius.manage.slideshow, sylius.manage.string_block, sylius.manage.slideshow_block, sylius.manage.imagine_block, sylius.manage.metadata_container] - sylius.security: [sylius.manage.permission, sylius.manage.role, sylius.manage.user, sylius.manage.customer, sylius.manage.group, sylius.accounts] - sylius.accounts: [sylius.manage.customer, sylius.manage.group, sylius.manage.user] - sylius.taxes: [sylius.manage.tax_rate, sylius.manage.tax_category] - - security_roles: - ROLE_ADMINISTRATION_ACCESS: Can access administration - ROLE_API_ACCESS: Can access REST API - ROLE_ALLOWED_TO_SWITCH: Can impersonate users - - roles: - administrator: - name: Administrator - description: Administrator user - permissions: [sylius.manage.settings, sylius.manage.locale, sylius.manage.currency, sylius.manage.country, sylius.manage.province, sylius.manage.zone, sylius.manage.payment_method, sylius.manage.channel, sylius.manage.admin_user] - security_roles: [ROLE_ADMINISTRATION_ACCESS, ROLE_ALLOWED_TO_SWITCH] - api_administrator: - name: API Administrator - description: API Administrator user - permissions: [sylius.manage.settings, sylius.manage.locale, sylius.manage.currency, sylius.manage.country, sylius.manage.province, sylius.manage.zone, sylius.manage.payment_method, sylius.manage.channel] - security_roles: [ROLE_ADMINISTRATION_ACCESS, ROLE_API_ACCESS] - catalog_manager: - name: Catalog Manager - description: Users responsible for catalog product management - permissions: [sylius.catalog] - security_roles: [ROLE_ADMINISTRATION_ACCESS] - sales_manager: - name: Sales Manager - description: Sales - permissions: [sylius.sales] - security_roles: [ROLE_ADMINISTRATION_ACCESS] - marketing_manager: - name: Marketing Manager - description: Marketing - permissions: [sylius.marketing] - security_roles: [ROLE_ADMINISTRATION_ACCESS] - accounts_manager: - name: Accounts Manager - description: Users responsible for managing customer accounts - permissions: [sylius.accounts] - security_roles: [ROLE_ADMINISTRATION_ACCESS, ROLE_ALLOWED_TO_SWITCH] - shipping_manager: - name: Shipping Manager - description: Shipping Department people - permissions: [sylius.shipping] - security_roles: [ROLE_ADMINISTRATION_ACCESS] - content_editor: - name: Content Editor - description: Content Team people - permissions: [sylius.content] - security_roles: [ROLE_ADMINISTRATION_ACCESS, ROLE_CAN_VIEW_NON_PUBLISHED] - tax_manager: - name: Tax Manager - description: Taxes Team - permissions: [sylius.taxes] - security_roles: [ROLE_ADMINISTRATION_ACCESS] - it: - name: IT - description: IT Team - security_roles: [ROLE_ADMINISTRATION_ACCESS] - security_auditor: - name: Security Auditor - description: Security Team - permissions: [sylius.security] - security_roles: [ROLE_ADMINISTRATION_ACCESS] - developer: - name: Developer - description: Developers Access - permissions: [sylius.customer.index, sylius.customer.show, sylius.manage.api_client] - security_roles: [ROLE_ADMINISTRATION_ACCESS] - support: - name: Support - description: Support Team - permissions: [sylius.support, sylius.customer.show, sylius.customer.index] - security_roles: [ROLE_ADMINISTRATION_ACCESS, ROLE_ALLOWED_TO_SWITCH] - - roles_hierarchy: - administrator: [catalog_manager, sales_manager, marketing_manager, accounts_manager, shipping_manager, content_editor, tax_manager, it, support] - it: [security_auditor, developer] - sylius_resource: translation: true diff --git a/src/Sylius/Bundle/CoreBundle/Resources/config/doctrine/model/AdminUser.orm.xml b/src/Sylius/Bundle/CoreBundle/Resources/config/doctrine/model/AdminUser.orm.xml index d52093bbf0..e9d476cdd4 100644 --- a/src/Sylius/Bundle/CoreBundle/Resources/config/doctrine/model/AdminUser.orm.xml +++ b/src/Sylius/Bundle/CoreBundle/Resources/config/doctrine/model/AdminUser.orm.xml @@ -17,17 +17,6 @@ http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - - - - - - - - - - - diff --git a/src/Sylius/Bundle/CoreBundle/Resources/config/doctrine/model/ShopUser.orm.xml b/src/Sylius/Bundle/CoreBundle/Resources/config/doctrine/model/ShopUser.orm.xml index bbe37ccfc7..56c243252a 100644 --- a/src/Sylius/Bundle/CoreBundle/Resources/config/doctrine/model/ShopUser.orm.xml +++ b/src/Sylius/Bundle/CoreBundle/Resources/config/doctrine/model/ShopUser.orm.xml @@ -25,17 +25,6 @@ - - - - - - - - - - - diff --git a/src/Sylius/Bundle/CoreBundle/Resources/config/fixtures.xml b/src/Sylius/Bundle/CoreBundle/Resources/config/fixtures.xml index 3bf4813f42..9401c8b00f 100644 --- a/src/Sylius/Bundle/CoreBundle/Resources/config/fixtures.xml +++ b/src/Sylius/Bundle/CoreBundle/Resources/config/fixtures.xml @@ -159,10 +159,5 @@ - - - - - diff --git a/src/Sylius/Bundle/CoreBundle/Resources/config/fixtures_factories.xml b/src/Sylius/Bundle/CoreBundle/Resources/config/fixtures_factories.xml index 22463becb0..6f9d9bf74b 100644 --- a/src/Sylius/Bundle/CoreBundle/Resources/config/fixtures_factories.xml +++ b/src/Sylius/Bundle/CoreBundle/Resources/config/fixtures_factories.xml @@ -44,7 +44,6 @@ - diff --git a/src/Sylius/Bundle/CoreBundle/Resources/config/services.xml b/src/Sylius/Bundle/CoreBundle/Resources/config/services.xml index 179a89367e..5e1b31398f 100644 --- a/src/Sylius/Bundle/CoreBundle/Resources/config/services.xml +++ b/src/Sylius/Bundle/CoreBundle/Resources/config/services.xml @@ -235,10 +235,6 @@ - - - - @@ -479,11 +475,6 @@ - - - - - diff --git a/src/Sylius/Bundle/CoreBundle/composer.json b/src/Sylius/Bundle/CoreBundle/composer.json index 75450dde56..d45af80da6 100644 --- a/src/Sylius/Bundle/CoreBundle/composer.json +++ b/src/Sylius/Bundle/CoreBundle/composer.json @@ -46,7 +46,6 @@ "sylius/pricing-bundle": "^1.0", "sylius/product-bundle": "^1.0", "sylius/promotion-bundle": "^1.0", - "sylius/rbac-bundle": "^1.0", "sylius/report-bundle": "^1.0", "sylius/resource-bundle": "^1.0", "sylius/settings-bundle": "^1.0", diff --git a/src/Sylius/Bundle/CoreBundle/spec/EventListener/AddAdministratorRoleListenerSpec.php b/src/Sylius/Bundle/CoreBundle/spec/EventListener/AddAdministratorRoleListenerSpec.php deleted file mode 100644 index eb5c165c7d..0000000000 --- a/src/Sylius/Bundle/CoreBundle/spec/EventListener/AddAdministratorRoleListenerSpec.php +++ /dev/null @@ -1,74 +0,0 @@ - - */ -final class AddAdministratorRoleListenerSpec extends ObjectBehavior -{ - function let(RoleRepository $roleRepository) - { - $this->beConstructedWith($roleRepository); - } - - function it_is_initializable() - { - $this->shouldHaveType(AddAdministratorRoleListener::class); - } - - function it_adds_administration_role( - RoleRepository $roleRepository, - RoleInterface $role, - AdminUserInterface $user, - GenericEvent $event - ) { - $event->getSubject()->willReturn($user); - $roleRepository->findOneBy(['code' => 'administrator'])->willReturn($role); - $user->addAuthorizationRole($role)->shouldBeCalled(); - - $this->addAdministrationRole($event); - } - - function it_throws_runtime_exception_if_subject_is_not_admin_user( - RoleRepository $roleRepository, - RoleInterface $role, - CustomerInterface $customer, - GenericEvent $event - ) { - $event->getSubject()->willReturn($customer); - $roleRepository->findOneBy(['code' => 'administrator'])->willReturn($role); - - $this->shouldThrow(\RuntimeException::class)->during('addAdministrationRole', [$event]); - } - - function it_does_not_add_administration_role_if_it_does_not_exist( - RoleRepository $roleRepository, - AdminUserInterface $user, - GenericEvent $event - ) { - $event->getSubject()->willReturn($user); - $roleRepository->findOneBy(['code' => 'administrator'])->willReturn(null); - $user->addAuthorizationRole(Argument::any())->shouldNotBeCalled(); - } -} diff --git a/src/Sylius/Bundle/RbacBundle/.gitignore b/src/Sylius/Bundle/RbacBundle/.gitignore deleted file mode 100644 index 46aed33710..0000000000 --- a/src/Sylius/Bundle/RbacBundle/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -vendor/ -bin/ - -composer.phar -composer.lock diff --git a/src/Sylius/Bundle/RbacBundle/Authorization/RbacAuthorizationChecker.php b/src/Sylius/Bundle/RbacBundle/Authorization/RbacAuthorizationChecker.php deleted file mode 100644 index 63cd025744..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Authorization/RbacAuthorizationChecker.php +++ /dev/null @@ -1,50 +0,0 @@ - - */ -class RbacAuthorizationChecker implements ResourceBundleAuthorizationCheckerInterface -{ - /** - * @var AuthorizationCheckerInterface - */ - private $rbacAuthorizationChecker; - - /** - * @param AuthorizationCheckerInterface $rbacAuthorizationChecker - */ - public function __construct(AuthorizationCheckerInterface $rbacAuthorizationChecker) - { - $this->rbacAuthorizationChecker = $rbacAuthorizationChecker; - } - - /** - * @param RequestConfiguration $requestConfiguration - * @param string $permission - * - * @return bool - */ - public function isGranted(RequestConfiguration $requestConfiguration, $permission) - { - if (!$requestConfiguration->hasPermission()) { - return true; - } - - return $this->rbacAuthorizationChecker->isGranted($permission); - } -} diff --git a/src/Sylius/Bundle/RbacBundle/CHANGELOG.md b/src/Sylius/Bundle/RbacBundle/CHANGELOG.md deleted file mode 100644 index e9c097488d..0000000000 --- a/src/Sylius/Bundle/RbacBundle/CHANGELOG.md +++ /dev/null @@ -1,6 +0,0 @@ -CHANGELOG -========= - -### v0.15.0 - -* Initial dev release. diff --git a/src/Sylius/Bundle/RbacBundle/Command/InitializeCommand.php b/src/Sylius/Bundle/RbacBundle/Command/InitializeCommand.php deleted file mode 100644 index 321464d19e..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Command/InitializeCommand.php +++ /dev/null @@ -1,50 +0,0 @@ - - */ -class InitializeCommand extends ContainerAwareCommand -{ - /** - * {@inheritdoc} - */ - protected function configure() - { - $this - ->setName('sylius:rbac:initialize') - ->setDescription('Initialize default permissions & roles in the application.') - ->setHelp(<<%command.name% command initializes default RBAC setup. -EOT - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $output->writeln('Initializing Sylius RBAC roles and permissions.'); - - $initializer = $this->getContainer()->get('sylius.rbac.initializer'); - $initializer->initialize($output); - - $output->writeln('Completed!'); - } -} diff --git a/src/Sylius/Bundle/RbacBundle/DependencyInjection/Configuration.php b/src/Sylius/Bundle/RbacBundle/DependencyInjection/Configuration.php deleted file mode 100644 index 6b9900e8fc..0000000000 --- a/src/Sylius/Bundle/RbacBundle/DependencyInjection/Configuration.php +++ /dev/null @@ -1,212 +0,0 @@ - - */ -class Configuration implements ConfigurationInterface -{ - /** - * {@inheritdoc} - */ - public function getConfigTreeBuilder() - { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('sylius_rbac'); - - $rootNode - ->children() - ->scalarNode('driver')->defaultValue(SyliusResourceBundle::DRIVER_DOCTRINE_ORM)->end() - ->scalarNode('authorization_checker')->defaultValue('sylius.authorization_checker.default')->end() - ->scalarNode('identity_provider')->defaultValue('sylius.authorization_identity_provider.security')->end() - ->scalarNode('permission_map')->defaultValue('sylius.permission_map.cached')->end() - ->arrayNode('security_roles') - ->useAttributeAsKey('id') - ->prototype('scalar') - ->defaultValue([]) - ->end() - ->end() - ; - - $this->addResourcesSection($rootNode); - $this->addRolesSection($rootNode); - $this->addPermissionsSection($rootNode); - - return $treeBuilder; - } - - /** - * @param ArrayNodeDefinition $node - */ - private function addResourcesSection(ArrayNodeDefinition $node) - { - $node - ->children() - ->arrayNode('resources') - ->addDefaultsIfNotSet() - ->children() - ->arrayNode('role') - ->addDefaultsIfNotSet() - ->children() - ->variableNode('options')->end() - ->arrayNode('classes') - ->addDefaultsIfNotSet() - ->children() - ->scalarNode('model')->defaultValue(Role::class)->cannotBeEmpty()->end() - ->scalarNode('interface')->defaultValue(RoleInterface::class)->cannotBeEmpty()->end() - ->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end() - ->scalarNode('repository')->cannotBeEmpty()->end() - ->scalarNode('factory')->defaultValue(Factory::class)->end() - ->arrayNode('form') - ->addDefaultsIfNotSet() - ->children() - ->scalarNode('default')->defaultValue(RoleType::class)->cannotBeEmpty()->end() - ->scalarNode('choice')->defaultValue(ResourceChoiceType::class)->cannotBeEmpty()->end() - ->end() - ->end() - ->end() - ->end() - ->arrayNode('validation_groups') - ->addDefaultsIfNotSet() - ->children() - ->arrayNode('default') - ->prototype('scalar')->end() - ->defaultValue(['sylius']) - ->end() - ->end() - ->end() - ->end() - ->end() - ->arrayNode('permission') - ->addDefaultsIfNotSet() - ->children() - ->variableNode('options')->end() - ->arrayNode('classes') - ->addDefaultsIfNotSet() - ->children() - ->scalarNode('model')->defaultValue(Permission::class)->cannotBeEmpty()->end() - ->scalarNode('interface')->defaultValue(PermissionInterface::class)->cannotBeEmpty()->end() - ->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end() - ->scalarNode('repository')->cannotBeEmpty()->end() - ->scalarNode('factory')->defaultValue(Factory::class)->end() - ->arrayNode('form') - ->addDefaultsIfNotSet() - ->children() - ->scalarNode('default')->defaultValue(PermissionType::class)->cannotBeEmpty()->end() - ->scalarNode('choice')->defaultValue(ResourceChoiceType::class)->cannotBeEmpty()->end() - ->end() - ->end() - ->end() - ->end() - ->arrayNode('validation_groups') - ->addDefaultsIfNotSet() - ->children() - ->arrayNode('default') - ->prototype('scalar')->end() - ->defaultValue(['sylius']) - ->end() - ->end() - ->end() - ->end() - ->end() - ->end() - ->end() - ->end() - ; - } - - /** - * @param ArrayNodeDefinition $node - */ - private function addRolesSection(ArrayNodeDefinition $node) - { - $node - ->children() - ->arrayNode('roles') - ->useAttributeAsKey('id') - ->prototype('array') - ->children() - ->scalarNode('name')->isRequired()->cannotBeEmpty()->end() - ->scalarNode('description')->end() - ->arrayNode('permissions') - ->prototype('scalar')->end() - ->end() - ->arrayNode('security_roles') - ->prototype('scalar')->end() - ->defaultValue([]) - ->end() - ->end() - ->end() - ->end() - ->arrayNode('roles_hierarchy') - ->useAttributeAsKey('id') - ->prototype('array') - ->beforeNormalization()->ifString()->then(function ($v) { return ['value' => $v]; })->end() - ->beforeNormalization() - ->ifTrue(function ($v) { return is_array($v) && isset($v['value']); }) - ->then(function ($v) { return preg_split('/\s*,\s*/', $v['value']); }) - ->end() - ->prototype('scalar')->end() - ->end() - ->end() - ->end() - ; - } - - /** - * @param ArrayNodeDefinition $node - */ - private function addPermissionsSection(ArrayNodeDefinition $node) - { - $node - ->children() - ->arrayNode('permissions') - ->useAttributeAsKey('id') - ->prototype('scalar')->end() - ->defaultValue([]) - ->end() - ->arrayNode('permissions_hierarchy') - ->useAttributeAsKey('id') - ->prototype('array') - ->performNoDeepMerging() - ->beforeNormalization()->ifString()->then(function ($v) { return ['value' => $v]; })->end() - ->beforeNormalization() - ->ifTrue(function ($v) { return is_array($v) && isset($v['value']); }) - ->then(function ($v) { return preg_split('/\s*,\s*/', $v['value']); }) - ->end() - ->prototype('scalar')->end() - ->end() - ->end() - ->end() - ; - } -} diff --git a/src/Sylius/Bundle/RbacBundle/DependencyInjection/SyliusRbacExtension.php b/src/Sylius/Bundle/RbacBundle/DependencyInjection/SyliusRbacExtension.php deleted file mode 100644 index d111ffeec5..0000000000 --- a/src/Sylius/Bundle/RbacBundle/DependencyInjection/SyliusRbacExtension.php +++ /dev/null @@ -1,100 +0,0 @@ - - */ -class SyliusRbacExtension extends AbstractResourceExtension implements PrependExtensionInterface -{ - /** - * {@inheritdoc} - */ - public function load(array $config, ContainerBuilder $container) - { - $config = $this->processConfiguration($this->getConfiguration($config, $container), $config); - $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - - $loader->load(sprintf('driver/%s.xml', $config['driver'])); - - $this->registerResources('sylius', $config['driver'], $config['resources'], $container); - - $configFiles = [ - 'services.xml', - 'templating.xml', - 'twig.xml', - ]; - - foreach ($configFiles as $configFile) { - $loader->load($configFile); - } - - $container->setAlias('sylius.authorization_identity_provider', $config['identity_provider']); - $container->setAlias('sylius.permission_map', $config['permission_map']); - $container->setAlias('sylius.authorization_checker', $config['authorization_checker']); - - $container->setParameter('sylius.rbac.security_roles', $config['security_roles']); - - $container->setParameter('sylius.rbac.default_roles', $config['roles']); - $container->setParameter('sylius.rbac.default_roles_hierarchy', $config['roles_hierarchy']); - - $container->setParameter('sylius.rbac.default_permissions', $config['permissions']); - $container->setParameter('sylius.rbac.default_permissions_hierarchy', $config['permissions_hierarchy']); - } - - /** - * {@inheritdoc} - */ - public function prepend(ContainerBuilder $container) - { - $this->prependDoctrineCache($container); - $this->prependSyliusResource($container); - } - - /** - * @param ContainerBuilder $container - */ - private function prependDoctrineCache(ContainerBuilder $container) - { - if (!$container->hasExtension('doctrine_cache')) { - throw new \RuntimeException('DoctrineCacheBundle must be registered!'); - } - - $container->prependExtensionConfig('doctrine_cache', [ - 'providers' => [ - 'sylius_rbac' => '%sylius.cache%', - ], - ]); - } - /** - * @param ContainerBuilder $container - */ - private function prependSyliusResource(ContainerBuilder $container) - { - if (!$container->hasExtension('sylius_resource')) { - return; - } - - $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - $loader->load('resource_integration.xml'); - - $container->prependExtensionConfig('sylius_resource', [ - 'authorization_checker' => 'sylius.resource_controller.authorization_checker.rbac', - ]); - } -} diff --git a/src/Sylius/Bundle/RbacBundle/Doctrine/ORM/PermissionRepository.php b/src/Sylius/Bundle/RbacBundle/Doctrine/ORM/PermissionRepository.php deleted file mode 100644 index 05863a99b1..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Doctrine/ORM/PermissionRepository.php +++ /dev/null @@ -1,37 +0,0 @@ - - */ -class PermissionRepository extends EntityRepository implements PermissionRepositoryInterface -{ - /** - * {@inheritdoc} - */ - public function getChildPermissions(PermissionInterface $permission) - { - $queryBuilder = $this->createQueryBuilder('o'); - - return $queryBuilder - ->where($queryBuilder->expr()->lt('o.left', $permission->getRight())) - ->andWhere($queryBuilder->expr()->gt('o.left', $permission->getLeft())) - ->getQuery() - ->execute() - ; - } -} diff --git a/src/Sylius/Bundle/RbacBundle/Doctrine/ORM/RoleRepository.php b/src/Sylius/Bundle/RbacBundle/Doctrine/ORM/RoleRepository.php deleted file mode 100644 index 8fc44a92ec..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Doctrine/ORM/RoleRepository.php +++ /dev/null @@ -1,37 +0,0 @@ - - */ -class RoleRepository extends EntityRepository implements RoleRepositoryInterface -{ - /** - * {@inheritdoc} - */ - public function getChildRoles(RoleInterface $role) - { - $queryBuilder = $this->createQueryBuilder('o'); - - return $queryBuilder - ->where($queryBuilder->expr()->lt('o.left', $role->getRight())) - ->andWhere($queryBuilder->expr()->gt('o.left', $role->getLeft())) - ->getQuery() - ->execute() - ; - } -} diff --git a/src/Sylius/Bundle/RbacBundle/Doctrine/RbacInitializer.php b/src/Sylius/Bundle/RbacBundle/Doctrine/RbacInitializer.php deleted file mode 100644 index b92fcda05b..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Doctrine/RbacInitializer.php +++ /dev/null @@ -1,175 +0,0 @@ - - * @author Joseph Bielawski - */ -class RbacInitializer -{ - private $permissions; - private $permissionsHierarchy; - private $permissionManager; - private $permissionFactory; - private $permissionRepository; - - private $permissionsByCode = [ - 'root' => null, - ]; - - private $roles; - private $rolesHierarchy; - private $roleManager; - private $roleFactory; - private $roleRepository; - - public function __construct( - array $permissions, - array $permissionsHierarchy, - $permissionManager, - FactoryInterface $permissionFactory, - RepositoryInterface $permissionRepository, - array $roles, - array $rolesHierarchy, - $roleManager, - FactoryInterface $roleFactory, - RepositoryInterface $roleRepository - ) { - $this->permissions = $permissions; - $this->permissionsHierarchy = $permissionsHierarchy; - $this->permissionFactory = $permissionFactory; - $this->permissionManager = $permissionManager; - $this->permissionRepository = $permissionRepository; - - $this->roles = $roles; - $this->rolesHierarchy = $rolesHierarchy; - $this->roleFactory = $roleFactory; - $this->roleManager = $roleManager; - $this->roleRepository = $roleRepository; - } - - public function initialize(OutputInterface $output = null) - { - try { - $this->initializePermissions($output); - $this->initializeRoles($output); - } catch (NonUniqueResultException $exception) { - if ($output) { - $output->writeln('RBAC already initialized'); - } - } - } - - protected function initializePermissions(OutputInterface $output = null) - { - if (null === $root = $this->permissionRepository->findOneBy(['code' => 'root'])) { - $root = $this->permissionFactory->createNew(); - $root->setCode('root'); - $root->setDescription('Root'); - - $this->permissionManager->persist($root); - $this->permissionManager->flush(); - } - - $this->permissionsByCode['root'] = $root; - - foreach ($this->permissions as $code => $description) { - if (null === $permission = $this->permissionRepository->findOneBy(['code' => $code])) { - $permission = $this->permissionFactory->createNew(); - $permission->setCode($code); - $permission->setDescription($description); - $permission->setParent($root); - - $this->permissionManager->persist($permission); - - if ($output) { - $output->writeln(sprintf('Adding permission "%s". (%s)', $description, $code)); - } - } - - $this->permissionsByCode[$code] = $permission; - } - - foreach ($this->permissionsHierarchy as $code => $children) { - foreach ($children as $childCode) { - $this->permissionsByCode[$code]->addChild($this->permissionsByCode[$childCode]); - } - } - - $this->permissionManager->flush(); - } - - protected function initializeRoles(OutputInterface $output = null) - { - if (!isset($this->permissionsByCode['root'])) { - return; - } - - if (null === $root = $this->roleRepository->findOneBy(['code' => 'root'])) { - $root = $this->roleFactory->createNew(); - $root->setCode('root'); - $root->setName('Root'); - - $root->addPermission($this->permissionsByCode['root']); - - $this->roleManager->persist($root); - $this->roleManager->flush(); - } - - $rolesByCode = ['root' => $root]; - - foreach ($this->roles as $code => $data) { - if (null === $role = $this->roleRepository->findOneBy(['code' => $code])) { - $role = $this->roleFactory->createNew(); - $role->setCode($code); - $role->setName($data['name']); - $role->setDescription($data['description']); - $role->setParent($root); - if ($output) { - $output->writeln(sprintf('Adding role "%s". (%s)', $data['name'], $code)); - } - } - - foreach ($data['permissions'] as $permission) { - if (!$role->hasPermission($this->permissionsByCode[$permission])) { - $role->addPermission($this->permissionsByCode[$permission]); - if ($output) { - $output->writeln(sprintf('Adding role:permission %s:%s', - $role->getCode(), - $permission - )); - } - } - } - - $role->setSecurityRoles($data['security_roles']); - - $this->roleManager->persist($role); - - $rolesByCode[$code] = $role; - } - - foreach ($this->rolesHierarchy as $code => $children) { - foreach ($children as $childCode) { - $rolesByCode[$code]->addChild($rolesByCode[$childCode]); - } - } - - $this->roleManager->flush(); - } -} diff --git a/src/Sylius/Bundle/RbacBundle/EventListener/CacheListener.php b/src/Sylius/Bundle/RbacBundle/EventListener/CacheListener.php deleted file mode 100644 index 2b29264bb3..0000000000 --- a/src/Sylius/Bundle/RbacBundle/EventListener/CacheListener.php +++ /dev/null @@ -1,70 +0,0 @@ - - */ -class CacheListener -{ - /** - * @var ClearableCache - */ - private $cache; - - /** - * @param ClearableCache $cache - */ - public function __construct(ClearableCache $cache) - { - $this->cache = $cache; - } - - /** - * @param LifecycleEventArgs $args - */ - public function postPersist(LifecycleEventArgs $args) - { - $this->clearCache($args); - } - - /** - * @param LifecycleEventArgs $args - */ - public function postRemove(LifecycleEventArgs $args) - { - $this->clearCache($args); - } - - /** - * @param LifecycleEventArgs $args - */ - public function postUpdate(LifecycleEventArgs $args) - { - $this->clearCache($args); - } - - /** - * @param LifecycleEventArgs $args - */ - protected function clearCache(LifecycleEventArgs $args) - { - if ($args->getEntity() instanceof RoleInterface || $args->getEntity() instanceof PermissionInterface) { - $this->cache->deleteAll(); - } - } -} diff --git a/src/Sylius/Bundle/RbacBundle/Form/EventSubscriber/AddParentFormSubscriber.php b/src/Sylius/Bundle/RbacBundle/Form/EventSubscriber/AddParentFormSubscriber.php deleted file mode 100644 index 0b6c21784d..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Form/EventSubscriber/AddParentFormSubscriber.php +++ /dev/null @@ -1,75 +0,0 @@ - - */ -class AddParentFormSubscriber implements EventSubscriberInterface -{ - /** - * @var string - */ - private $type; - - /** - * @param string $type - */ - public function __construct($type) - { - $this->type = $type; - } - - /** - * {@inheritdoc} - */ - public static function getSubscribedEvents() - { - return [ - FormEvents::PRE_SET_DATA => 'preSetData', - ]; - } - - /** - * @param FormEvent $event - */ - public function preSetData(FormEvent $event) - { - $resource = $event->getData(); - - if (null === $resource) { - return; - } - - if (!$resource instanceof RoleInterface && !$resource instanceof PermissionInterface) { - throw new UnexpectedTypeException($resource, '\RoleInterface or \PermissionInterface'); - } - - if (null !== $resource->getId() && null === $resource->getParent()) { - return; - } - - $form = $event->getForm(); - $form->add( - 'parent', - sprintf('sylius_%s_choice', $this->type), - ['label' => sprintf('sylius.form.%s.parent', $this->type)] - ); - } -} diff --git a/src/Sylius/Bundle/RbacBundle/Form/Type/PermissionEntityType.php b/src/Sylius/Bundle/RbacBundle/Form/Type/PermissionEntityType.php deleted file mode 100644 index 73a9201e9d..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Form/Type/PermissionEntityType.php +++ /dev/null @@ -1,35 +0,0 @@ - - */ -class PermissionEntityType extends ResourceChoiceType -{ - public function configureOptions(OptionsResolver $resolver) - { - parent::configureOptions($resolver); - - $resolver->setDefaults([ - 'query_builder' => function (EntityRepository $repository) { - return $repository->createQueryBuilder('o')->orderBy('o.left', 'asc'); - }, - ]); - } -} diff --git a/src/Sylius/Bundle/RbacBundle/Form/Type/PermissionType.php b/src/Sylius/Bundle/RbacBundle/Form/Type/PermissionType.php deleted file mode 100644 index f465c8c1e5..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Form/Type/PermissionType.php +++ /dev/null @@ -1,47 +0,0 @@ - - */ -class PermissionType extends AbstractResourceType -{ - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('description', 'textarea', [ - 'label' => 'sylius.form.permission.description', - ]) - ->addEventSubscriber(new AddCodeFormSubscriber()) - ->addEventSubscriber(new AddParentFormSubscriber('permission')) - ; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'sylius_permission'; - } -} diff --git a/src/Sylius/Bundle/RbacBundle/Form/Type/RoleEntityType.php b/src/Sylius/Bundle/RbacBundle/Form/Type/RoleEntityType.php deleted file mode 100644 index 0e3f6dc167..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Form/Type/RoleEntityType.php +++ /dev/null @@ -1,35 +0,0 @@ - - */ -class RoleEntityType extends ResourceChoiceType -{ - public function configureOptions(OptionsResolver $resolver) - { - parent::configureOptions($resolver); - - $resolver->setDefaults([ - 'query_builder' => function (EntityRepository $repository) { - return $repository->createQueryBuilder('o')->orderBy('o.left', 'asc'); - }, - ]); - } -} diff --git a/src/Sylius/Bundle/RbacBundle/Form/Type/RoleType.php b/src/Sylius/Bundle/RbacBundle/Form/Type/RoleType.php deleted file mode 100644 index 6b7572e3f9..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Form/Type/RoleType.php +++ /dev/null @@ -1,61 +0,0 @@ - - */ -class RoleType extends AbstractResourceType -{ - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('name', 'text', [ - 'label' => 'sylius.form.role.name', - ]) - ->add('description', 'textarea', [ - 'required' => false, - 'label' => 'sylius.form.role.description', - ]) - ->add('securityRoles', 'sylius_security_role_choice', [ - 'required' => false, - 'label' => 'sylius.form.role.security_roles', - ]) - ->add('permissions', 'sylius_permission_choice', [ - 'required' => false, - 'multiple' => true, - 'expanded' => true, - 'label' => 'sylius.form.role.permissions', - ]) - ->addEventSubscriber(new AddCodeFormSubscriber()) - ->addEventSubscriber(new AddParentFormSubscriber('role')) - ; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'sylius_role'; - } -} diff --git a/src/Sylius/Bundle/RbacBundle/Form/Type/SecurityRoleChoiceType.php b/src/Sylius/Bundle/RbacBundle/Form/Type/SecurityRoleChoiceType.php deleted file mode 100644 index 1ada09766f..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Form/Type/SecurityRoleChoiceType.php +++ /dev/null @@ -1,64 +0,0 @@ - - */ -class SecurityRoleChoiceType extends AbstractType -{ - /** - * @var array - */ - protected $roles; - - /** - * @param array $roles - */ - public function __construct(array $roles) - { - $this->roles = $roles; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'choices' => $this->roles, - 'multiple' => true, - 'expanded' => true, - ]); - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return 'choice'; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'sylius_security_role_choice'; - } -} diff --git a/src/Sylius/Bundle/RbacBundle/Provider/SecurityIdentityProvider.php b/src/Sylius/Bundle/RbacBundle/Provider/SecurityIdentityProvider.php deleted file mode 100644 index 9d4be004cf..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Provider/SecurityIdentityProvider.php +++ /dev/null @@ -1,60 +0,0 @@ - - */ -class SecurityIdentityProvider implements CurrentIdentityProviderInterface -{ - /** - * @var TokenStorageInterface - */ - private $tokenStorage; - - /** - * @param TokenStorageInterface $tokenStorage - */ - public function __construct(TokenStorageInterface $tokenStorage) - { - $this->tokenStorage = $tokenStorage; - } - - /** - * {@inheritdoc} - */ - public function getIdentity() - { - if (null === $token = $this->tokenStorage->getToken()) { - return; - } - - if ($token instanceof AnonymousToken) { - return; - } - - if (null === $user = $token->getUser()) { - return; - } - - if (!$user instanceof IdentityInterface) { - throw new \InvalidArgumentException('User class must implement "Sylius\Component\Rbac\Model\IdentityInterface".'); - } - - return $user; - } -} diff --git a/src/Sylius/Bundle/RbacBundle/README.md b/src/Sylius/Bundle/RbacBundle/README.md deleted file mode 100644 index 7d67f2d29e..0000000000 --- a/src/Sylius/Bundle/RbacBundle/README.md +++ /dev/null @@ -1,74 +0,0 @@ -SyliusRbacBundle [![Build status...](https://secure.travis-ci.org/Sylius/SyliusRbacBundle.png?branch=master)](http://travis-ci.org/Sylius/SyliusRbacBundle) -================ - -Symfony2 Role-Based-Access-Control bundle, powered by Sylius Rbac component. - -Sylius ------- - -**Sylius** - Modern ecommerce for Symfony2. Visit [Sylius.org](http://sylius.org). - -[phpspec](http://phpspec.net) examples --------------------------------------- - -```bash -$ composer install -$ bin/phpspec run -f pretty -``` - -Documentation -------------- - -Documentation is available on [**docs.sylius.org**](http://sylius.org/en/latest/bundles/SyliusRbacBundle/index.html). - -Contributing ------------- - -All informations about contributing to Sylius can be found on [this page](http://docs.sylius.org/en/latest/contributing/index.html). - -Mailing lists -------------- - -### Users - -Questions? Feel free to ask on [users mailing list](http://groups.google.com/group/sylius). - -### Developers - -To contribute and develop this bundle, use the [developers mailing list](http://groups.google.com/group/sylius-dev). - -Sylius twitter account ----------------------- - -If you want to keep up with updates, [follow the official Sylius account on twitter](http://twitter.com/Sylius). - -Bug tracking ------------- - -This bundle uses [GitHub issues](https://github.com/Sylius/SyliusRbacBundle/issues). -If you have found bug, please create an issue. - -Versioning ----------- - -Releases will be numbered with the format `major.minor.patch`. - -And constructed with the following guidelines. - -* Breaking backwards compatibility bumps the major. -* New additions without breaking backwards compatibility bumps the minor. -* Bug fixes and misc changes bump the patch. - -For more information on SemVer, please visit [semver.org website](http://semver.org/)... -This versioning method is same for all **Sylius** bundles and applications. - -MIT License ------------ - -License can be found [here](https://github.com/Sylius/SyliusRbacBundle/blob/master/Resources/meta/LICENSE). - -Authors -------- - -The bundle was originally created by [Paweł Jędrzejewski](http://pjedrzejewski.com). -See the list of [contributors](https://github.com/Sylius/SyliusRbacBundle/contributors). diff --git a/src/Sylius/Bundle/RbacBundle/Resources/config/doctrine/model/Permission.orm.xml b/src/Sylius/Bundle/RbacBundle/Resources/config/doctrine/model/Permission.orm.xml deleted file mode 100644 index c49696069a..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/config/doctrine/model/Permission.orm.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Sylius/Bundle/RbacBundle/Resources/config/doctrine/model/Role.orm.xml b/src/Sylius/Bundle/RbacBundle/Resources/config/doctrine/model/Role.orm.xml deleted file mode 100644 index 059b6d8edd..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/config/doctrine/model/Role.orm.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Sylius/Bundle/RbacBundle/Resources/config/driver/doctrine/orm.xml b/src/Sylius/Bundle/RbacBundle/Resources/config/driver/doctrine/orm.xml deleted file mode 100644 index 827a1e8c99..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/config/driver/doctrine/orm.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - Sylius\Bundle\RbacBundle\Form\Type\RoleEntityType - Sylius\Bundle\RbacBundle\Form\Type\PermissionEntityType - - Sylius\Bundle\RbacBundle\Doctrine\ORM\RoleRepository - Sylius\Bundle\RbacBundle\Doctrine\ORM\PermissionRepository - - Sylius\Bundle\RbacBundle\EventListener\CacheListener - - - - - - - - - - - - diff --git a/src/Sylius/Bundle/RbacBundle/Resources/config/resource_integration.xml b/src/Sylius/Bundle/RbacBundle/Resources/config/resource_integration.xml deleted file mode 100644 index 518730ea81..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/config/resource_integration.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - Sylius\Bundle\RbacBundle\Authorization\RbacAuthorizationChecker - - - - - - - - diff --git a/src/Sylius/Bundle/RbacBundle/Resources/config/services.xml b/src/Sylius/Bundle/RbacBundle/Resources/config/services.xml deleted file mode 100644 index 113395cc3b..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/config/services.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - Sylius\Bundle\RbacBundle\Provider\SecurityIdentityProvider - Sylius\Component\Rbac\Authorization\AuthorizationChecker - Sylius\Component\Rbac\Provider\PermissionProvider - Sylius\Component\Rbac\Resolver\NestedSetRolesResolver - Sylius\Component\Rbac\Resolver\NestedSetPermissionsResolver - Sylius\Component\Rbac\Authorization\PermissionMap - Sylius\Component\Rbac\Authorization\CachedPermissionMap - Sylius\Bundle\RbacBundle\Form\Type\SecurityRoleChoiceType - Sylius\Bundle\RbacBundle\Doctrine\RbacInitializer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %sylius.rbac.security_roles% - - - - - %sylius.rbac.default_permissions% - %sylius.rbac.default_permissions_hierarchy% - - - - %sylius.rbac.default_roles% - %sylius.rbac.default_roles_hierarchy% - - - - - - - diff --git a/src/Sylius/Bundle/RbacBundle/Resources/config/templating.xml b/src/Sylius/Bundle/RbacBundle/Resources/config/templating.xml deleted file mode 100644 index c444365614..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/config/templating.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - Sylius\Bundle\RbacBundle\Templating\Helper\RbacHelper - - - - - - - - - - diff --git a/src/Sylius/Bundle/RbacBundle/Resources/config/twig.xml b/src/Sylius/Bundle/RbacBundle/Resources/config/twig.xml deleted file mode 100644 index b93fd554c7..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/config/twig.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - Sylius\Bundle\RbacBundle\Twig\RbacExtension - - - - - - - - - - diff --git a/src/Sylius/Bundle/RbacBundle/Resources/config/validation.xml b/src/Sylius/Bundle/RbacBundle/Resources/config/validation.xml deleted file mode 100644 index 770196f180..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/config/validation.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Sylius/Bundle/RbacBundle/Resources/meta/LICENSE b/src/Sylius/Bundle/RbacBundle/Resources/meta/LICENSE deleted file mode 100644 index acd4c1958c..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/meta/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2011-2016 Paweł Jędrzejewski - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.ar.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.ar.yml deleted file mode 100644 index 5b51cdc937..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.ar.yml +++ /dev/null @@ -1,7 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - name: الاسم diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.be.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.be.yml deleted file mode 100644 index c0958b897e..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.be.yml +++ /dev/null @@ -1,14 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Код - name: Імя - description: Апісанне - parent: "Бацькоўскі аб'ект" - permission: - code: Код - description: Апісанне - parent: "Бацькоўскі аб'ект" diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.ca.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.ca.yml deleted file mode 100644 index 725aeeaf3b..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.ca.yml +++ /dev/null @@ -1,12 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Codi - name: Nom - description: Descripció - permission: - code: Codi - description: Descripció diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.cs.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.cs.yml deleted file mode 100644 index 6620e15ba4..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.cs.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Kód - name: Jméno - description: Popis - permissions: Oprávnění - parent: Rodič - permission: - code: Kód - description: Popis - parent: Rodič diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.da.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.da.yml deleted file mode 100644 index 97619a73e2..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.da.yml +++ /dev/null @@ -1,14 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Kode - name: Navn - description: Beskrivelse - parent: Overordnede - permission: - code: Kode - description: Beskrivelse - parent: Overordnede diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.de.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.de.yml deleted file mode 100644 index ef3a87f95f..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.de.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Code - name: Name - description: Beschreibung - permissions: Berechtigungen - parent: Übergeordnet - permission: - code: Code - description: Beschreibung - parent: Übergeordnet diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.de_CH.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.de_CH.yml deleted file mode 100644 index dc8d4c6d51..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.de_CH.yml +++ /dev/null @@ -1,10 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Code - name: Name - permission: - code: Code diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.el.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.el.yml deleted file mode 100644 index 9583c317ca..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.el.yml +++ /dev/null @@ -1,12 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Κώδικος - name: Ονομασία - description: Περιγραφή - permission: - code: Κώδικος - description: Περιγραφή diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.en.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.en.yml deleted file mode 100644 index 3a645c0d08..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.en.yml +++ /dev/null @@ -1,12 +0,0 @@ -sylius: - form: - role: - code: Code - name: Name - description: Description - permissions: Permissions - parent: Parent - permission: - code: Code - description: Description - parent: Parent \ No newline at end of file diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.es.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.es.yml deleted file mode 100644 index 9849cb9e9b..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.es.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Código - name: Nombre - description: Descripción - permissions: Permisos - parent: Padre - permission: - code: Código - description: Descripción - parent: Padre diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.fa.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.fa.yml deleted file mode 100644 index 12c8eaff6f..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.fa.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: نام انگلیسی - name: نام - description: شرح - permissions: دسترسی ها - parent: رده پدر - permission: - code: نام انگلیسی - description: شرح - parent: رده پدر diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.fi.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.fi.yml deleted file mode 100644 index 4b206c3999..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.fi.yml +++ /dev/null @@ -1,9 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - parent: Vanhempi - permission: - parent: Vanhempi diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.fr.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.fr.yml deleted file mode 100644 index d41a37ae1b..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.fr.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Code - name: Nom - description: Description - permissions: "Droits d'accès" - parent: Parent - permission: - code: Code - description: Description - parent: Parent diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.hr.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.hr.yml deleted file mode 100644 index b99b181965..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.hr.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: ISO kod - name: Naziv grupe - description: Opis - permissions: Dozvole - parent: Nadređena kategorija - permission: - code: ISO kod - description: Opis - parent: Nadređena kategorija diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.hu.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.hu.yml deleted file mode 100644 index 0213a92ee7..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.hu.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Kód - name: Név - description: Leírás - permissions: Engedélyek - parent: Szülő - permission: - code: Kód - description: Leírás - parent: Szülő diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.id.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.id.yml deleted file mode 100644 index 21ccb71bb6..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.id.yml +++ /dev/null @@ -1,10 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Kode - name: Nama - permission: - code: Kode diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.it.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.it.yml deleted file mode 100644 index f8a2289a4d..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.it.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Codice - name: Nome - description: Descrizione - permissions: Autorizzazioni - parent: Genitore - permission: - code: Codice - description: Descrizione - parent: Genitore diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.lt.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.lt.yml deleted file mode 100644 index 0b3951be1c..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.lt.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Kodas - name: Pavadinimas - description: Aprašymas - permissions: Prieigos teisės - parent: Motininis elementas - permission: - code: Kodas - description: Aprašymas - parent: Motininis elementas diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.nl.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.nl.yml deleted file mode 100644 index f94d0e995c..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.nl.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Code - name: Naam - description: Omschrijving - permissions: Machtigingen - parent: Ouder - permission: - code: Code - description: Omschrijving - parent: Ouder diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.no.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.no.yml deleted file mode 100644 index 4f102bce0b..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.no.yml +++ /dev/null @@ -1,14 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Kode - name: Navn - description: Beskrivelse - parent: Forelder - permission: - code: Kode - description: Beskrivelse - parent: Forelder diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.pl.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.pl.yml deleted file mode 100644 index e62e38137c..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.pl.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Kod - name: Nazwa - description: Opis - permissions: Uprawnienia - parent: Rodzic - permission: - code: Kod - description: Opis - parent: Rodzic diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.pt.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.pt.yml deleted file mode 100644 index fcfdc697eb..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.pt.yml +++ /dev/null @@ -1,11 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - name: Nome - description: Descrição - permissions: Permissões - permission: - description: Descrição diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.pt_BR.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.pt_BR.yml deleted file mode 100644 index 84b7ffe9f0..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.pt_BR.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Código - name: Nome - description: Descrição - permissions: Permissões - parent: Pai - permission: - code: Código - description: Descrição - parent: Pai diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.ro.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.ro.yml deleted file mode 100644 index a199cd897b..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.ro.yml +++ /dev/null @@ -1,14 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Cod - name: Nume - description: Descriere - parent: Părinte - permission: - code: Cod - description: Descriere - parent: Părinte diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.ru.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.ru.yml deleted file mode 100644 index 49f373c058..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.ru.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Код - name: Название - description: Описание - permissions: Права доступа - parent: Родитель - permission: - code: Код - description: Описание - parent: Родитель diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.sk.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.sk.yml deleted file mode 100644 index 5c270303ca..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.sk.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Kód - name: Názov - description: Popis - permissions: Oprávnenia - parent: Nadradená kategória - permission: - code: Kód - description: Popis - parent: Nadradená kategória diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.sl.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.sl.yml deleted file mode 100644 index 6f6b09aa06..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.sl.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Koda - name: Ime - description: Opis - permissions: Dovoljenja - parent: Nadrejeni - permission: - code: Koda - description: Opis - parent: Nadrejeni diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.sq.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.sq.yml deleted file mode 100644 index b0b6ebca16..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.sq.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Kodi - name: Emri - description: Përshkrimi - permissions: Lejet - parent: Prind - permission: - code: Kodi - description: Përshkrimi - parent: Prind diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.sr_CS.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.sr_CS.yml deleted file mode 100644 index 0dfde43b69..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.sr_CS.yml +++ /dev/null @@ -1,7 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - name: Ime diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.sv.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.sv.yml deleted file mode 100644 index 7bd867fbc5..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.sv.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Kod - name: Namn - description: Beskrivning - permissions: Rättigheter - parent: Förälder - permission: - code: Kod - description: Beskrivning - parent: Förälder diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.th.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.th.yml deleted file mode 100644 index fd0c039f2f..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.th.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: รหัส - name: ชื่อ - description: คำอธิบาย - permissions: สิทธิ์การเข้าถึง - parent: หมวดแม่ - permission: - code: รหัส - description: คำอธิบาย - parent: หมวดแม่ diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.tr.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.tr.yml deleted file mode 100644 index 32673c5c4e..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.tr.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Kod - name: Ad - description: Açıklama - permissions: İzinler - parent: Üst - permission: - code: Kod - description: Açıklama - parent: Üst diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.uk.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.uk.yml deleted file mode 100644 index 9225c9b04c..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.uk.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Код - name: Ім’я - description: Опис - permissions: Дозволи - parent: "Батьківський об'єкт" - permission: - code: Код - description: Опис - parent: "Батьківський об'єкт" diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.vi.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.vi.yml deleted file mode 100644 index b4483bac4d..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.vi.yml +++ /dev/null @@ -1,10 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: Mã - name: Tên - permission: - code: Mã diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.zh_CN.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.zh_CN.yml deleted file mode 100644 index 74db51c9af..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/messages.zh_CN.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - form: - role: - code: 代码 - name: 名称 - description: 描述 - permissions: 权限 - parent: 上一级 - permission: - code: 代码 - description: 描述 - parent: 上一级 diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.cs.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.cs.yml deleted file mode 100644 index 159618355c..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.cs.yml +++ /dev/null @@ -1,16 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - role: - code: - unique: Kód musí být unikátní. - not_blank: Zadejte kód, prosím. - name: - not_blank: Zadejte prosím název role. - permission: - code: - unique: Kód musí být unikátní. - not_blank: Zadejte kód, prosím. - description: - not_blank: Popište, prosím, oprávnění. diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.de.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.de.yml deleted file mode 100644 index 6e6848870e..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.de.yml +++ /dev/null @@ -1,16 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - role: - code: - unique: Der Kode muss eindeutig sein. - not_blank: Bitte gib einen Kode ein. - name: - not_blank: Bitte gib einen Namen für die Rolle ein. - permission: - code: - unique: Der Kode muss eindeutig sein. - not_blank: Bitte gib einen Kode ein. - description: - not_blank: Bitte beschreibe die Erlaubnis. diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.en.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.en.yml deleted file mode 100644 index 71f0f01693..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.en.yml +++ /dev/null @@ -1,13 +0,0 @@ -sylius: - role: - code: - unique: Code must be unique. - not_blank: Please enter code. - name: - not_blank: Please enter role name. - permission: - code: - unique: Code must be unique. - not_blank: Please enter code. - description: - not_blank: Please describe the permission. diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.es.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.es.yml deleted file mode 100644 index cfcf32dd9c..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.es.yml +++ /dev/null @@ -1,16 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - role: - code: - unique: El código debe ser único. - not_blank: Por favor, introduzca un código. - name: - not_blank: Por favor, introduzca un nombre de rol. - permission: - code: - unique: El código debe ser único. - not_blank: Por favor, introduzca un código. - description: - not_blank: Por favor, describa el permiso. diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.fa.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.fa.yml deleted file mode 100644 index 030e35c46f..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.fa.yml +++ /dev/null @@ -1,16 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - role: - code: - unique: کد باید منحصر به فرد باشد. - not_blank: لطفا کد را وارد کنید. - name: - not_blank: لطفا نام نقش کاربری را وارد کنید. - permission: - code: - unique: کد باید منحصر به فرد باشد. - not_blank: لطفا کد را وارد کنید. - description: - not_blank: لطفا تنظیمات دسترسی را تعریف کنید. diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.fr.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.fr.yml deleted file mode 100644 index d252d39256..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.fr.yml +++ /dev/null @@ -1,16 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - role: - code: - unique: Le code doit être unique. - not_blank: Veuillez entrer un code. - name: - not_blank: Veuillez entrer un nom de rôle. - permission: - code: - unique: Le code doit être unique. - not_blank: Veuillez entrer un code. - description: - not_blank: Veuillez décrire la permission. diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.hu.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.hu.yml deleted file mode 100644 index 7f25250906..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.hu.yml +++ /dev/null @@ -1,16 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - role: - code: - unique: Kódnak egyedinek kell lennie. - not_blank: Kérjük, írja be a kódot. - name: - not_blank: Kérjük adja meg az szerepkör nevét. - permission: - code: - unique: Kódnak egyedinek kell lennie. - not_blank: Kérjük, írja be a kódot. - description: - not_blank: Kérjük, ismertesse az jogosultságot. diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.it.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.it.yml deleted file mode 100644 index 7fdf84f311..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.it.yml +++ /dev/null @@ -1,16 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - role: - code: - unique: Il codice deve essere univoco. - not_blank: Inserisci il codice. - name: - not_blank: Inserisci il nome del ruolo. - permission: - code: - unique: Il codice deve essere univoco. - not_blank: Inserisci il codice. - description: - not_blank: "Si prega di descrivere l'autorizzazione." diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.lt.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.lt.yml deleted file mode 100644 index 273f6d909c..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.lt.yml +++ /dev/null @@ -1,16 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - role: - code: - unique: Kodas turi būti unikalus. - not_blank: Prašome įvesti kodą. - name: - not_blank: Įveskite rolės pavadinimą. - permission: - code: - unique: Kodas turi būti unikalus. - not_blank: Prašome įvesti kodą. - description: - not_blank: Apibūdinkite leidimą. diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.nl.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.nl.yml deleted file mode 100644 index 4af6deb615..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.nl.yml +++ /dev/null @@ -1,16 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - role: - code: - unique: Code moet uniek zijn. - not_blank: Voer code in. - name: - not_blank: Voer rolnaam in. - permission: - code: - unique: Code moet uniek zijn. - not_blank: Voer code in. - description: - not_blank: Beschrijf de machtiging. diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.pl.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.pl.yml deleted file mode 100644 index ec4bcca056..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.pl.yml +++ /dev/null @@ -1,16 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - role: - code: - unique: Kod musi być unikatowy. - not_blank: Wprowadź kod. - name: - not_blank: Wprowadź nazwę roli. - permission: - code: - unique: Kod musi być unikatowy. - not_blank: Wprowadź kod. - description: - not_blank: Opisz uprawnienie. diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.pt.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.pt.yml deleted file mode 100644 index b9ac3b9734..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.pt.yml +++ /dev/null @@ -1,10 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - role: - code: - not_blank: Por favor digite o código. - permission: - code: - not_blank: Por favor digite o código. diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.pt_BR.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.pt_BR.yml deleted file mode 100644 index fbaaf95fb3..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.pt_BR.yml +++ /dev/null @@ -1,16 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - role: - code: - unique: Código deve ser único. - not_blank: Por favor digite o código. - name: - not_blank: Por favor insira o nome do papel/função. - permission: - code: - unique: Código deve ser único. - not_blank: Por favor digite o código. - description: - not_blank: Por favor, descreva a permissão. diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.ru.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.ru.yml deleted file mode 100644 index 2209069894..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.ru.yml +++ /dev/null @@ -1,16 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - role: - code: - unique: Код должен быть уникальным. - not_blank: Пожалуйста, введите код. - name: - not_blank: Пожалуйста, введите имя роли. - permission: - code: - unique: Код должен быть уникальным. - not_blank: Пожалуйста, введите код. - description: - not_blank: Пожалуйста, опишите право доступа. diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.sk.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.sk.yml deleted file mode 100644 index 138d038690..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.sk.yml +++ /dev/null @@ -1,16 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - role: - code: - unique: Kód musí byť jedinečný. - not_blank: Prosím, zadajte kód. - name: - not_blank: Prosím zadajte názov role. - permission: - code: - unique: Kód musí byť jedinečný. - not_blank: Prosím, zadajte kód. - description: - not_blank: Prosím, opíšte právomoc. diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.sl.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.sl.yml deleted file mode 100644 index ae5e5cdcde..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.sl.yml +++ /dev/null @@ -1,16 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - role: - code: - unique: Koda mora biti edinstvena. - not_blank: Prosimo, vnesite kodo. - name: - not_blank: Prosimo, vnesite ime vloge. - permission: - code: - unique: Koda mora biti edinstvena. - not_blank: Prosimo, vnesite kodo. - description: - not_blank: Prosimo, opišite dovoljenje. diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.sq.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.sq.yml deleted file mode 100644 index 02efcce31b..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.sq.yml +++ /dev/null @@ -1,16 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - role: - code: - unique: Kodi duhet të jetë unik. - not_blank: Fut kodin. - name: - not_blank: Fut emrin e rolit. - permission: - code: - unique: Kodi duhet të jetë unik. - not_blank: Fut kodin. - description: - not_blank: Përshkruaj lejen. diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.th.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.th.yml deleted file mode 100644 index b861ab97d4..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.th.yml +++ /dev/null @@ -1,16 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - role: - code: - unique: รหัสต้องไม่ซ้ำกัน - not_blank: กรุณาใส่รหัส - name: - not_blank: กรุณาระบุชื่อบทบาท - permission: - code: - unique: รหัสต้องไม่ซ้ำกัน - not_blank: กรุณาใส่รหัส - description: - not_blank: โปรดอธิบายสิทธิ์การเข้าถึง diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.tr.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.tr.yml deleted file mode 100644 index e94a40dcc5..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.tr.yml +++ /dev/null @@ -1,16 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - role: - code: - unique: Kodun benzersiz olması gerekir. - not_blank: Lütfen kodu girin. - name: - not_blank: Lütfen bölge adını yazınız. - permission: - code: - unique: Kodun benzersiz olması gerekir. - not_blank: Lütfen kodu girin. - description: - not_blank: Izni açıklayınız. diff --git a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.zh_CN.yml b/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.zh_CN.yml deleted file mode 100644 index e80d2c909b..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Resources/translations/validators.zh_CN.yml +++ /dev/null @@ -1,16 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -sylius: - role: - code: - unique: 编号必须是唯一的。 - not_blank: 请输入编号。 - name: - not_blank: 请输入角色名称。 - permission: - code: - unique: 编号必须是唯一的。 - not_blank: 请输入编号。 - description: - not_blank: 请添加权限描述。 diff --git a/src/Sylius/Bundle/RbacBundle/SyliusRbacBundle.php b/src/Sylius/Bundle/RbacBundle/SyliusRbacBundle.php deleted file mode 100644 index 8f47bc690e..0000000000 --- a/src/Sylius/Bundle/RbacBundle/SyliusRbacBundle.php +++ /dev/null @@ -1,41 +0,0 @@ - - */ -class SyliusRbacBundle extends AbstractResourceBundle -{ - /** - * {@inheritdoc} - */ - public function getSupportedDrivers() - { - return [ - SyliusResourceBundle::DRIVER_DOCTRINE_ORM, - ]; - } - - /** - * {@inheritdoc} - */ - protected function getModelNamespace() - { - return 'Sylius\Component\Rbac\Model'; - } -} diff --git a/src/Sylius/Bundle/RbacBundle/Templating/Helper/RbacHelper.php b/src/Sylius/Bundle/RbacBundle/Templating/Helper/RbacHelper.php deleted file mode 100644 index c475126f9f..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Templating/Helper/RbacHelper.php +++ /dev/null @@ -1,51 +0,0 @@ - - */ -class RbacHelper extends Helper -{ - /** - * @var AuthorizationCheckerInterface - */ - private $authorizationChecker; - - public function __construct(AuthorizationCheckerInterface $authorizationChecker) - { - $this->authorizationChecker = $authorizationChecker; - } - - /** - * Check if currently logged in identity is granted permission. - * - * @param string $permissionCode - * - * @return string - */ - public function isGranted($permissionCode) - { - return $this->authorizationChecker->isGranted($permissionCode); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'sylius_rbac'; - } -} diff --git a/src/Sylius/Bundle/RbacBundle/Twig/RbacExtension.php b/src/Sylius/Bundle/RbacBundle/Twig/RbacExtension.php deleted file mode 100644 index 403e02e148..0000000000 --- a/src/Sylius/Bundle/RbacBundle/Twig/RbacExtension.php +++ /dev/null @@ -1,65 +0,0 @@ - - */ -class RbacExtension extends \Twig_Extension -{ - /** - * @var RbacHelper - */ - protected $helper; - - /** - * @param RbacHelper $helper - */ - public function __construct(RbacHelper $helper) - { - $this->helper = $helper; - } - - /** - * {@inheritdoc} - */ - public function getFunctions() - { - return [ - new \Twig_SimpleFunction('sylius_is_granted', [$this, 'isGranted']), - ]; - } - - /** - * Check if currently logged in user is granted specific permission. - * - * @param string $permissionCode - * - * @return string - */ - public function isGranted($permissionCode) - { - return $this->helper->isGranted($permissionCode); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'sylius_rbac'; - } -} diff --git a/src/Sylius/Bundle/RbacBundle/composer.json b/src/Sylius/Bundle/RbacBundle/composer.json deleted file mode 100644 index b536a08230..0000000000 --- a/src/Sylius/Bundle/RbacBundle/composer.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "sylius/rbac-bundle", - "type": "symfony-bundle", - "description": "Symfony2 Role-Based-Access-Control", - "keywords": ["security", "rbac", "roles", "permissions"], - "homepage": "http://sylius.org", - "license": "MIT", - "authors": [ - { - "name": "Paweł Jędrzejewski", - "homepage": "http://pjedrzejewski.com" - }, - { - "name": "Sylius project", - "homepage": "http://sylius.org" - }, - { - "name": "Community contributions", - "homepage": "http://github.com/Sylius/Sylius/contributors" - } - ], - "require": { - "php": "^5.6|^7.0", - - "doctrine/doctrine-cache-bundle": "~1.0", - "sylius/rbac": "^1.0", - "sylius/resource-bundle": "^1.0", - "symfony/framework-bundle": "^2.8" - }, - "require-dev": { - "phpspec/phpspec": "^3.0", - "doctrine/orm": "^2.4.8,<2.5", - "symfony/form": "^2.8", - "twig/twig": "^1.0" - }, - "config": { - "bin-dir": "bin" - }, - "autoload": { - "psr-4": { "Sylius\\Bundle\\RbacBundle\\": "" } - }, - "autoload-dev": { - "psr-4": { "Sylius\\Bundle\\RbacBundle\\spec\\": "spec/" } - }, - "minimum-stability": "dev", - "prefer-stable": true, - "repositories": [ - { - "type": "path", - "url": "../../*/*" - } - ], - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - } -} diff --git a/src/Sylius/Bundle/RbacBundle/phpspec.yml.dist b/src/Sylius/Bundle/RbacBundle/phpspec.yml.dist deleted file mode 100644 index d49a002e49..0000000000 --- a/src/Sylius/Bundle/RbacBundle/phpspec.yml.dist +++ /dev/null @@ -1,5 +0,0 @@ -suites: - main: - namespace: Sylius\Bundle\RbacBundle - psr4_prefix: Sylius\Bundle\RbacBundle - src_path: . diff --git a/src/Sylius/Bundle/RbacBundle/spec/Authorization/RbacAuthorizationCheckerSpec.php b/src/Sylius/Bundle/RbacBundle/spec/Authorization/RbacAuthorizationCheckerSpec.php deleted file mode 100644 index 009dce5a4a..0000000000 --- a/src/Sylius/Bundle/RbacBundle/spec/Authorization/RbacAuthorizationCheckerSpec.php +++ /dev/null @@ -1,57 +0,0 @@ - - */ -final class RbacAuthorizationCheckerSpec extends ObjectBehavior -{ - function let(AuthorizationCheckerInterface $rbacAuthorizationChecker) - { - $this->beConstructedWith($rbacAuthorizationChecker); - } - - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Bundle\RbacBundle\Authorization\RbacAuthorizationChecker'); - } - - function it_implements_resource_controller_authorization_checker_interface() - { - $this->shouldImplement(ResourceBundleAuthorizationCheckerInterface::class); - } - - function it_grants_access_if_permission_is_not_required(RequestConfiguration $requestConfiguration) - { - $requestConfiguration->hasPermission()->willReturn(false); - $this->isGranted($requestConfiguration, 'sylius.product.foo')->shouldReturn(true); - } - - function it_uses_rbac_authorization_checker( - RequestConfiguration $requestConfiguration, - AuthorizationCheckerInterface $rbacAuthorizationChecker - ) { - $requestConfiguration->hasPermission()->willReturn(true); - $requestConfiguration->getPermission('sylius.product.foo')->willReturn('sylius.product.foo'); - $rbacAuthorizationChecker->isGranted('sylius.product.foo')->willReturn(false); - $this->isGranted($requestConfiguration, 'sylius.product.foo')->shouldReturn(false); - - $rbacAuthorizationChecker->isGranted('sylius.product.foo')->willReturn(true); - $this->isGranted($requestConfiguration, 'sylius.product.foo')->shouldReturn(true); - } -} diff --git a/src/Sylius/Bundle/RbacBundle/spec/Doctrine/ORM/PermissionRepositorySpec.php b/src/Sylius/Bundle/RbacBundle/spec/Doctrine/ORM/PermissionRepositorySpec.php deleted file mode 100644 index 0dcb96c915..0000000000 --- a/src/Sylius/Bundle/RbacBundle/spec/Doctrine/ORM/PermissionRepositorySpec.php +++ /dev/null @@ -1,63 +0,0 @@ - - */ -final class PermissionRepositorySpec extends ObjectBehavior -{ - function let(EntityManager $em, ClassMetadata $classMetadata) - { - $this->beConstructedWith($em, $classMetadata); - } - - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Bundle\RbacBundle\Doctrine\ORM\PermissionRepository'); - } - - function it_gets_child_permission( - $em, - PermissionInterface $permission, - QueryBuilder $builder, - AbstractQuery $query, - Expr $expr - ) { - $permission->getRight()->shouldBeCalled()->willReturn(1); - $permission->getLeft()->shouldBeCalled()->willReturn(2); - - $builder->expr()->shouldBeCalled()->willReturn($expr); - $expr->lt('o.left', 1)->shouldBeCalled()->willReturn($expr); - $expr->gt('o.left', 2)->shouldBeCalled()->willReturn($expr); - - $em->createQueryBuilder()->shouldBeCalled()->willReturn($builder); - $builder->select('o')->shouldBeCalled()->willReturn($builder); - $builder->from(Argument::any(), 'o', Argument::cetera())->shouldBeCalled()->willReturn($builder); - $builder->where(Argument::type(Expr::class))->shouldBeCalled()->willReturn($builder); - $builder->andWhere(Argument::type(Expr::class))->shouldBeCalled()->willReturn($builder); - - $builder->getQuery()->shouldBeCalled()->willReturn($query); - $query->execute()->shouldBeCalled(); - - $this->getChildPermissions($permission); - } -} diff --git a/src/Sylius/Bundle/RbacBundle/spec/Doctrine/ORM/RoleRepositorySpec.php b/src/Sylius/Bundle/RbacBundle/spec/Doctrine/ORM/RoleRepositorySpec.php deleted file mode 100644 index 0163f667dd..0000000000 --- a/src/Sylius/Bundle/RbacBundle/spec/Doctrine/ORM/RoleRepositorySpec.php +++ /dev/null @@ -1,63 +0,0 @@ - - */ -final class RoleRepositorySpec extends ObjectBehavior -{ - function let(EntityManager $em, ClassMetadata $classMetadata) - { - $this->beConstructedWith($em, $classMetadata); - } - - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Bundle\RbacBundle\Doctrine\ORM\RoleRepository'); - } - - function it_gets_child_roles( - $em, - RoleInterface $role, - QueryBuilder $builder, - AbstractQuery $query, - Expr $expr - ) { - $role->getRight()->shouldBeCalled()->willReturn(1); - $role->getLeft()->shouldBeCalled()->willReturn(2); - - $builder->expr()->shouldBeCalled()->willReturn($expr); - $expr->lt('o.left', 1)->shouldBeCalled()->willReturn($expr); - $expr->gt('o.left', 2)->shouldBeCalled()->willReturn($expr); - - $em->createQueryBuilder()->shouldBeCalled()->willReturn($builder); - $builder->select('o')->shouldBeCalled()->willReturn($builder); - $builder->from(Argument::any(), 'o', Argument::cetera())->shouldBeCalled()->willReturn($builder); - $builder->where(Argument::type(Expr::class))->shouldBeCalled()->willReturn($builder); - $builder->andWhere(Argument::type(Expr::class))->shouldBeCalled()->willReturn($builder); - - $builder->getQuery()->shouldBeCalled()->willReturn($query); - $query->execute()->shouldBeCalled(); - - $this->getChildRoles($role); - } -} diff --git a/src/Sylius/Bundle/RbacBundle/spec/EventListener/CacheListenerSpec.php b/src/Sylius/Bundle/RbacBundle/spec/EventListener/CacheListenerSpec.php deleted file mode 100644 index fbd37ec023..0000000000 --- a/src/Sylius/Bundle/RbacBundle/spec/EventListener/CacheListenerSpec.php +++ /dev/null @@ -1,72 +0,0 @@ - - */ -final class CacheListenerSpec extends ObjectBehavior -{ - function let(ClearableCache $cache) - { - $this->beConstructedWith($cache); - } - - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Bundle\RbacBundle\EventListener\CacheListener'); - } - - function it_clears_the_cache_after_persisting_a_role($cache, LifecycleEventArgs $args, RoleInterface $role) - { - $args->getEntity()->shouldBeCalled()->willReturn($role); - $cache->deleteAll()->shouldBeCalled(); - - $this->postPersist($args); - } - - function it_clears_the_cache_on_post_after_removing_a_role($cache, LifecycleEventArgs $args, RoleInterface $role) - { - $args->getEntity()->shouldBeCalled()->willReturn($role); - $cache->deleteAll()->shouldBeCalled(); - - $this->postRemove($args); - } - - function it_clears_the_cache_after_persisting_a_permission( - $cache, - LifecycleEventArgs $args, - PermissionInterface $permission - ) { - $args->getEntity()->shouldBeCalled()->willReturn($permission); - $cache->deleteAll()->shouldBeCalled(); - - $this->postPersist($args); - } - - function it_clears_the_cache_on_post_after_removing_a_permission( - $cache, - LifecycleEventArgs $args, - PermissionInterface $permission - ) { - $args->getEntity()->shouldBeCalled()->willReturn($permission); - $cache->deleteAll()->shouldBeCalled(); - - $this->postRemove($args); - } -} diff --git a/src/Sylius/Bundle/RbacBundle/spec/Form/EventSubscriber/AddParentFormSubscriberSpec.php b/src/Sylius/Bundle/RbacBundle/spec/Form/EventSubscriber/AddParentFormSubscriberSpec.php deleted file mode 100644 index 4743d5b6b5..0000000000 --- a/src/Sylius/Bundle/RbacBundle/spec/Form/EventSubscriber/AddParentFormSubscriberSpec.php +++ /dev/null @@ -1,113 +0,0 @@ - - */ -final class AddParentFormSubscriberSpec extends ObjectBehavior -{ - function let() - { - $this->beConstructedWith('role'); - } - - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Bundle\RbacBundle\Form\EventSubscriber\AddParentFormSubscriber'); - } - - function it_implements_event_subscriber_interface() - { - $this->shouldImplement(EventSubscriberInterface::class); - } - - function it_subscribes_to_event() - { - $this::getSubscribedEvents()->shouldReturn([FormEvents::PRE_SET_DATA => 'preSetData']); - } - - function it_add_parent_if_it_is_not_set_and_resource_has_not_id(FormEvent $event, FormInterface $form, RoleInterface $role) - { - $event->getData()->willReturn($role); - $event->getForm()->willReturn($form); - - $role->getId()->willReturn(null); - $role->getParent()->willReturn(null); - - $form->add('parent', 'sylius_role_choice', Argument::cetera())->shouldBeCalled(); - - $this->preSetData($event); - } - - function it_add_parent_if_it_is_set_and_the_resource_has_id(FormEvent $event, FormInterface $form, RoleInterface $role) - { - $event->getData()->willReturn($role); - $event->getForm()->willReturn($form); - - $role->getId()->willReturn(112); - $role->getParent()->willReturn(Argument::type(RoleInterface::class)); - - $form->add('parent', 'sylius_role_choice', Argument::cetera())->shouldBeCalled(); - - $this->preSetData($event); - } - - function it_add_parent_if_it_is_set_and_the_resource_has_not_id(FormEvent $event, FormInterface $form, RoleInterface $role) - { - $event->getData()->willReturn($role); - $event->getForm()->willReturn($form); - - $role->getId()->willReturn(null); - $role->getParent()->willReturn(Argument::type(RoleInterface::class)); - - $form->add('parent', 'sylius_role_choice', Argument::cetera())->shouldBeCalled(); - - $this->preSetData($event); - } - - function it_does_not_add_parent_if_it_is_not_set_and_the_resource_has_id(FormEvent $event, FormInterface $form, RoleInterface $role) - { - $event->getData()->willReturn($role); - $event->getForm()->willReturn($form); - - $role->getId()->willReturn(112); - $role->getParent()->willReturn(null); - - $form->add('parent', 'sylius_role_choice', Argument::cetera())->shouldNotBeCalled(); - - $this->preSetData($event); - } - - function it_does_not_add_parent_if_resource_is_not_set(FormEvent $event, FormInterface $form) - { - $event->getData()->willReturn(null); - $form->add('parent', 'sylius_role_choice', Argument::cetera())->shouldNotBeCalled(); - $this->preSetData($event); - } - - function it_throws_exception_when_resource_does_not_implement_role_interface_or_permission_interface(FormEvent $event, \stdClass $resource) - { - $event->getData()->willReturn($resource); - $this->shouldThrow(UnexpectedTypeException::class) - ->during('preSetData', [$event]); - } -} diff --git a/src/Sylius/Bundle/RbacBundle/spec/Form/Type/PermissionEntityTypeSpec.php b/src/Sylius/Bundle/RbacBundle/spec/Form/Type/PermissionEntityTypeSpec.php deleted file mode 100644 index 1b99e0bb3f..0000000000 --- a/src/Sylius/Bundle/RbacBundle/spec/Form/Type/PermissionEntityTypeSpec.php +++ /dev/null @@ -1,50 +0,0 @@ - - */ -final class PermissionEntityTypeSpec extends ObjectBehavior -{ - function let(MetadataInterface $metadata) - { - $this->beConstructedWith($metadata); - } - - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Bundle\RbacBundle\Form\Type\PermissionEntityType'); - } - - function it_is_a_form() - { - $this->shouldHaveType(ResourceChoiceType::class); - } - - function it_has_options(OptionsResolver $resolver, $metadata) - { - $metadata->getDriver()->willReturn(SyliusResourceBundle::DRIVER_DOCTRINE_ORM); - $resolver->setDefaults(Argument::withKey('class'))->shouldBeCalled()->willReturn($resolver); - $resolver->setNormalizer('class', Argument::type('callable'))->shouldBeCalled()->willReturn($resolver); - $resolver->setDefaults(Argument::withKey('query_builder'))->shouldBeCalled()->willReturn($resolver); - - $this->configureOptions($resolver); - } -} diff --git a/src/Sylius/Bundle/RbacBundle/spec/Form/Type/PermissionTypeSpec.php b/src/Sylius/Bundle/RbacBundle/spec/Form/Type/PermissionTypeSpec.php deleted file mode 100644 index bdd40dfcef..0000000000 --- a/src/Sylius/Bundle/RbacBundle/spec/Form/Type/PermissionTypeSpec.php +++ /dev/null @@ -1,82 +0,0 @@ - - */ -final class PermissionTypeSpec extends ObjectBehavior -{ - function let() - { - $this->beConstructedWith('Permission', ['sylius']); - } - - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Bundle\RbacBundle\Form\Type\PermissionType'); - } - - function it_is_a_form_type() - { - $this->shouldImplement(FormTypeInterface::class); - } - - function it_should_build_form_with_proper_fields(FormBuilder $builder) - { - $builder - ->add('description', 'textarea', Argument::any()) - ->shouldBeCalled() - ->willReturn($builder) - ; - - $builder - ->addEventSubscriber(Argument::type(AddCodeFormSubscriber::class)) - ->shouldBeCalled() - ->willReturn($builder) - ; - - $builder - ->addEventSubscriber(Argument::type(AddParentFormSubscriber::class)) - ->shouldBeCalled() - ->willReturn($builder) - ; - - $this->buildForm($builder, []); - } - - function it_should_define_assigned_data_class_and_validation_groups(OptionsResolver $resolver) - { - $resolver - ->setDefaults([ - 'data_class' => 'Permission', - 'validation_groups' => ['sylius'], - ]) - ->shouldBeCalled() - ; - - $this->configureOptions($resolver); - } - - function it_has_valid_name() - { - $this->getName()->shouldReturn('sylius_permission'); - } -} diff --git a/src/Sylius/Bundle/RbacBundle/spec/Form/Type/RoleEntityTypeSpec.php b/src/Sylius/Bundle/RbacBundle/spec/Form/Type/RoleEntityTypeSpec.php deleted file mode 100644 index 344125c5ff..0000000000 --- a/src/Sylius/Bundle/RbacBundle/spec/Form/Type/RoleEntityTypeSpec.php +++ /dev/null @@ -1,50 +0,0 @@ - - */ -final class RoleEntityTypeSpec extends ObjectBehavior -{ - function let(MetadataInterface $metadata) - { - $this->beConstructedWith($metadata); - } - - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Bundle\RbacBundle\Form\Type\RoleEntityType'); - } - - function it_is_a_form() - { - $this->shouldHaveType(ResourceChoiceType::class); - } - - function it_has_options(OptionsResolver $resolver, $metadata) - { - $metadata->getDriver()->willReturn(SyliusResourceBundle::DRIVER_DOCTRINE_ORM); - $resolver->setDefaults(Argument::withKey('class'))->shouldBeCalled()->willReturn($resolver); - $resolver->setNormalizer('class', Argument::type('callable'))->shouldBeCalled()->willReturn($resolver); - $resolver->setDefaults(Argument::withKey('query_builder'))->shouldBeCalled()->willReturn($resolver); - - $this->configureOptions($resolver); - } -} diff --git a/src/Sylius/Bundle/RbacBundle/spec/Form/Type/RoleTypeSpec.php b/src/Sylius/Bundle/RbacBundle/spec/Form/Type/RoleTypeSpec.php deleted file mode 100644 index 7ab956932d..0000000000 --- a/src/Sylius/Bundle/RbacBundle/spec/Form/Type/RoleTypeSpec.php +++ /dev/null @@ -1,94 +0,0 @@ - - */ -final class RoleTypeSpec extends ObjectBehavior -{ - function let() - { - $this->beConstructedWith('Role', ['sylius']); - } - - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Bundle\RbacBundle\Form\Type\RoleType'); - } - - function it_is_a_form_type() - { - $this->shouldImplement(FormTypeInterface::class); - } - - function it_should_build_form_with_proper_fields(FormBuilder $builder) - { - $builder - ->add('name', 'text', Argument::any()) - ->willReturn($builder) - ; - - $builder - ->add('description', 'textarea', Argument::any()) - ->willReturn($builder) - ; - $builder - ->add('securityRoles', 'sylius_security_role_choice', Argument::any()) - ->willReturn($builder) - ; - - $builder - ->add('permissions', 'sylius_permission_choice', Argument::any()) - ->willReturn($builder) - ; - - $builder - ->addEventSubscriber(Argument::type(AddCodeFormSubscriber::class)) - ->shouldBeCalled() - ->willReturn($builder) - ; - - $builder - ->addEventSubscriber(Argument::type(AddParentFormSubscriber::class)) - ->shouldBeCalled() - ->willReturn($builder) - ; - - $this->buildForm($builder, []); - } - - function it_should_define_assigned_data_class_and_validation_groups(OptionsResolver $resolver) - { - $resolver - ->setDefaults([ - 'data_class' => 'Role', - 'validation_groups' => ['sylius'], - ]) - ->shouldBeCalled(); - - $this->configureOptions($resolver); - } - - function it_has_valid_name() - { - $this->getName()->shouldReturn('sylius_role'); - } -} diff --git a/src/Sylius/Bundle/RbacBundle/spec/Form/Type/SecurityRoleChoiceTypeSpec.php b/src/Sylius/Bundle/RbacBundle/spec/Form/Type/SecurityRoleChoiceTypeSpec.php deleted file mode 100644 index 16b08292bb..0000000000 --- a/src/Sylius/Bundle/RbacBundle/spec/Form/Type/SecurityRoleChoiceTypeSpec.php +++ /dev/null @@ -1,62 +0,0 @@ - - */ -final class SecurityRoleChoiceTypeSpec extends ObjectBehavior -{ - function let() - { - $this->beConstructedWith([ - 'key' => 'role', - ]); - } - - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Bundle\RbacBundle\Form\Type\SecurityRoleChoiceType'); - } - - function it_is_a_form() - { - $this->shouldHaveType(AbstractType::class); - } - - function it_has_options(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'choices' => [ - 'key' => 'role', - ], - 'multiple' => true, - 'expanded' => true, - ])->shouldBeCalled(); - - $this->configureOptions($resolver); - } - - function it_has_a_parent() - { - $this->getParent()->shouldReturn('choice'); - } - - function it_has_a_name() - { - $this->getName()->shouldReturn('sylius_security_role_choice'); - } -} diff --git a/src/Sylius/Bundle/RbacBundle/spec/Provider/SecurityIdentityProviderSpec.php b/src/Sylius/Bundle/RbacBundle/spec/Provider/SecurityIdentityProviderSpec.php deleted file mode 100644 index de433fa042..0000000000 --- a/src/Sylius/Bundle/RbacBundle/spec/Provider/SecurityIdentityProviderSpec.php +++ /dev/null @@ -1,82 +0,0 @@ - - */ -final class SecurityIdentityProviderSpec extends ObjectBehavior -{ - function let(TokenStorageInterface $tokenStorage) - { - $this->beConstructedWith($tokenStorage); - } - - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Bundle\RbacBundle\Provider\SecurityIdentityProvider'); - } - - function it_is_a_rbac_identity_provider() - { - $this->shouldHaveType(CurrentIdentityProviderInterface::class); - } - - function it_returns_null_if_user_is_not_logged_in($tokenStorage) - { - $tokenStorage->getToken()->shouldBeCalled()->willReturn(null); - - $this->getIdentity()->shouldReturn(null); - } - - function it_returns_null_if_token_exists_but_still_no_authenticated_user($tokenStorage, TokenInterface $token) - { - $tokenStorage->getToken()->shouldBeCalled()->willReturn($token); - $token->getUser()->shouldBeCalled()->willReturn(null); - - $this->getIdentity()->shouldReturn(null); - } - - function it_returns_null_if_token_exists_but_its_an_anonymous_user($tokenStorage, AnonymousToken $token) - { - $tokenStorage->getToken()->shouldBeCalled()->willReturn($token); - - $this->getIdentity()->shouldReturn(null); - } - - function it_returns_the_authenticated_user($tokenStorage, TokenInterface $token, IdentityInterface $user) - { - $tokenStorage->getToken()->shouldBeCalled()->willReturn($token); - $token->getUser()->shouldBeCalled()->willReturn($user); - - $this->getIdentity()->shouldReturn($user); - } - - function it_throws_exception_if_user_does_not_implement_identity_interface($tokenStorage, TokenInterface $token, UserInterface $user) - { - $tokenStorage->getToken()->shouldBeCalled()->willReturn($token); - $token->getUser()->shouldBeCalled()->willReturn($user); - - $this - ->shouldThrow(new \InvalidArgumentException('User class must implement "Sylius\Component\Rbac\Model\IdentityInterface".')) - ->duringGetIdentity() - ; - } -} diff --git a/src/Sylius/Bundle/RbacBundle/spec/Templating/Helper/RbacHelperSpec.php b/src/Sylius/Bundle/RbacBundle/spec/Templating/Helper/RbacHelperSpec.php deleted file mode 100644 index b76826dbd9..0000000000 --- a/src/Sylius/Bundle/RbacBundle/spec/Templating/Helper/RbacHelperSpec.php +++ /dev/null @@ -1,46 +0,0 @@ - - */ -final class RbacHelperSpec extends ObjectBehavior -{ - function let(AuthorizationCheckerInterface $authorizationChecker) - { - $this->beConstructedWith($authorizationChecker); - } - - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Bundle\RbacBundle\Templating\Helper\RbacHelper'); - } - - function it_is_a_Twig_extension() - { - $this->shouldHaveType(Helper::class); - } - - function it_uses_authorization_checker_to_verify_permissions($authorizationChecker) - { - $authorizationChecker->isGranted('can_block_users')->shouldBeCalled()->willReturn(true); - $this->isGranted('can_block_users')->shouldReturn(true); - - $authorizationChecker->isGranted('can_eat_bananas')->shouldBeCalled()->willReturn(false); - $this->isGranted('can_eat_bananas')->shouldReturn(false); - } -} diff --git a/src/Sylius/Bundle/RbacBundle/spec/Twig/RbacExtensionSpec.php b/src/Sylius/Bundle/RbacBundle/spec/Twig/RbacExtensionSpec.php deleted file mode 100644 index 9048a3664e..0000000000 --- a/src/Sylius/Bundle/RbacBundle/spec/Twig/RbacExtensionSpec.php +++ /dev/null @@ -1,36 +0,0 @@ - - */ -final class RbacExtensionSpec extends ObjectBehavior -{ - function let(RbacHelper $helper) - { - $this->beConstructedWith($helper); - } - - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Bundle\RbacBundle\Twig\RbacExtension'); - } - - function it_is_a_Twig_extension() - { - $this->shouldHaveType('Twig_Extension'); - } -} diff --git a/src/Sylius/Component/Core/Model/AdminUser.php b/src/Sylius/Component/Core/Model/AdminUser.php index dd7ad8cea7..a8fa208371 100644 --- a/src/Sylius/Component/Core/Model/AdminUser.php +++ b/src/Sylius/Component/Core/Model/AdminUser.php @@ -11,8 +11,6 @@ namespace Sylius\Component\Core\Model; -use Doctrine\Common\Collections\ArrayCollection; -use Sylius\Component\Rbac\Model\RoleInterface; use Sylius\Component\User\Model\User; /** @@ -20,11 +18,6 @@ use Sylius\Component\User\Model\User; */ class AdminUser extends User implements AdminUserInterface { - /** - * @var ArrayCollection - */ - protected $authorizationRoles; - /** * @var string */ @@ -40,63 +33,6 @@ class AdminUser extends User implements AdminUserInterface */ protected $roles = [AdminUserInterface::DEFAULT_ADMIN_ROLE]; - public function __construct() - { - parent::__construct(); - - $this->authorizationRoles = new ArrayCollection(); - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationRoles() - { - return $this->authorizationRoles; - } - - /** - * {@inheritdoc} - */ - public function addAuthorizationRole(RoleInterface $role) - { - if (!$this->hasAuthorizationRole($role)) { - $this->authorizationRoles->add($role); - } - } - - /** - * {@inheritdoc} - */ - public function removeAuthorizationRole(RoleInterface $role) - { - if ($this->hasAuthorizationRole($role)) { - $this->authorizationRoles->removeElement($role); - } - } - - /** - * {@inheritdoc} - */ - public function hasAuthorizationRole(RoleInterface $role) - { - return $this->authorizationRoles->contains($role); - } - - /** - * {@inheritdoc} - */ - public function getRoles() - { - $roles = parent::getRoles(); - - foreach ($this->getAuthorizationRoles() as $role) { - $roles = array_merge($roles, $role->getSecurityRoles()); - } - - return $roles; - } - /** * @return string */ diff --git a/src/Sylius/Component/Core/Model/AdminUserInterface.php b/src/Sylius/Component/Core/Model/AdminUserInterface.php index 572d1ee38f..561508328d 100644 --- a/src/Sylius/Component/Core/Model/AdminUserInterface.php +++ b/src/Sylius/Component/Core/Model/AdminUserInterface.php @@ -11,31 +11,12 @@ namespace Sylius\Component\Core\Model; -use Sylius\Component\Rbac\Model\IdentityInterface; -use Sylius\Component\Rbac\Model\RoleInterface; use Sylius\Component\User\Model\UserInterface as BaseUserInterface; /** * @author Arkadiusz Krakowiak */ -interface AdminUserInterface extends BaseUserInterface, IdentityInterface +interface AdminUserInterface extends BaseUserInterface { const DEFAULT_ADMIN_ROLE = 'ROLE_ADMINISTRATION_ACCESS'; - - /** - * @param RoleInterface $role - */ - public function addAuthorizationRole(RoleInterface $role); - - /** - * @param RoleInterface $role - */ - public function removeAuthorizationRole(RoleInterface $role); - - /** - * @param RoleInterface $role - * - * @return bool - */ - public function hasAuthorizationRole(RoleInterface $role); } diff --git a/src/Sylius/Component/Core/Model/ShopUser.php b/src/Sylius/Component/Core/Model/ShopUser.php index 441bf53e0f..ffd44a872e 100644 --- a/src/Sylius/Component/Core/Model/ShopUser.php +++ b/src/Sylius/Component/Core/Model/ShopUser.php @@ -11,9 +11,7 @@ namespace Sylius\Component\Core\Model; -use Doctrine\Common\Collections\ArrayCollection; use Sylius\Component\Customer\Model\CustomerInterface as BaseCustomerInterface; -use Sylius\Component\Rbac\Model\RoleInterface; use Sylius\Component\User\Model\User as BaseUser; /** @@ -22,72 +20,11 @@ use Sylius\Component\User\Model\User as BaseUser; */ class ShopUser extends BaseUser implements ShopUserInterface { - /** - * @var ArrayCollection - */ - protected $authorizationRoles; - /** * @var CustomerInterface */ protected $customer; - public function __construct() - { - parent::__construct(); - $this->authorizationRoles = new ArrayCollection(); - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationRoles() - { - return $this->authorizationRoles; - } - - /** - * {@inheritdoc} - */ - public function addAuthorizationRole(RoleInterface $role) - { - if (!$this->hasAuthorizationRole($role)) { - $this->authorizationRoles->add($role); - } - } - - /** - * {@inheritdoc} - */ - public function removeAuthorizationRole(RoleInterface $role) - { - if ($this->hasAuthorizationRole($role)) { - $this->authorizationRoles->removeElement($role); - } - } - - /** - * {@inheritdoc} - */ - public function hasAuthorizationRole(RoleInterface $role) - { - return $this->authorizationRoles->contains($role); - } - - /** - * {@inheritdoc} - */ - public function getRoles() - { - $roles = parent::getRoles(); - - foreach ($this->getAuthorizationRoles() as $role) { - $roles = array_merge($roles, $role->getSecurityRoles()); - } - - return $roles; - } - /** * {@inheritdoc} */ @@ -121,6 +58,7 @@ class ShopUser extends BaseUser implements ShopUserInterface { $this->customer->setEmail($email); } + /** * {@inheritdoc} */ @@ -128,6 +66,7 @@ class ShopUser extends BaseUser implements ShopUserInterface { return $this->customer->getEmailCanonical(); } + /** * {@inheritdoc} */ diff --git a/src/Sylius/Component/Core/Model/ShopUserInterface.php b/src/Sylius/Component/Core/Model/ShopUserInterface.php index 8d2daf53e4..82f5c61188 100644 --- a/src/Sylius/Component/Core/Model/ShopUserInterface.php +++ b/src/Sylius/Component/Core/Model/ShopUserInterface.php @@ -12,29 +12,11 @@ namespace Sylius\Component\Core\Model; use Sylius\Component\Customer\Model\CustomerAwareInterface; -use Sylius\Component\Rbac\Model\IdentityInterface; -use Sylius\Component\Rbac\Model\RoleInterface; use Sylius\Component\User\Model\UserInterface as BaseUserInterface; /** * @author Paweł Jędrzejewski */ -interface ShopUserInterface extends BaseUserInterface, IdentityInterface, CustomerAwareInterface +interface ShopUserInterface extends BaseUserInterface, CustomerAwareInterface { - /** - * @param RoleInterface $role - */ - public function addAuthorizationRole(RoleInterface $role); - - /** - * @param RoleInterface $role - */ - public function removeAuthorizationRole(RoleInterface $role); - - /** - * @param RoleInterface $role - * - * @return bool - */ - public function hasAuthorizationRole(RoleInterface $role); } diff --git a/src/Sylius/Component/Core/spec/Model/AdminUserSpec.php b/src/Sylius/Component/Core/spec/Model/AdminUserSpec.php index f70a435f0c..6bff8d0958 100644 --- a/src/Sylius/Component/Core/spec/Model/AdminUserSpec.php +++ b/src/Sylius/Component/Core/spec/Model/AdminUserSpec.php @@ -45,19 +45,6 @@ class AdminUserSpec extends ObjectBehavior $this->shouldImplement(UserInterface::class); } - function its_authorization_roles_are_mutable(RoleInterface $role) - { - $this->addAuthorizationRole($role); - $this->hasAuthorizationRole($role)->shouldReturn(true); - } - - function its_authorization_role_can_be_removed(RoleInterface $role) - { - $this->addAuthorizationRole($role); - $this->removeAuthorizationRole($role); - $this->hasAuthorizationRole($role)->shouldReturn(false); - } - function it_has_first_name_and_last_name() { $this->setFirstName('John'); diff --git a/src/Sylius/Component/Core/spec/Model/ShopUserSpec.php b/src/Sylius/Component/Core/spec/Model/ShopUserSpec.php index 2033a353c6..d415824efb 100644 --- a/src/Sylius/Component/Core/spec/Model/ShopUserSpec.php +++ b/src/Sylius/Component/Core/spec/Model/ShopUserSpec.php @@ -31,17 +31,4 @@ final class ShopUserSpec extends ObjectBehavior { $this->shouldImplement(ShopUserInterface::class); } - - function its_authorization_roles_are_mutable(RoleInterface $role) - { - $this->addAuthorizationRole($role); - $this->hasAuthorizationRole($role)->shouldReturn(true); - } - - function its_authorization_role_can_be_removed(RoleInterface $role) - { - $this->addAuthorizationRole($role); - $this->removeAuthorizationRole($role); - $this->hasAuthorizationRole($role)->shouldReturn(false); - } } diff --git a/src/Sylius/Component/Rbac/.gitignore b/src/Sylius/Component/Rbac/.gitignore deleted file mode 100644 index 46aed33710..0000000000 --- a/src/Sylius/Component/Rbac/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -vendor/ -bin/ - -composer.phar -composer.lock diff --git a/src/Sylius/Component/Rbac/Authorization/AuthorizationChecker.php b/src/Sylius/Component/Rbac/Authorization/AuthorizationChecker.php deleted file mode 100644 index 862acaac14..0000000000 --- a/src/Sylius/Component/Rbac/Authorization/AuthorizationChecker.php +++ /dev/null @@ -1,80 +0,0 @@ - - */ -class AuthorizationChecker implements AuthorizationCheckerInterface -{ - /** - * @var CurrentIdentityProviderInterface - */ - protected $currentIdentityProvider; - - /** - * @var PermissionMapInterface - */ - protected $permissionMap; - - /** - * @var RolesResolverInterface - */ - protected $rolesResolver; - - /** - * @param CurrentIdentityProviderInterface $currentIdentityProvider - * @param PermissionMapInterface $permissionMap - * @param RolesResolverInterface $rolesResolver - */ - public function __construct( - CurrentIdentityProviderInterface $currentIdentityProvider, - PermissionMapInterface $permissionMap, - RolesResolverInterface $rolesResolver - ) { - $this->currentIdentityProvider = $currentIdentityProvider; - $this->permissionMap = $permissionMap; - $this->rolesResolver = $rolesResolver; - } - - /** - * {@inheritdoc} - */ - public function isGranted($permissionCode) - { - $identity = $this->currentIdentityProvider->getIdentity(); - - if (null === $identity) { - return false; - } - - if (!$identity instanceof IdentityInterface) { - throw new \InvalidArgumentException('Current identity must implement "Sylius\Component\Rbac\Model\IdentityInterface".'); - } - - $roles = $this->rolesResolver->getRoles($identity); - - foreach ($roles as $role) { - if ($this->permissionMap->hasPermission($role, $permissionCode)) { - return true; - } - } - - return false; - } -} diff --git a/src/Sylius/Component/Rbac/Authorization/AuthorizationCheckerInterface.php b/src/Sylius/Component/Rbac/Authorization/AuthorizationCheckerInterface.php deleted file mode 100644 index 38255f9e6a..0000000000 --- a/src/Sylius/Component/Rbac/Authorization/AuthorizationCheckerInterface.php +++ /dev/null @@ -1,27 +0,0 @@ - - */ -interface AuthorizationCheckerInterface -{ - /** - * @param string $permissionCode - * - * @return bool - */ - public function isGranted($permissionCode); -} diff --git a/src/Sylius/Component/Rbac/Authorization/CachedPermissionMap.php b/src/Sylius/Component/Rbac/Authorization/CachedPermissionMap.php deleted file mode 100644 index 943c1bb7c3..0000000000 --- a/src/Sylius/Component/Rbac/Authorization/CachedPermissionMap.php +++ /dev/null @@ -1,92 +0,0 @@ - - */ -class CachedPermissionMap implements PermissionMapInterface -{ - const DEFAULT_TTL = 60; - const CACHE_KEY_PREFIX = 'rbac_role:'; - - /** - * @var PermissionMapInterface - */ - protected $map; - - /** - * @var Cache - */ - protected $cache; - - /** - * @var int - */ - protected $ttl; - - /** - * @param PermissionMapInterface $map - * @param Cache $cache - * @param int $ttl - */ - public function __construct(PermissionMapInterface $map, Cache $cache, $ttl = self::DEFAULT_TTL) - { - $this->map = $map; - $this->cache = $cache; - $this->ttl = $ttl; - } - - /** - * {@inheritdoc} - */ - public function hasPermission(RoleInterface $role, $permissionCode) - { - if ($this->cache->contains($this->getCacheKey($role))) { - return in_array($permissionCode, $this->cache->fetch($this->getCacheKey($role))); - } - - $permissions = $this->map->getPermissions($role); - $permissionsCache = []; - - foreach ($permissions as $permission) { - $permissionsCache[] = $permission->getCode(); - } - - $this->cache->save($this->getCacheKey($role), $permissionsCache, $this->ttl); - - return in_array($permissionCode, $permissionsCache); - } - - /** - * {@inheritdoc} - */ - public function getPermissions(RoleInterface $role) - { - return $this->map->getPermissions($role); - } - - /** - * @param RoleInterface $role - * - * @return string - */ - private function getCacheKey(RoleInterface $role) - { - return self::CACHE_KEY_PREFIX . $role->getCode(); - } -} diff --git a/src/Sylius/Component/Rbac/Authorization/PermissionMap.php b/src/Sylius/Component/Rbac/Authorization/PermissionMap.php deleted file mode 100644 index 2e28976725..0000000000 --- a/src/Sylius/Component/Rbac/Authorization/PermissionMap.php +++ /dev/null @@ -1,95 +0,0 @@ - - */ -class PermissionMap implements PermissionMapInterface -{ - /** - * @var PermissionProviderInterface - */ - protected $permissionProvider; - - /** - * @var PermissionsResolverInterface - */ - protected $permissionsResolver; - - /** - * Cache. - * - * @var array - */ - private $permissions = []; - - /** - * @param PermissionProviderInterface $permissionProvider - * @param PermissionsResolverInterface $permissionsResolver - */ - public function __construct( - PermissionProviderInterface $permissionProvider, - PermissionsResolverInterface $permissionsResolver - ) { - $this->permissionProvider = $permissionProvider; - $this->permissionsResolver = $permissionsResolver; - } - - /** - * {@inheritdoc} - */ - public function hasPermission(RoleInterface $role, $permissionCode) - { - $permission = $this->getPermission($permissionCode); - - if (null === $permission) { - return false; - } - - return $this->getPermissions($role)->contains($permission); - } - - /** - * {@inheritdoc} - */ - public function getPermissions(RoleInterface $role) - { - return $this->permissionsResolver->getPermissions($role); - } - - /** - * @param string $code - * - * @return null|PermissionInterface - */ - private function getPermission($code) - { - if (isset($this->permissions[$code])) { - return $this->permissions[$code]; - } - - try { - return $this->permissionProvider->getPermission($code); - } catch (PermissionNotFoundException $exception) { - return null; - } - } -} diff --git a/src/Sylius/Component/Rbac/Authorization/PermissionMapInterface.php b/src/Sylius/Component/Rbac/Authorization/PermissionMapInterface.php deleted file mode 100644 index 77e72b2661..0000000000 --- a/src/Sylius/Component/Rbac/Authorization/PermissionMapInterface.php +++ /dev/null @@ -1,38 +0,0 @@ - - */ -interface PermissionMapInterface -{ - /** - * @param RoleInterface $role - * @param string $permissionCode - * - * @return bool - */ - public function hasPermission(RoleInterface $role, $permissionCode); - - /** - * @param RoleInterface $role - * - * @return Collection - */ - public function getPermissions(RoleInterface $role); -} diff --git a/src/Sylius/Component/Rbac/CHANGELOG.md b/src/Sylius/Component/Rbac/CHANGELOG.md deleted file mode 100644 index e9c097488d..0000000000 --- a/src/Sylius/Component/Rbac/CHANGELOG.md +++ /dev/null @@ -1,6 +0,0 @@ -CHANGELOG -========= - -### v0.15.0 - -* Initial dev release. diff --git a/src/Sylius/Component/Rbac/Exception/PermissionNotFoundException.php b/src/Sylius/Component/Rbac/Exception/PermissionNotFoundException.php deleted file mode 100644 index c9fd5e5131..0000000000 --- a/src/Sylius/Component/Rbac/Exception/PermissionNotFoundException.php +++ /dev/null @@ -1,25 +0,0 @@ - - */ -class PermissionNotFoundException extends \Exception -{ - public function __construct($permission) - { - parent::__construct(sprintf('Permission "%s" does not exist!', $permission)); - } -} diff --git a/src/Sylius/Component/Rbac/LICENSE b/src/Sylius/Component/Rbac/LICENSE deleted file mode 100644 index acd4c1958c..0000000000 --- a/src/Sylius/Component/Rbac/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2011-2016 Paweł Jędrzejewski - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/src/Sylius/Component/Rbac/Model/IdentityInterface.php b/src/Sylius/Component/Rbac/Model/IdentityInterface.php deleted file mode 100644 index 28627cf2fd..0000000000 --- a/src/Sylius/Component/Rbac/Model/IdentityInterface.php +++ /dev/null @@ -1,27 +0,0 @@ - - */ -interface IdentityInterface -{ - /** - * Get roles. - * - * @return RoleInterface[] - */ - public function getAuthorizationRoles(); -} diff --git a/src/Sylius/Component/Rbac/Model/Permission.php b/src/Sylius/Component/Rbac/Model/Permission.php deleted file mode 100644 index df8122b67e..0000000000 --- a/src/Sylius/Component/Rbac/Model/Permission.php +++ /dev/null @@ -1,233 +0,0 @@ - - */ -class Permission implements PermissionInterface -{ - use TimestampableTrait; - - /** - * @var mixed - */ - protected $id; - - /** - * @var string - */ - protected $code; - - /** - * @var string - */ - protected $description; - - /** - * @var null|PermissionInterface - */ - protected $parent; - - /** - * @var Collection|PermissionInterface[] - */ - protected $children; - - /** - * Required by DoctrineExtensions. - * - * @var int - */ - protected $left; - - /** - * Required by DoctrineExtensions. - * - * @var int - */ - protected $right; - - /** - * Required by DoctrineExtensions. - * - * @var int - */ - protected $level; - - public function __construct() - { - $this->children = new ArrayCollection(); - $this->createdAt = new \DateTime(); - } - - public function __toString() - { - return $this->description; - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->id; - } - - /** - * {@inheritdoc} - */ - public function getCode() - { - return $this->code; - } - - /** - * {@inheritdoc} - */ - public function setCode($code) - { - $this->code = $code; - } - - /** - * {@inheritdoc} - */ - public function getDescription() - { - return $this->description; - } - - /** - * {@inheritdoc} - */ - public function setDescription($description) - { - $this->description = $description; - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return $this->parent; - } - - /** - * {@inheritdoc} - */ - public function setParent(PermissionInterface $permission = null) - { - $this->parent = $permission; - } - - /** - * {@inheritdoc} - */ - public function getChildren() - { - return $this->children; - } - - /** - * {@inheritdoc} - */ - public function hasChildren() - { - return !$this->children->isEmpty(); - } - - /** - * {@inheritdoc} - */ - public function addChild(PermissionInterface $permission) - { - if (!$this->hasChild($permission)) { - $permission->setParent($this); - $this->children->add($permission); - } - } - - /** - * {@inheritdoc} - */ - public function removeChild(PermissionInterface $permission) - { - if ($this->hasChild($permission)) { - $permission->setParent(null); - $this->children->removeElement($permission); - } - } - - /** - * {@inheritdoc} - */ - public function hasChild(PermissionInterface $permission) - { - return $this->children->contains($permission); - } - - /** - * {@inheritdoc} - */ - public function getLeft() - { - return $this->left; - } - - /** - * {@inheritdoc} - */ - public function setLeft($left) - { - $this->left = $left; - } - - /** - * {@inheritdoc} - */ - public function getRight() - { - return $this->right; - } - - /** - * {@inheritdoc} - */ - public function setRight($right) - { - $this->right = $right; - } - - /** - * {@inheritdoc} - */ - public function getLevel() - { - return $this->level; - } - - /** - * {@inheritdoc} - */ - public function setLevel($level) - { - $this->level = $level; - } -} diff --git a/src/Sylius/Component/Rbac/Model/PermissionInterface.php b/src/Sylius/Component/Rbac/Model/PermissionInterface.php deleted file mode 100644 index 4cf01a83f3..0000000000 --- a/src/Sylius/Component/Rbac/Model/PermissionInterface.php +++ /dev/null @@ -1,102 +0,0 @@ - - */ -interface PermissionInterface extends CodeAwareInterface, TimestampableInterface, ResourceInterface -{ - /** - * @return string - */ - public function getDescription(); - - /** - * @param string $description - */ - public function setDescription($description); - - /** - * @return null|PermissionInterface - */ - public function getParent(); - - /** - * @param PermissionInterface $permission - */ - public function setParent(PermissionInterface $permission); - - /** - * @return Collection|PermissionInterface[] - */ - public function getChildren(); - - /** - * @return bool - */ - public function hasChildren(); - - /** - * @param PermissionInterface $permission - */ - public function addChild(PermissionInterface $permission); - - /** - * @param PermissionInterface $permission - */ - public function removeChild(PermissionInterface $permission); - - /** - * @param PermissionInterface $permission - * - * @return bool - */ - public function hasChild(PermissionInterface $permission); - - /** - * @return int - */ - public function getLeft(); - - /** - * @param int $left - */ - public function setLeft($left); - - /** - * @return int - */ - public function getRight(); - - /** - * @param int $right - */ - public function setRight($right); - - /** - * @return int - */ - public function getLevel(); - - /** - * @param int $level - */ - public function setLevel($level); -} diff --git a/src/Sylius/Component/Rbac/Model/Role.php b/src/Sylius/Component/Rbac/Model/Role.php deleted file mode 100644 index 23f99661e2..0000000000 --- a/src/Sylius/Component/Rbac/Model/Role.php +++ /dev/null @@ -1,320 +0,0 @@ - - */ -class Role implements RoleInterface -{ - use TimestampableTrait; - - /** - * @var mixed - */ - protected $id; - - /** - * @var string - */ - protected $code; - - /** - * @var string - */ - protected $name; - - /** - * @var string - */ - protected $description; - - /** - * @var null|RoleInterface - */ - protected $parent; - - /** - * @var Collection|RoleInterface[] - */ - protected $children; - - /** - * Required by DoctrineExtensions. - * - * @var int - */ - protected $left; - - /** - * Required by DoctrineExtensions. - * - * @var int - */ - protected $right; - - /** - * Required by DoctrineExtensions. - * - * @var int - */ - protected $level; - - /** - * @var Collection|PermissionInterface[] - */ - protected $permissions; - - /** - * @var array - */ - protected $securityRoles = []; - - public function __construct() - { - $this->children = new ArrayCollection(); - $this->permissions = new ArrayCollection(); - $this->createdAt = new \DateTime(); - } - - /** - * {@inheritdoc} - */ - public function __toString() - { - return $this->name; - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->id; - } - - /** - * {@inheritdoc} - */ - public function getCode() - { - return $this->code; - } - - /** - * {@inheritdoc} - */ - public function setCode($code) - { - $this->code = $code; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - /** - * {@inheritdoc} - */ - public function setName($name) - { - $this->name = $name; - } - - /** - * {@inheritdoc} - */ - public function getDescription() - { - return $this->description; - } - - /** - * {@inheritdoc} - */ - public function setDescription($description) - { - $this->description = $description; - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return $this->parent; - } - - /** - * {@inheritdoc} - */ - public function setParent(RoleInterface $role = null) - { - $this->parent = $role; - } - - /** - * {@inheritdoc} - */ - public function getChildren() - { - return $this->children; - } - - /** - * {@inheritdoc} - */ - public function hasChildren() - { - return !$this->children->isEmpty(); - } - - /** - * {@inheritdoc} - */ - public function addChild(RoleInterface $role) - { - if (!$this->hasChild($role)) { - $role->setParent($this); - $this->children->add($role); - } - } - - /** - * {@inheritdoc} - */ - public function removeChild(RoleInterface $role) - { - if ($this->hasChild($role)) { - $role->setParent(null); - $this->children->removeElement($role); - } - } - - /** - * {@inheritdoc} - */ - public function hasChild(RoleInterface $role) - { - return $this->children->contains($role); - } - - /** - * {@inheritdoc} - */ - public function getLeft() - { - return $this->left; - } - - /** - * {@inheritdoc} - */ - public function setLeft($left) - { - $this->left = $left; - } - - /** - * {@inheritdoc} - */ - public function getRight() - { - return $this->right; - } - - /** - * {@inheritdoc} - */ - public function setRight($right) - { - $this->right = $right; - } - - /** - * {@inheritdoc} - */ - public function getLevel() - { - return $this->level; - } - - /** - * {@inheritdoc} - */ - public function setLevel($level) - { - $this->level = $level; - } - - /** - * {@inheritdoc} - */ - public function getPermissions() - { - return $this->permissions; - } - - /** - * {@inheritdoc} - */ - public function addPermission(PermissionInterface $permission) - { - if (!$this->hasPermission($permission)) { - $this->permissions->add($permission); - } - } - - /** - * {@inheritdoc} - */ - public function removePermission(PermissionInterface $permission) - { - if ($this->hasPermission($permission)) { - $this->permissions->removeElement($permission); - } - } - - /** - * {@inheritdoc} - */ - public function hasPermission(PermissionInterface $permission) - { - return $this->permissions->contains($permission); - } - - /** - * {@inheritdoc} - */ - public function getSecurityRoles() - { - return $this->securityRoles; - } - - /** - * {@inheritdoc} - */ - public function setSecurityRoles(array $securityRoles) - { - $this->securityRoles = $securityRoles; - } -} diff --git a/src/Sylius/Component/Rbac/Model/RoleInterface.php b/src/Sylius/Component/Rbac/Model/RoleInterface.php deleted file mode 100644 index e3f74a8d38..0000000000 --- a/src/Sylius/Component/Rbac/Model/RoleInterface.php +++ /dev/null @@ -1,134 +0,0 @@ - - */ -interface RoleInterface extends CodeAwareInterface, TimestampableInterface, ResourceInterface -{ - /** - * @return string - */ - public function getName(); - - /** - * @param string $name - */ - public function setName($name); - - /** - * @return string - */ - public function getDescription(); - - /** - * @param string $description - */ - public function setDescription($description); - - /** - * @return Collection|PermissionInterface[] - */ - public function getPermissions(); - - /** - * @param PermissionInterface $permission - */ - public function addPermission(PermissionInterface $permission); - - /** - * @param PermissionInterface $permission - */ - public function removePermission(PermissionInterface $permission); - - /** - * @param PermissionInterface $permission - * - * @return bool - */ - public function hasPermission(PermissionInterface $permission); - - /** - * @return null|RoleInterface - */ - public function getParent(); - - /** - * @param RoleInterface $role - */ - public function setParent(RoleInterface $role); - - /** - * @return Collection|RoleInterface[] - */ - public function getChildren(); - - /** - * @return bool - */ - public function hasChildren(); - - /** - * @param RoleInterface $role - */ - public function addChild(RoleInterface $role); - - /** - * @param RoleInterface $role - */ - public function removeChild(RoleInterface $role); - - /** - * @param RoleInterface $role - * - * @return bool - */ - public function hasChild(RoleInterface $role); - - /** - * @return int - */ - public function getLeft(); - - /** - * @param int $left - */ - public function setLeft($left); - - /** - * @return int - */ - public function getRight(); - - /** - * @param int $right - */ - public function setRight($right); - - /** - * @return int - */ - public function getLevel(); - - /** - * @param int $level - */ - public function setLevel($level); -} diff --git a/src/Sylius/Component/Rbac/Provider/CurrentIdentityProviderInterface.php b/src/Sylius/Component/Rbac/Provider/CurrentIdentityProviderInterface.php deleted file mode 100644 index 3ad8f4e5f0..0000000000 --- a/src/Sylius/Component/Rbac/Provider/CurrentIdentityProviderInterface.php +++ /dev/null @@ -1,29 +0,0 @@ - - */ -interface CurrentIdentityProviderInterface -{ - /** - * Get the identity. - * - * @return IdentityInterface - */ - public function getIdentity(); -} diff --git a/src/Sylius/Component/Rbac/Provider/PermissionProvider.php b/src/Sylius/Component/Rbac/Provider/PermissionProvider.php deleted file mode 100644 index a591bad343..0000000000 --- a/src/Sylius/Component/Rbac/Provider/PermissionProvider.php +++ /dev/null @@ -1,48 +0,0 @@ - - */ -class PermissionProvider implements PermissionProviderInterface -{ - /** - * @var RepositoryInterface - */ - protected $repository; - - /** - * @param RepositoryInterface $repository - */ - public function __construct(RepositoryInterface $repository) - { - $this->repository = $repository; - } - - /** - * {@inheritdoc} - */ - public function getPermission($code) - { - if (null === $permission = $this->repository->findOneBy(['code' => $code])) { - throw new PermissionNotFoundException($code); - } - - return $permission; - } -} diff --git a/src/Sylius/Component/Rbac/Provider/PermissionProviderInterface.php b/src/Sylius/Component/Rbac/Provider/PermissionProviderInterface.php deleted file mode 100644 index da7bcb33fe..0000000000 --- a/src/Sylius/Component/Rbac/Provider/PermissionProviderInterface.php +++ /dev/null @@ -1,34 +0,0 @@ - - */ -interface PermissionProviderInterface -{ - /** - * Get the permission instance by code. - * - * @param string $code - * - * @return PermissionInterface - * - * @throws PermissionNotFoundException When permission does not exist in the system - */ - public function getPermission($code); -} diff --git a/src/Sylius/Component/Rbac/README.md b/src/Sylius/Component/Rbac/README.md deleted file mode 100644 index 58e35a3a5a..0000000000 --- a/src/Sylius/Component/Rbac/README.md +++ /dev/null @@ -1,47 +0,0 @@ -Rbac Component [![Build status...](https://secure.travis-ci.org/Sylius/Rbac.png?branch=master)](http://travis-ci.org/Sylius/Rbac) -============== - -Role-Based-Access-Control for PHP applications. - -Sylius ------- - -Modern ecommerce for PHP and Symfony2. Visit [Sylius.org](http://sylius.org). - -Documentation -------------- - -Documentation is available on [**docs.sylius.org**](http://docs.sylius.org/en/latest/components/Rbac/index.html). - -Contributing ------------- - -All instructions for contributing to Sylius can be found in the [Contributing Guide](http://docs.sylius.org/en/latest/contributing/index.html). - -Support -------- - -If you have a question regarding the usage of this library, please ask on -[Stackoverflow](http://stackoverflow.com). You should use "sylius" -tag when posting and make sure to [browse existing questions](http://stackoverflow.com/questions/tagged/sylius). - -Sylius on Twitter ------------------ - -[Follow the official Sylius account on Twitter!](http://twitter.com/Sylius). - -Bug Tracking ------------- - -If you find a bug, please refer to the [Reporting a Bug](http://docs.sylius.org/en/latest/contributing/code/bugs.html) guide. - -MIT License ------------ - -License can be found [here](https://github.com/Sylius/Rbac/blob/master/LICENSE). - -Authors -------- - -The component was originally created by [Paweł Jędrzejewski](http://pjedrzejewski.com). -See the list of [contributors](https://github.com/Sylius/Rbac/contributors). diff --git a/src/Sylius/Component/Rbac/Repository/PermissionRepositoryInterface.php b/src/Sylius/Component/Rbac/Repository/PermissionRepositoryInterface.php deleted file mode 100644 index c2f02c38b3..0000000000 --- a/src/Sylius/Component/Rbac/Repository/PermissionRepositoryInterface.php +++ /dev/null @@ -1,28 +0,0 @@ - - */ -interface PermissionRepositoryInterface extends RepositoryInterface -{ - /** - * @param PermissionInterface - * - * @return array - */ - public function getChildPermissions(PermissionInterface $permission); -} diff --git a/src/Sylius/Component/Rbac/Repository/RoleRepositoryInterface.php b/src/Sylius/Component/Rbac/Repository/RoleRepositoryInterface.php deleted file mode 100644 index 14d6e215db..0000000000 --- a/src/Sylius/Component/Rbac/Repository/RoleRepositoryInterface.php +++ /dev/null @@ -1,28 +0,0 @@ - - */ -interface RoleRepositoryInterface extends RepositoryInterface -{ - /** - * @param RoleInterface - * - * @return array - */ - public function getChildRoles(RoleInterface $role); -} diff --git a/src/Sylius/Component/Rbac/Resolver/NestedSetPermissionsResolver.php b/src/Sylius/Component/Rbac/Resolver/NestedSetPermissionsResolver.php deleted file mode 100644 index b12f60ac9e..0000000000 --- a/src/Sylius/Component/Rbac/Resolver/NestedSetPermissionsResolver.php +++ /dev/null @@ -1,63 +0,0 @@ - - */ -class NestedSetPermissionsResolver implements PermissionsResolverInterface -{ - private $permissionRepository; - - public function __construct(PermissionRepositoryInterface $permissionRepository) - { - $this->permissionRepository = $permissionRepository; - } - - /** - * {@inheritdoc} - */ - public function getPermissions(RoleInterface $role) - { - $permissions = new ArrayCollection(); - - foreach ($role->getPermissions() as $permission) { - $permissions->add($permission); - - foreach ($this->getChildPermissions($permission) as $childPermission) { - if (!$permissions->contains($childPermission)) { - $permissions->add($childPermission); - } - } - } - - return $permissions; - } - - /** - * @param PermissionInterface $permission - * - * @return Collection - */ - private function getChildPermissions(PermissionInterface $permission) - { - return $this->permissionRepository->getChildPermissions($permission); - } -} diff --git a/src/Sylius/Component/Rbac/Resolver/NestedSetRolesResolver.php b/src/Sylius/Component/Rbac/Resolver/NestedSetRolesResolver.php deleted file mode 100644 index c01e0b5d42..0000000000 --- a/src/Sylius/Component/Rbac/Resolver/NestedSetRolesResolver.php +++ /dev/null @@ -1,71 +0,0 @@ - - */ -class NestedSetRolesResolver implements RolesResolverInterface -{ - private $roleRepository; - private $cache = []; - - public function __construct(RoleRepositoryInterface $roleRepository) - { - $this->roleRepository = $roleRepository; - } - - /** - * {@inheritdoc} - */ - public function getRoles(IdentityInterface $identity) - { - $identityHash = spl_object_hash($identity); - - if (isset($this->cache[$identityHash])) { - return $this->cache[$identityHash]; - } - - $roles = new ArrayCollection(); - - foreach ($identity->getAuthorizationRoles() as $role) { - $childRoles = $this->getChildRoles($role); - $roles->add($role); - - foreach ($childRoles as $childRole) { - if (!$roles->contains($childRole)) { - $roles->add($childRole); - } - } - } - - return $this->cache[$identityHash] = $roles; - } - - /** - * @param RoleInterface $role - * - * @return Collection - */ - private function getChildRoles(RoleInterface $role) - { - return $this->roleRepository->getChildRoles($role); - } -} diff --git a/src/Sylius/Component/Rbac/Resolver/PermissionsResolver.php b/src/Sylius/Component/Rbac/Resolver/PermissionsResolver.php deleted file mode 100644 index a75b15e4e5..0000000000 --- a/src/Sylius/Component/Rbac/Resolver/PermissionsResolver.php +++ /dev/null @@ -1,44 +0,0 @@ - - */ -class PermissionsResolver implements PermissionsResolverInterface -{ - /** - * {@inheritdoc} - */ - public function getPermissions(RoleInterface $role) - { - $permissions = new ArrayCollection(); - - $iterator = new \RecursiveIteratorIterator( - new RecursivePermissionIterator($role->getPermissions()), - \RecursiveIteratorIterator::SELF_FIRST - ); - - foreach ($iterator as $permission) { - if (!$permissions->contains($permission)) { - $permissions->add($permission); - } - } - - return $permissions; - } -} diff --git a/src/Sylius/Component/Rbac/Resolver/PermissionsResolverInterface.php b/src/Sylius/Component/Rbac/Resolver/PermissionsResolverInterface.php deleted file mode 100644 index 26d03c071b..0000000000 --- a/src/Sylius/Component/Rbac/Resolver/PermissionsResolverInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - */ -interface PermissionsResolverInterface -{ - /** - * Get all applicable permissions from role. - * - * @param RoleInterface - * - * @return Collection - */ - public function getPermissions(RoleInterface $role); -} diff --git a/src/Sylius/Component/Rbac/Resolver/RecursivePermissionIterator.php b/src/Sylius/Component/Rbac/Resolver/RecursivePermissionIterator.php deleted file mode 100644 index 70b5ae158c..0000000000 --- a/src/Sylius/Component/Rbac/Resolver/RecursivePermissionIterator.php +++ /dev/null @@ -1,44 +0,0 @@ -toArray(); - } - - parent::__construct($permissions); - } - - public function valid() - { - return $this->current() instanceof PermissionInterface; - } - - public function hasChildren() - { - return $this->current()->hasChildren(); - } - - public function getChildren() - { - return new self($this->current()->getChildren()); - } -} diff --git a/src/Sylius/Component/Rbac/Resolver/RecursiveRoleIterator.php b/src/Sylius/Component/Rbac/Resolver/RecursiveRoleIterator.php deleted file mode 100644 index 2e8a83712a..0000000000 --- a/src/Sylius/Component/Rbac/Resolver/RecursiveRoleIterator.php +++ /dev/null @@ -1,44 +0,0 @@ -toArray(); - } - - parent::__construct($roles); - } - - public function valid() - { - return $this->current() instanceof RoleInterface; - } - - public function hasChildren() - { - return $this->current()->hasChildren(); - } - - public function getChildren() - { - return new self($this->current()->getChildren()); - } -} diff --git a/src/Sylius/Component/Rbac/Resolver/RolesResolver.php b/src/Sylius/Component/Rbac/Resolver/RolesResolver.php deleted file mode 100644 index 3b0f2ef99d..0000000000 --- a/src/Sylius/Component/Rbac/Resolver/RolesResolver.php +++ /dev/null @@ -1,33 +0,0 @@ - - */ -class RolesResolver implements RolesResolverInterface -{ - /** - * {@inheritdoc} - */ - public function getRoles(IdentityInterface $identity) - { - return new \RecursiveIteratorIterator( - new RecursiveRoleIterator($identity->getAuthorizationRoles()), - \RecursiveIteratorIterator::SELF_FIRST - ); - } -} diff --git a/src/Sylius/Component/Rbac/Resolver/RolesResolverInterface.php b/src/Sylius/Component/Rbac/Resolver/RolesResolverInterface.php deleted file mode 100644 index 1d485f0c22..0000000000 --- a/src/Sylius/Component/Rbac/Resolver/RolesResolverInterface.php +++ /dev/null @@ -1,31 +0,0 @@ - - */ -interface RolesResolverInterface -{ - /** - * Get all applicable roles from a given Identity. - * - * @param IdentityInterface - * - * @return array - */ - public function getRoles(IdentityInterface $identity); -} diff --git a/src/Sylius/Component/Rbac/composer.json b/src/Sylius/Component/Rbac/composer.json deleted file mode 100644 index 5126029cf1..0000000000 --- a/src/Sylius/Component/Rbac/composer.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "sylius/rbac", - "type": "library", - "description": "RBAC component for PHP applications.", - "keywords": ["Rbac", "security", "acl", "permissions"], - "homepage": "http://sylius.org", - "license": "MIT", - "authors": [ - { - "name": "Paweł Jędrzejewski", - "homepage": "http://pjedrzejewski.com" - }, - { - "name": "Sylius project", - "homepage": "http://sylius.org" - }, - { - "name": "Community contributions", - "homepage": "http://github.com/Sylius/Sylius/contributors" - } - ], - "require": { - "php": "^5.6|^7.0", - - "sylius/resource": "^1.0" - }, - "require-dev": { - "phpspec/phpspec": "^3.0" - }, - "config": { - "bin-dir": "bin" - }, - "autoload": { - "psr-4": { "Sylius\\Component\\Rbac\\": "" } - }, - "autoload-dev": { - "psr-4": { "Sylius\\Component\\Rbac\\spec\\": "spec/" } - }, - "minimum-stability": "dev", - "prefer-stable": true, - "repositories": [ - { - "type": "path", - "url": "../../*/*" - } - ], - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - } -} diff --git a/src/Sylius/Component/Rbac/phpspec.yml.dist b/src/Sylius/Component/Rbac/phpspec.yml.dist deleted file mode 100644 index ee8e7f900a..0000000000 --- a/src/Sylius/Component/Rbac/phpspec.yml.dist +++ /dev/null @@ -1,5 +0,0 @@ -suites: - main: - namespace: Sylius\Component\Rbac - psr4_prefix: Sylius\Component\Rbac - src_path: . diff --git a/src/Sylius/Component/Rbac/spec/Authorization/AuthorizationCheckerSpec.php b/src/Sylius/Component/Rbac/spec/Authorization/AuthorizationCheckerSpec.php deleted file mode 100644 index cd07ff8b74..0000000000 --- a/src/Sylius/Component/Rbac/spec/Authorization/AuthorizationCheckerSpec.php +++ /dev/null @@ -1,87 +0,0 @@ - - */ -final class AuthorizationCheckerSpec extends ObjectBehavior -{ - function let( - CurrentIdentityProviderInterface $currentIdentityProvider, - PermissionMapInterface $permissionMap, - RolesResolverInterface $rolesResolver - ) { - $this->beConstructedWith($currentIdentityProvider, $permissionMap, $rolesResolver); - } - - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Component\Rbac\Authorization\AuthorizationChecker'); - } - - function it_implements_Sylius_Rbac_authorization_checker_interface() - { - $this->shouldImplement(AuthorizationCheckerInterface::class); - } - - function it_obtains_the_current_identity_and_returns_false_if_none_available($currentIdentityProvider) - { - $currentIdentityProvider->getIdentity()->shouldBeCalled()->willReturn(null); - - $this->isGranted('edit_product')->shouldReturn(false); - } - - function it_returns_false_if_none_of_current_identity_roles_has_permission( - $currentIdentityProvider, - IdentityInterface $identity, - $permissionMap, - $rolesResolver, - RoleInterface $role1, - RoleInterface $role2 - ) { - $currentIdentityProvider->getIdentity()->shouldBeCalled()->willReturn($identity); - $rolesResolver->getRoles($identity)->shouldBeCalled()->willReturn([$role1, $role2]); - - $permissionMap->hasPermission($role1, 'can_close_store')->shouldBeCalled()->willReturn(false); - $permissionMap->hasPermission($role2, 'can_close_store')->shouldBeCalled()->willReturn(false); - - $this->isGranted('can_close_store')->shouldReturn(false); - } - - function it_returns_true_if_any_of_current_identity_roles_has_permission( - $currentIdentityProvider, - IdentityInterface $identity, - $permissionMap, - $rolesResolver, - PermissionInterface $permission, - RoleInterface $role1, - RoleInterface $role2 - ) { - $currentIdentityProvider->getIdentity()->shouldBeCalled()->willReturn($identity); - $rolesResolver->getRoles($identity)->shouldBeCalled()->willReturn([$role1, $role2]); - - $permissionMap->hasPermission($role1, 'can_open_store')->shouldBeCalled()->willReturn(false); - $permissionMap->hasPermission($role2, 'can_open_store')->shouldBeCalled()->willReturn(true); - - $this->isGranted('can_open_store')->shouldReturn(true); - } -} diff --git a/src/Sylius/Component/Rbac/spec/Authorization/CachedPermissionMapSpec.php b/src/Sylius/Component/Rbac/spec/Authorization/CachedPermissionMapSpec.php deleted file mode 100644 index 4e41ffd6aa..0000000000 --- a/src/Sylius/Component/Rbac/spec/Authorization/CachedPermissionMapSpec.php +++ /dev/null @@ -1,57 +0,0 @@ - - */ -final class CachedPermissionMapSpec extends ObjectBehavior -{ - function let(PermissionMapInterface $map, Cache $cache) - { - $this->beConstructedWith($map, $cache); - } - - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Component\Rbac\Authorization\CachedPermissionMap'); - } - - function it_is_a_permission_map() - { - $this->shouldHaveType(PermissionMapInterface::class); - } - - function it_uses_another_map_to_get_all_permissions($map, Collection $permissions, RoleInterface $role) - { - $map->getPermissions($role)->shouldBeCalled()->willReturn($permissions); - - $this->getPermissions($role)->shouldReturn($permissions); - } - - function it_checks_if_permission_is_in_the_cached_array($cache, RoleInterface $role) - { - $role->getCode()->shouldBeCalled()->willReturn('catalog_manager'); - - $cache->contains('rbac_role:catalog_manager')->shouldBeCalled()->willReturn(true); - $cache->fetch('rbac_role:catalog_manager')->shouldBeCalled()->willReturn(['can_eat_bananas', 'can_smash_bananas']); - - $this->hasPermission($role, 'can_eat_bananas')->shouldReturn(true); - $this->hasPermission($role, 'can_eat_oranges')->shouldReturn(false); - } -} diff --git a/src/Sylius/Component/Rbac/spec/Authorization/PermissionMapSpec.php b/src/Sylius/Component/Rbac/spec/Authorization/PermissionMapSpec.php deleted file mode 100644 index 52272689b1..0000000000 --- a/src/Sylius/Component/Rbac/spec/Authorization/PermissionMapSpec.php +++ /dev/null @@ -1,72 +0,0 @@ - - */ -final class PermissionMapSpec extends ObjectBehavior -{ - function let(PermissionProviderInterface $permissionProvider, PermissionsResolverInterface $permissionResolver) - { - $this->beConstructedWith($permissionProvider, $permissionResolver); - } - - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Component\Rbac\Authorization\PermissionMap'); - } - - function it_is_a_permission_map() - { - $this->shouldHaveType(PermissionMapInterface::class); - } - - function it_uses_permissions_resolver_to_obtain_whole_tree_of_permissions( - $permissionResolver, - RoleInterface $role, - PermissionInterface $permission1, - PermissionInterface $permission2 - ) { - $permissionResolver->getPermissions($role)->shouldBeCalled()->willReturn([$permission1, $permission2]); - - $this->getPermissions($role)->shouldReturn([$permission1, $permission2]); - } - - function it_checks_if_role_has_permission_with_given_code( - $permissionProvider, - $permissionResolver, - RoleInterface $role, - PermissionInterface $permission, - Collection $validPermissions, - Collection $invalidPermissions - ) { - $validPermissions->contains($permission)->shouldBeCalled()->willReturn(true); - $invalidPermissions->contains($permission)->shouldBeCalled()->willReturn(false); - - $permissionProvider->getPermission('can_eat_bananas')->shouldBeCalled()->willReturn($permission); - - $permissionResolver->getPermissions($role)->shouldBeCalled()->willReturn($validPermissions); - $this->hasPermission($role, 'can_eat_bananas')->shouldReturn(true); - - $permissionResolver->getPermissions($role)->shouldBeCalled()->willReturn($invalidPermissions); - $this->hasPermission($role, 'can_eat_bananas')->shouldReturn(false); - } -} diff --git a/src/Sylius/Component/Rbac/spec/Model/PermissionSpec.php b/src/Sylius/Component/Rbac/spec/Model/PermissionSpec.php deleted file mode 100644 index 487188b334..0000000000 --- a/src/Sylius/Component/Rbac/spec/Model/PermissionSpec.php +++ /dev/null @@ -1,79 +0,0 @@ - - */ -final class PermissionSpec extends ObjectBehavior -{ - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Component\Rbac\Model\Permission'); - } - - function it_implements_Sylius_Rbac_permission_interface() - { - $this->shouldImplement(PermissionInterface::class); - } - - function it_has_no_id_by_default() - { - $this->getId()->shouldReturn(null); - } - - function it_has_no_code_by_default() - { - $this->getCode()->shouldReturn(null); - } - - function its_code_is_mutable() - { - $this->setCode('can_edit_product'); - $this->getCode()->shouldReturn('can_edit_product'); - } - - function it_has_no_description_by_default() - { - $this->getDescription()->shouldReturn(null); - } - - function it_can_have_a_description() - { - $this->setDescription('Can edit product'); - $this->getDescription()->shouldReturn('Can edit product'); - } - - function its_creation_date_is_mutable() - { - $date = new \DateTime(); - - $this->setCreatedAt($date); - $this->getCreatedAt()->shouldReturn($date); - } - - function it_has_no_last_update_date_by_default() - { - $this->getUpdatedAt()->shouldReturn(null); - } - - function its_last_update_date_is_mutable() - { - $date = new \DateTime(); - - $this->setUpdatedAt($date); - $this->getUpdatedAt()->shouldReturn($date); - } -} diff --git a/src/Sylius/Component/Rbac/spec/Model/RoleSpec.php b/src/Sylius/Component/Rbac/spec/Model/RoleSpec.php deleted file mode 100644 index ba0bc4ce38..0000000000 --- a/src/Sylius/Component/Rbac/spec/Model/RoleSpec.php +++ /dev/null @@ -1,100 +0,0 @@ - - */ -final class RoleSpec extends ObjectBehavior -{ - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Component\Rbac\Model\Role'); - } - - function it_implements_Sylius_Rbac_role_interface() - { - $this->shouldImplement(RoleInterface::class); - } - - function it_has_no_id_by_default() - { - $this->getId()->shouldReturn(null); - } - - function it_has_no_code_by_default() - { - $this->getCode()->shouldReturn(null); - } - - function its_code_is_mutable() - { - $this->setCode('catalog_manager'); - $this->getCode()->shouldReturn('catalog_manager'); - } - - function it_is_unnamed_by_default() - { - $this->getName()->shouldReturn(null); - } - - function it_can_have_a_name() - { - $this->setName('Catalog Manager'); - $this->getName()->shouldReturn('Catalog Manager'); - } - - function it_does_not_have_any_permissions_by_default() - { - $this->getPermissions()->shouldHaveType(ArrayCollection::class); - } - - function it_can_have_specific_permissions(PermissionInterface $permission) - { - $this->hasPermission($permission)->shouldReturn(false); - $this->addPermission($permission); - $this->hasPermission($permission)->shouldReturn(true); - } - - function it_can_remove_permissions(PermissionInterface $permission) - { - $this->addPermission($permission); - $this->removePermission($permission); - $this->hasPermission($permission)->shouldReturn(false); - } - - function its_creation_date_is_mutable() - { - $date = new \DateTime(); - - $this->setCreatedAt($date); - $this->getCreatedAt()->shouldReturn($date); - } - - function it_has_no_last_update_date_by_default() - { - $this->getUpdatedAt()->shouldReturn(null); - } - - function its_last_update_date_is_mutable() - { - $date = new \DateTime(); - - $this->setUpdatedAt($date); - $this->getUpdatedAt()->shouldReturn($date); - } -} diff --git a/src/Sylius/Component/Rbac/spec/Provider/PermissionProviderSpec.php b/src/Sylius/Component/Rbac/spec/Provider/PermissionProviderSpec.php deleted file mode 100644 index 9e601dd6a5..0000000000 --- a/src/Sylius/Component/Rbac/spec/Provider/PermissionProviderSpec.php +++ /dev/null @@ -1,53 +0,0 @@ - - */ -final class PermissionProviderSpec extends ObjectBehavior -{ - function let(RepositoryInterface $permissionRepository) - { - $this->beConstructedWith($permissionRepository); - } - - function it_is_initializable() - { - $this->shouldHaveType('Sylius\Component\Rbac\Provider\PermissionProvider'); - } - - function it_implements_Sylius_Rbac_permission_provider_interface() - { - $this->shouldImplement(PermissionProviderInterface::class); - } - - function it_looks_for_permission_via_repository($permissionRepository, PermissionInterface $permission) - { - $permissionRepository->findOneBy(['code' => 'can_dance_on_the_table'])->shouldBeCalled()->willReturn($permission); - - $this->getPermission('can_dance_on_the_table')->shouldReturn($permission); - } - - function it_throws_an_exception_when_permission_does_not_exist($permissionRepository) - { - $permissionRepository->findOneBy(['code' => 'can_dance_on_the_fridge'])->shouldBeCalled()->willReturn(null); - - $this->shouldThrow(new PermissionNotFoundException('can_dance_on_the_fridge'))->duringGetPermission('can_dance_on_the_fridge'); - } -} From a7be137d119dcaa0a353b34198376c599268626a Mon Sep 17 00:00:00 2001 From: Arminek Date: Tue, 23 Aug 2016 13:07:59 +0200 Subject: [PATCH 2/2] [User] Remove authorization roles from Admin & Shop user --- app/migrations/Version20160823110432.php | 56 +++++++++++++++++++ .../Factory/AdminUserExampleFactory.php | 2 +- .../Resources/config/app/fixtures.yml | 1 - .../InstallerBundle/Command/SetupCommand.php | 4 -- 4 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 app/migrations/Version20160823110432.php diff --git a/app/migrations/Version20160823110432.php b/app/migrations/Version20160823110432.php new file mode 100644 index 0000000000..96bc463303 --- /dev/null +++ b/app/migrations/Version20160823110432.php @@ -0,0 +1,56 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE sylius_permission DROP FOREIGN KEY FK_C5160A4E727ACA70'); + $this->addSql('ALTER TABLE sylius_role_permission DROP FOREIGN KEY FK_45CEE9B8FED90CCA'); + $this->addSql('ALTER TABLE sylius_admin_user_role DROP FOREIGN KEY FK_EEACD2AFD60322AC'); + $this->addSql('ALTER TABLE sylius_role DROP FOREIGN KEY FK_8C606FE3727ACA70'); + $this->addSql('ALTER TABLE sylius_role_permission DROP FOREIGN KEY FK_45CEE9B8D60322AC'); + $this->addSql('ALTER TABLE sylius_shop_user_role DROP FOREIGN KEY FK_E865E2D3D60322AC'); + $this->addSql('DROP TABLE sylius_admin_user_role'); + $this->addSql('DROP TABLE sylius_permission'); + $this->addSql('DROP TABLE sylius_role'); + $this->addSql('DROP TABLE sylius_role_permission'); + $this->addSql('DROP TABLE sylius_shop_user_role'); + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('CREATE TABLE sylius_admin_user_role (user_id INT NOT NULL, role_id INT NOT NULL, INDEX IDX_EEACD2AFA76ED395 (user_id), INDEX IDX_EEACD2AFD60322AC (role_id), PRIMARY KEY(user_id, role_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); + $this->addSql('CREATE TABLE sylius_permission (id INT AUTO_INCREMENT NOT NULL, parent_id INT DEFAULT NULL, code VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, description LONGTEXT DEFAULT NULL COLLATE utf8_unicode_ci, tree_left INT NOT NULL, tree_right INT NOT NULL, tree_level INT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME DEFAULT NULL, INDEX IDX_C5160A4E727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); + $this->addSql('CREATE TABLE sylius_role (id INT AUTO_INCREMENT NOT NULL, parent_id INT DEFAULT NULL, code VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, name VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, description LONGTEXT DEFAULT NULL COLLATE utf8_unicode_ci, security_roles LONGTEXT NOT NULL COLLATE utf8_unicode_ci COMMENT \'(DC2Type:array)\', tree_left INT NOT NULL, tree_right INT NOT NULL, tree_level INT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME DEFAULT NULL, INDEX IDX_8C606FE3727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); + $this->addSql('CREATE TABLE sylius_role_permission (role_id INT NOT NULL, permission_id INT NOT NULL, INDEX IDX_45CEE9B8D60322AC (role_id), INDEX IDX_45CEE9B8FED90CCA (permission_id), PRIMARY KEY(role_id, permission_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); + $this->addSql('CREATE TABLE sylius_shop_user_role (user_id INT NOT NULL, role_id INT NOT NULL, INDEX IDX_E865E2D3A76ED395 (user_id), INDEX IDX_E865E2D3D60322AC (role_id), PRIMARY KEY(user_id, role_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); + $this->addSql('ALTER TABLE sylius_admin_user_role ADD CONSTRAINT FK_EEACD2AFA76ED395 FOREIGN KEY (user_id) REFERENCES sylius_admin_user (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_admin_user_role ADD CONSTRAINT FK_EEACD2AFD60322AC FOREIGN KEY (role_id) REFERENCES sylius_role (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_permission ADD CONSTRAINT FK_C5160A4E727ACA70 FOREIGN KEY (parent_id) REFERENCES sylius_permission (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_role ADD CONSTRAINT FK_8C606FE3727ACA70 FOREIGN KEY (parent_id) REFERENCES sylius_role (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_role_permission ADD CONSTRAINT FK_45CEE9B8D60322AC FOREIGN KEY (role_id) REFERENCES sylius_role (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_role_permission ADD CONSTRAINT FK_45CEE9B8FED90CCA FOREIGN KEY (permission_id) REFERENCES sylius_permission (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_shop_user_role ADD CONSTRAINT FK_E865E2D3A76ED395 FOREIGN KEY (user_id) REFERENCES sylius_shop_user (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_shop_user_role ADD CONSTRAINT FK_E865E2D3D60322AC FOREIGN KEY (role_id) REFERENCES sylius_role (id) ON DELETE CASCADE'); + } +} diff --git a/src/Sylius/Bundle/CoreBundle/Fixture/Factory/AdminUserExampleFactory.php b/src/Sylius/Bundle/CoreBundle/Fixture/Factory/AdminUserExampleFactory.php index 891f88829d..27193c16ce 100644 --- a/src/Sylius/Bundle/CoreBundle/Fixture/Factory/AdminUserExampleFactory.php +++ b/src/Sylius/Bundle/CoreBundle/Fixture/Factory/AdminUserExampleFactory.php @@ -77,7 +77,7 @@ final class AdminUserExampleFactory implements ExampleFactoryInterface $user->addRole('ROLE_ADMINISTRATION_ACCESS'); if ($options['api']) { - $this->addUserRole($user, 'ROLE_API_ACCESS', 'api_administrator'); + $user->addRole('ROLE_API_ACCESS'); } return $user; diff --git a/src/Sylius/Bundle/CoreBundle/Resources/config/app/fixtures.yml b/src/Sylius/Bundle/CoreBundle/Resources/config/app/fixtures.yml index 7fc50db12d..2370c562a6 100644 --- a/src/Sylius/Bundle/CoreBundle/Resources/config/app/fixtures.yml +++ b/src/Sylius/Bundle/CoreBundle/Resources/config/app/fixtures.yml @@ -70,7 +70,6 @@ sylius_fixtures: last_name: Doe password: sylius - rbac: ~ admin_user: name: admin_user options: diff --git a/src/Sylius/Bundle/InstallerBundle/Command/SetupCommand.php b/src/Sylius/Bundle/InstallerBundle/Command/SetupCommand.php index ac733ac1b9..104a147680 100644 --- a/src/Sylius/Bundle/InstallerBundle/Command/SetupCommand.php +++ b/src/Sylius/Bundle/InstallerBundle/Command/SetupCommand.php @@ -77,9 +77,6 @@ EOT $userRepository = $this->get('sylius.repository.admin_user'); $userFactory = $this->get('sylius.factory.admin_user'); - $rbacInitializer = $this->get('sylius.rbac.initializer'); - $rbacInitializer->initialize(); - /** @var AdminUserInterface $user */ $user = $userFactory->createNew(); @@ -107,7 +104,6 @@ EOT } $user->setEnabled(true); - $user->addAuthorizationRole($this->get('sylius.repository.role')->findOneBy(['code' => 'administrator'])); $userManager->persist($user); $userManager->flush();