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
9 changes: 9 additions & 0 deletions config/pimcore/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ pimcore_studio_backend:
group: system
- key: preview
group: system
data_object:
predefined_columns:
- key: type
group: system
- key: fullpath
group: system
- key: classname
group: system

grid:
asset:
predefined_columns:
Expand Down
2 changes: 1 addition & 1 deletion src/Asset/Controller/Search/GetConfigurationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function __construct(
HttpResponseCodes::BAD_REQUEST,
HttpResponseCodes::UNAUTHORIZED,
])]
public function getAssetGridConfiguration(): JsonResponse
public function getAssetSearchConfiguration(): JsonResponse
{
$configuration = $this->configurationService->getAssetSearchConfiguration();

Expand Down
86 changes: 86 additions & 0 deletions src/DataObject/Controller/Search/GetConfigurationController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php
declare(strict_types=1);

/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\StudioBackendBundle\DataObject\Controller\Search;

use OpenApi\Attributes\Get;
use OpenApi\Attributes\JsonContent;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException;
use Pimcore\Bundle\StudioBackendBundle\Grid\Schema\DetailedConfiguration;
use Pimcore\Bundle\StudioBackendBundle\Grid\Service\ConfigurationServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\StringParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes;
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\UserPermissions;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;

/**
* @internal
*/
final class GetConfigurationController extends AbstractApiController
{
public function __construct(
SerializerInterface $serializer,
private readonly ConfigurationServiceInterface $gridConfigurationService,
) {
parent::__construct($serializer);
}

/**
* @throws NotFoundException
*/
#[Route(
'/data-object/search/configuration/{classId?}',
Comment thread
lukmzig marked this conversation as resolved.
name: 'pimcore_studio_api_get_data_object_search_configuration',
methods: ['GET'],

)]
#[IsGranted(UserPermissions::DATA_OBJECTS->value)]
#[Get(
path: self::PREFIX . '/data-object/search/configuration/{classId}',
operationId: 'data_object_get_search_configuration',
description: 'data_object_get_search_configuration_description',
summary: 'data_object_get_search_configuration_summary',
tags: [Tags::DataObjectsSearch->value]
)]
#[StringParameter(
name: 'classId',
example: 'EV',
description: 'Class Id of the data object',
required: false,
)]
#[SuccessResponse(
description: 'data_object_get_search_configuration_success_response',
content: new JsonContent(ref: DetailedConfiguration::class)
)]
#[DefaultResponses([
HttpResponseCodes::BAD_REQUEST,
HttpResponseCodes::NOT_FOUND,
HttpResponseCodes::UNAUTHORIZED,
])]
public function getDataObjectSearchConfiguration(?string $classId): JsonResponse
{
$configuration = $this->gridConfigurationService->getDataObjectSearchConfiguration($classId);

return $this->jsonResponse($configuration);
}
}
12 changes: 12 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,18 @@ private function addSearchGridConfiguration(ArrayNodeDefinition $node): void
->end()
->end()
->end()
->arrayNode('data_object')
->children()
->arrayNode('predefined_columns')
->arrayPrototype()
->children()
->scalarNode('group')->end()
->scalarNode('key')->end()
->end()
->end()
->end()
->end()
->end()
->end()
->end();
}
Expand Down
6 changes: 6 additions & 0 deletions src/DependencyInjection/PimcoreStudioBackendExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,17 @@ public function load(array $configs, ContainerBuilder $container): void
$definition->setArgument('$assetPredefinedColumns', $config['grid']['asset']['predefined_columns']);

$definition = $container->getDefinition(ConfigurationServiceInterface::class);

$definition->setArgument(
'$assetSearchPredefinedColumns',
$config['search_grid']['asset']['predefined_columns']
);

$definition->setArgument(
'$dataObjectSearchPredefinedColumns',
$config['search_grid']['data_object']['predefined_columns']
);

$definition = $container->getDefinition(ConfigurationServiceInterface::class);
$definition->setArgument('$dataObjectPredefinedColumns', $config['grid']['data_object']['predefined_columns']);

Expand Down
17 changes: 17 additions & 0 deletions src/Grid/Service/ColumnConfigurationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

namespace Pimcore\Bundle\StudioBackendBundle\Grid\Service;

use Pimcore\Bundle\StudioBackendBundle\Exception\Api\InvalidArgumentException;
use Pimcore\Bundle\StudioBackendBundle\Grid\Column\ClassIdInterface;
use Pimcore\Bundle\StudioBackendBundle\Grid\Column\FolderIdInterface;
use Pimcore\Bundle\StudioBackendBundle\Grid\Event\GridColumnConfigurationEvent;
Expand Down Expand Up @@ -91,6 +92,22 @@ public function getAvailableDataObjectColumnConfiguration(string $classId, int $

}

/**
* @return ColumnConfiguration[]
*
* @throws InvalidArgumentException
*/
public function getSystemDataObjectColumnConfiguration(): array
{
$systemCollector = $this->gridService->getColumnCollectors()['system.dataobject'];

if (!in_array(ElementTypes::TYPE_DATA_OBJECT, $systemCollector->supportedElementTypes(), true)) {
throw new InvalidArgumentException('collector does not support data objects');
}

return $systemCollector->getColumnConfigurations($this->gridService->getColumnDefinitions());
}

