diff --git a/src/Synolia/Bundle/FavoriteBundle/Controller/Frontend/FavoriteButtonAjaxController.php b/src/Synolia/Bundle/FavoriteBundle/Controller/Frontend/FavoriteButtonAjaxController.php index 003967d..d9dea76 100644 --- a/src/Synolia/Bundle/FavoriteBundle/Controller/Frontend/FavoriteButtonAjaxController.php +++ b/src/Synolia/Bundle/FavoriteBundle/Controller/Frontend/FavoriteButtonAjaxController.php @@ -9,7 +9,7 @@ use Oro\Bundle\SecurityBundle\Authentication\TokenAccessorInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\Attribute\Route; use Synolia\Bundle\FavoriteBundle\Handler\FavoriteButtonAjaxHandler; #[Route('/ajax', options: ["expose"=>true])] diff --git a/src/Synolia/Bundle/FavoriteBundle/Controller/Frontend/FavoriteController.php b/src/Synolia/Bundle/FavoriteBundle/Controller/Frontend/FavoriteController.php index dc99821..3076abb 100644 --- a/src/Synolia/Bundle/FavoriteBundle/Controller/Frontend/FavoriteController.php +++ b/src/Synolia/Bundle/FavoriteBundle/Controller/Frontend/FavoriteController.php @@ -7,7 +7,7 @@ use Oro\Bundle\LayoutBundle\Attribute\Layout; use Oro\Bundle\SecurityBundle\Attribute\Acl; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\Attribute\Route; use Synolia\Bundle\FavoriteBundle\Entity\Favorite; class FavoriteController extends AbstractController diff --git a/src/Synolia/Bundle/FavoriteBundle/Entity/Favorite.php b/src/Synolia/Bundle/FavoriteBundle/Entity/Favorite.php index 81f2718..c965287 100644 --- a/src/Synolia/Bundle/FavoriteBundle/Entity/Favorite.php +++ b/src/Synolia/Bundle/FavoriteBundle/Entity/Favorite.php @@ -23,10 +23,12 @@ 'organization_column_name' => 'organization_id', 'frontend_owner_type' => 'FRONTEND_USER', 'frontend_owner_field_name' => 'customerUser', - 'frontend_owner_column_name' => 'customer_user_id', ], + 'frontend_owner_column_name' => 'customer_user_id', + ], 'security' => [ 'type' => 'ACL', - 'group_name' => 'commerce'], + 'group_name' => 'commerce' + ], ])] class Favorite implements ExtendEntityInterface, OrganizationAwareInterface, DatesAwareInterface { diff --git a/src/Synolia/Bundle/FavoriteBundle/EventListener/FavoriteDatagridListener.php b/src/Synolia/Bundle/FavoriteBundle/EventListener/FavoriteDatagridListener.php index 89c69a8..3d6aa39 100644 --- a/src/Synolia/Bundle/FavoriteBundle/EventListener/FavoriteDatagridListener.php +++ b/src/Synolia/Bundle/FavoriteBundle/EventListener/FavoriteDatagridListener.php @@ -35,8 +35,6 @@ public function onBuildAfter(BuildAfter $event): void return; } - /** @var FavoriteRepository $repo */ - $repo = $this->entityManager->getRepository(Favorite::class); $user = $this->tokenAccessor->getUser(); $organization = $this->tokenAccessor->getOrganization(); $favProductIds = []; diff --git a/src/Synolia/Bundle/FavoriteBundle/EventListener/FrontendProductFavoriteDatagridListener.php b/src/Synolia/Bundle/FavoriteBundle/EventListener/FrontendProductFavoriteDatagridListener.php index 0d928ac..f3aad9f 100644 --- a/src/Synolia/Bundle/FavoriteBundle/EventListener/FrontendProductFavoriteDatagridListener.php +++ b/src/Synolia/Bundle/FavoriteBundle/EventListener/FrontendProductFavoriteDatagridListener.php @@ -10,8 +10,8 @@ use Oro\Bundle\DataGridBundle\Event\BuildBefore; use Oro\Bundle\DataGridBundle\Extension\Formatter\Property\PropertyInterface; use Oro\Bundle\OrganizationBundle\Entity\Organization; -use Oro\Bundle\SecurityBundle\Authentication\TokenAccessorInterface; use Oro\Bundle\SearchBundle\Datagrid\Event\SearchResultAfter; +use Oro\Bundle\SecurityBundle\Authentication\TokenAccessorInterface; use Oro\Bundle\SecurityBundle\ORM\Walker\AclHelper; use Synolia\Bundle\FavoriteBundle\Entity\Favorite; use Synolia\Bundle\FavoriteBundle\Entity\Repository\FavoriteRepository; diff --git a/src/Synolia/Bundle/FavoriteBundle/Migrations/Data/ORM/UpdateFrontendPermissionsForRoles.php b/src/Synolia/Bundle/FavoriteBundle/Migrations/Data/ORM/UpdateFrontendPermissionsForRoles.php index 944a215..06e959e 100644 --- a/src/Synolia/Bundle/FavoriteBundle/Migrations/Data/ORM/UpdateFrontendPermissionsForRoles.php +++ b/src/Synolia/Bundle/FavoriteBundle/Migrations/Data/ORM/UpdateFrontendPermissionsForRoles.php @@ -4,11 +4,8 @@ namespace Synolia\Bundle\FavoriteBundle\Migrations\Data\ORM; -use Doctrine\Persistence\ObjectManager; use Oro\Bundle\CustomerBundle\Migrations\Data\ORM\AbstractMassUpdateCustomerUserRolePermissions; use Oro\Bundle\CustomerBundle\Migrations\Data\ORM\LoadCustomerUserRoles; -use Oro\Bundle\CustomerBundle\Owner\Metadata\FrontendOwnershipMetadataProvider; -use Oro\Bundle\SecurityBundle\Owner\Metadata\ChainOwnershipMetadataProvider; use Synolia\Bundle\FavoriteBundle\Entity\Favorite; /** @@ -21,23 +18,6 @@ public function getDependencies(): array return [LoadCustomerUserRoles::class]; } - public function load(ObjectManager $manager): void - { - $aclManager = $this->getAclManager(); - if (!$aclManager->isAclEnabled()) { - return; - } - - $chainMetadataProvider = $this->getChainMetadataProvider(); - $chainMetadataProvider->startProviderEmulation(FrontendOwnershipMetadataProvider::ALIAS); - - $this->updateRoles($aclManager, $manager); - - $chainMetadataProvider->stopProviderEmulation(); - - $aclManager->flush(); - } - protected function getACLData(): array { return [ @@ -45,17 +25,11 @@ protected function getACLData(): array 'entity:' . Favorite::class => ['VIEW_SYSTEM', 'CREATE_SYSTEM', 'EDIT_SYSTEM', 'DELETE_SYSTEM'], ], 'ROLE_FRONTEND_BUYER' => [ - 'entity:' . Favorite::class => ['VIEW_BASIC', 'CREATE_BASIC', 'EDIT_BASIC', 'DELETE_BASIC'], + 'entity:' . Favorite::class => ['VIEW_SYSTEM', 'CREATE_SYSTEM', 'EDIT_SYSTEM', 'DELETE_SYSTEM'], ], 'ROLE_FRONTEND_ANONYMOUS' => [ 'entity:' . Favorite::class => ['VIEW_NONE', 'CREATE_NONE', 'EDIT_NONE', 'DELETE_NONE'], ], ]; } - - private function getChainMetadataProvider(): ChainOwnershipMetadataProvider - { - /** @phpstan-ignore-next-line */ - return $this->container->get('oro_security.owner.metadata_provider.chain'); - } } diff --git a/src/Synolia/Bundle/FavoriteBundle/Migrations/Schema/v1_1/AddSerializeDataColumn.php b/src/Synolia/Bundle/FavoriteBundle/Migrations/Schema/v1_1/AddSerializeDataColumn.php index c5cc830..6af1966 100644 --- a/src/Synolia/Bundle/FavoriteBundle/Migrations/Schema/v1_1/AddSerializeDataColumn.php +++ b/src/Synolia/Bundle/FavoriteBundle/Migrations/Schema/v1_1/AddSerializeDataColumn.php @@ -17,7 +17,7 @@ class AddSerializeDataColumn implements Migration public function up(Schema $schema, QueryBag $queries): void { $table = $schema->getTable('synolia_favorite'); - if($table->hasColumn('serialize_data')) { + if ($table->hasColumn('serialize_data')) { return; } $table->addColumn('serialized_data', Types::JSON, ['notnull' => false]); diff --git a/src/Synolia/Bundle/FavoriteBundle/Resources/config/oro/routing.yml b/src/Synolia/Bundle/FavoriteBundle/Resources/config/oro/routing.yml index 91ec1ec..4dba3da 100644 --- a/src/Synolia/Bundle/FavoriteBundle/Resources/config/oro/routing.yml +++ b/src/Synolia/Bundle/FavoriteBundle/Resources/config/oro/routing.yml @@ -1,13 +1,13 @@ synolia_ajax_button_favorite: resource: '@SynoliaFavoriteBundle/Controller/Frontend/FavoriteButtonAjaxController.php' - type: annotation + type: attribute prefix: /favorite options: frontend: true synolia_favorite_index: resource: '@SynoliaFavoriteBundle/Controller/Frontend/FavoriteController.php' - type: annotation + type: attribute prefix: /customer/favorite options: frontend: true