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
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"require": {
"php": "~8.3.0 || ~8.4.0",
"pimcore/pimcore": "^12.0",
"pimcore/generic-data-index-bundle": "^2.1",
"symfony/event-dispatcher-contracts": "^3.0"
},
"conflict": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ public function load(array $configs, ContainerBuilder $container): void
);

$loader->load('services.yml');
$loader->load('generic-data-index.yaml');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);

/**
* This source file is available under the terms of the
* Pimcore Open Core License (POCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
* @license Pimcore Open Core License (POCL)
*/

namespace FrontendPermissionToolkitBundle\GenericDataIndex\FieldDefinitionAdapter;

use FrontendPermissionToolkitBundle\CoreExtensions\ClassDefinitions\DynamicPermissionResource;
use Pimcore\Bundle\GenericDataIndexBundle\SearchIndexAdapter\DataObject\FieldDefinitionServiceInterface;
use Pimcore\Bundle\GenericDataIndexBundle\SearchIndexAdapter\DefaultSearch\DataObject\FieldDefinitionAdapter\AbstractAdapter;
use Pimcore\Bundle\GenericDataIndexBundle\SearchIndexAdapter\IndexMappingServiceInterface;
use Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\SearchIndexConfigServiceInterface;

/**
* @internal
*/
final class DynamicPermissionResourceAdapter extends AbstractAdapter
{
public function __construct(
protected SearchIndexConfigServiceInterface $searchIndexConfigService,
protected FieldDefinitionServiceInterface $fieldDefinitionService,
private readonly IndexMappingServiceInterface $indexMappingService,
) {
parent::__construct(
$searchIndexConfigService,
$fieldDefinitionService
);
}

public function getIndexMapping(): array
{
return $this->indexMappingService->getMappingForTextKeyword(
$this->searchIndexConfigService->getSearchAnalyzerAttributes()
);
}

public function normalize(mixed $value): ?array
{
$fieldDefinition = $this->getFieldDefinition();
if (!$fieldDefinition instanceof DynamicPermissionResource) {
return null;
}

return array_values($value);
}
}
23 changes: 23 additions & 0 deletions src/Resources/config/generic-data-index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
services:
_defaults:
autowire: true
autoconfigure: true
public: false

pimcore.front_permission_toolkit.generic_data_index.data_object.relation-adapter:
class: Pimcore\Bundle\GenericDataIndexBundle\SearchIndexAdapter\DefaultSearch\DataObject\FieldDefinitionAdapter\RelationAdapter
shared: false
tags:
- { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "permissionManyToManyRelation" }
- { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "permissionManyToOneRelation" }

pimcore.front_permission_toolkit.generic_data_index.data_object.dynamic-permission-resource-adapter:
class: Pimcore\Bundle\GenericDataIndexBundle\SearchIndexAdapter\DefaultSearch\DataObject\FieldDefinitionAdapter\TextKeywordAdapter
shared: false
tags:
- { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "permissionResource" }

FrontendPermissionToolkitBundle\GenericDataIndex\FieldDefinitionAdapter\DynamicPermissionResourceAdapter:
shared: false
tags:
- { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "dynamicPermissionResource" }