public function buildDataObjectAdapterColumnConfiguration(
ColumnFieldDefinition $definition,
?string $type = null,
Expand Down
5 changes: 5 additions & 0 deletions src/Grid/Service/ColumnConfigurationServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public function getAvailableAssetColumnConfiguration(): array;
*/
public function getAvailableDataObjectColumnConfiguration(string $classId, int $folderId): array;

/**
* @return ColumnConfiguration[]
*/
public function getSystemDataObjectColumnConfiguration(): array;

/**
* Builds a column configuration for a data object adapter column.
* key type and is optional and can be used to build a column configuration for a specific key type.
Expand Down
23 changes: 22 additions & 1 deletion src/Grid/Service/ConfigurationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function __construct(
private array $assetPredefinedColumns,
private array $dataObjectPredefinedColumns,
private array $assetSearchPredefinedColumns,
private array $dataObjectSearchPredefinedColumns,
) {
}

Expand Down Expand Up @@ -117,6 +118,26 @@ public function getAssetSearchConfiguration(): DetailedConfiguration
return $this->buildDefaultConfiguration($availableColumns, $this->assetSearchPredefinedColumns);
}

/**
* {@inheritdoc}
*/
public function getDataObjectSearchConfiguration(?string $classId): DetailedConfiguration
{
if (!$classId) {
return $this->buildDefaultConfiguration(
$this->columnConfigurationService->getSystemDataObjectColumnConfiguration(),
$this->dataObjectSearchPredefinedColumns,
true
);
}

return $this->buildDefaultConfiguration(
$this->columnConfigurationService->getAvailableDataObjectColumnConfiguration($classId, 1),
$this->dataObjectPredefinedColumns,
true
);
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -296,7 +317,7 @@ private function getDefaultColumnsForSearchAndGrid(array $availableColumns, bool

/** @var Data $fieldDefinition */
$fieldDefinition = $column->getConfig()['fieldDefinition'];
if ($search && !$fieldDefinition->getVisibleSearch()) {
if ($search && $fieldDefinition->getVisibleSearch()) {
$defaultColumns[] = new ColumnSchema(
key: $column->getKey(),
locale: $column->getLocale(),
Expand Down
5 changes: 5 additions & 0 deletions src/Grid/Service/ConfigurationServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public function getAssetGridConfiguration(?int $configurationId, int $folderId):

public function getAssetSearchConfiguration(): DetailedConfiguration;

/**
* @throws NotFoundException
*/
public function getDataObjectSearchConfiguration(?string $classId): DetailedConfiguration;

/**
* @throws NotFoundException
*/
Expand Down
3 changes: 3 additions & 0 deletions src/Grid/Service/SystemColumnService.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public function getSystemColumnsForDataObjects(): array
$columns[$column] = $this->columnMapper->getType($column);
}

// Add missing columns
$columns['type'] = 'string';

return $columns;
}

Expand Down
5 changes: 5 additions & 0 deletions src/OpenApi/Config/Tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
name: Tags::DataObjectsGrid->value,
description: 'tag_dataobject_grid_description'
)]
#[Tag(
name: Tags::DataObjectsSearch->value,
description: 'tag_dataobject_search_description'
)]
#[Tag(
name: Tags::Dependencies->value,
description: 'tag_dependencies_description'
Expand Down Expand Up @@ -160,6 +164,7 @@ enum Tags: string
case CustomReports = 'Custom Reports';
case DataObjects = 'Data Objects';
case DataObjectsGrid = 'Data Object Grid';
case DataObjectsSearch = 'Data Object Search';
case Dependencies = 'Dependencies';
case Documents = 'Documents';
case Elements = 'Elements';
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Grid/Service/SystemColumnServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function testGetSystemColumnsForDataObjects(): void
'filename' => 'string',
'classname' => 'string',
'index' => 'integer',
'type' => 'string',
], $systemColumnService->getSystemColumnsForDataObjects());
}
}
4 changes: 4 additions & 0 deletions translations/studio_api_docs.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ data_object_get_grid_configuration_description: |
Get data object saved grid configuration by <strong>{folderId}</strong> <strong>{classId}</strong> if a configuration-id is set, otherwise get the default configuration will be returned.
data_object_get_grid_configuration__success_response: Data Object grid configuration
data_object_get_grid_configuration_summary: Get data object grid configuration for a specific folder and class-id
data_object_get_search_configuration_description: Get data object search configuration
data_object_get_search_configuration_summary: Get data object search configuration
data_object_get_search_configuration_success_response: Data object search configuration
data_object_update_by_id_description: |
You can create/update/delete list entries like properties or data object editable fields. <br> If you want to update (add/remove) only some data of a field (e.g data of multi-relation fields), use the PATCH method.
data_object_update_by_id_success_response: Successfully updated data object
Expand Down Expand Up @@ -554,6 +557,7 @@ tag_create_summary: Create a new tag
tag_dataobjects_description: DataObject operations to get/update/create/delete data
objects
tag_dataobject_grid_description: DataObject Grid operations
tag_dataobject_search_description: DataObject Search operations
tag_delete_by_id_description: |
Delete a specific tag based on the given <strong>{id}</strong>
tag_delete_by_id_success_response: ID of successfully deleted tag
Expand Down
Loading