Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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])]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/Synolia/Bundle/FavoriteBundle/Entity/Favorite.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -21,41 +18,18 @@ 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 [
'ROLE_FRONTEND_ADMINISTRATOR' => [
'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');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Loading