Skip to content

Commit e78dfaf

Browse files
committed
Merge branch '2026.1' into 2026.x
2 parents b8b9c7e + fbe595c commit e78dfaf

23 files changed

Lines changed: 549 additions & 8 deletions

config/element_workflow.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ services:
2626
Pimcore\Bundle\StudioBackendBundle\Workflow\Service\WorkflowElementsServiceInterface:
2727
class: Pimcore\Bundle\StudioBackendBundle\Workflow\Service\WorkflowElementsService
2828

29+
Pimcore\Bundle\StudioBackendBundle\Workflow\Service\WorkflowMetaServiceInterface:
30+
class: Pimcore\Bundle\StudioBackendBundle\Workflow\Service\WorkflowMetaService
31+
2932
# Repositories
3033
Pimcore\Bundle\StudioBackendBundle\Workflow\Repository\WorkflowElementsRepositoryInterface:
3134
class: Pimcore\Bundle\StudioBackendBundle\Workflow\Repository\WorkflowElementsRepository

src/Entity/Search/SavedSearchConfiguration.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ class SavedSearchConfiguration implements ShareableConfigurationInterface
5050
#[ORM\Column(type: 'string', length: 50, nullable: true)]
5151
private ?string $classId = null;
5252

53+
#[ORM\Column(type: 'string', length: 50, nullable: true)]
54+
private ?string $elementType = null;
55+
5356
#[ORM\Column(type: 'boolean')]
5457
private bool $createMenuShortcut = false;
5558

@@ -106,6 +109,11 @@ public function getClassId(): ?string
106109
return $this->classId;
107110
}
108111

112+
public function getElementType(): ?string
113+
{
114+
return $this->elementType;
115+
}
116+
109117
public function isCreateMenuShortcut(): bool
110118
{
111119
return $this->createMenuShortcut;
@@ -166,6 +174,11 @@ public function setClassId(?string $classId): void
166174
$this->classId = $classId;
167175
}
168176

177+
public function setElementType(?string $elementType): void
178+
{
179+
$this->elementType = $elementType;
180+
}
181+
169182
public function setCreateMenuShortcut(bool $createMenuShortcut): void
170183
{
171184
$this->createMenuShortcut = $createMenuShortcut;
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This source file is available under the terms of the
7+
* Pimcore Open Core License (POCL)
8+
* Full copyright and license information is available in
9+
* LICENSE.md which is distributed with this source code.
10+
*
11+
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
12+
* @license Pimcore Open Core License (POCL)
13+
*/
14+
15+
namespace Pimcore\Bundle\StudioBackendBundle\Migrations;
16+
17+
use Doctrine\DBAL\Schema\Schema;
18+
use Doctrine\Migrations\AbstractMigration;
19+
use Pimcore\Bundle\StudioBackendBundle\Entity\Search\SavedSearchConfiguration;
20+
21+
/**
22+
* @internal
23+
*/
24+
final class Version20260625090000 extends AbstractMigration
25+
{
26+
public function getDescription(): string
27+
{
28+
return 'Add elementType column to the saved search configuration table';
29+
}
30+
31+
public function up(Schema $schema): void
32+
{
33+
if (!$schema->hasTable(SavedSearchConfiguration::TABLE_NAME)) {
34+
return;
35+
}
36+
37+
$table = $schema->getTable(SavedSearchConfiguration::TABLE_NAME);
38+
if (!$table->hasColumn('elementType')) {
39+
$table->addColumn('elementType', 'string', ['notnull' => false, 'length' => 50]);
40+
}
41+
}
42+
43+
public function down(Schema $schema): void
44+
{
45+
if (!$schema->hasTable(SavedSearchConfiguration::TABLE_NAME)) {
46+
return;
47+
}
48+
49+
$table = $schema->getTable(SavedSearchConfiguration::TABLE_NAME);
50+
if ($table->hasColumn('elementType')) {
51+
$table->dropColumn('elementType');
52+
}
53+
}
54+
}

src/Search/Attribute/Request/SavedSearchRequestBody.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function __construct()
4242
new SingleString('name'),
4343
new SingleString('description'),
4444
new SingleString('classId'),
45+
new SingleString('elementType'),
4546
new SingleBoolean('shareGlobal'),
4647
new SingleBoolean('createMenuShortcut'),
4748
new SingleString('menuShortcutGroup'),

src/Search/Controller/SavedSearch/ListConfigurationsController.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
use Pimcore\Bundle\StudioBackendBundle\MappedParameter\CollectionParameters;
1919
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Query\PageParameter;
2020
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Query\PageSizeParameter;
21+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Query\SortByParameter;
22+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Query\SortOrderParameter;
2123
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Query\TextFieldParameter;
2224
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Property\GenericCollection;
2325
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\Content\CollectionJson;
@@ -72,6 +74,8 @@ public function __construct(
7274
description: 'Optional term to filter the saved search configurations by name.',
7375
required: false
7476
)]
77+
#[SortByParameter(enum: ['name', 'modificationDate'])]
78+
#[SortOrderParameter]
7579
#[SuccessResponse(
7680
description: 'saved_search_get_configurations_success_response',
7781
content: new CollectionJson(new GenericCollection(ConfigurationListItem::class))
@@ -81,11 +85,15 @@ public function __construct(
8185
])]
8286
public function getSavedSearchConfigurations(
8387
#[MapQueryParameter] ?string $searchTerm = null,
88+
#[MapQueryParameter] ?string $sortBy = null,
89+
#[MapQueryParameter] ?string $sortOrder = null,
8490
#[MapQueryString] CollectionParameters $parameters = new CollectionParameters(),
8591
): JsonResponse {
8692
$collection = $this->savedSearchConfigurationService->listConfigurations(
8793
$parameters,
88-
$searchTerm
94+
$searchTerm,
95+
$sortBy,
96+
$sortOrder
8997
);
9098

9199
return $this->getPaginatedCollection(

src/Search/Hydrator/DetailedConfigurationHydrator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function hydrate(
3737
createMenuShortcut: $data->isCreateMenuShortcut(),
3838
menuShortcutGroup: $data->getMenuShortcutGroup(),
3939
classId: $data->getClassId(),
40+
elementType: $data->getElementType(),
4041
columns: $data->getColumns(),
4142
filter: $data->getFilter(),
4243
modificationDate: $data->getModificationDate()->getTimestamp(),

src/Search/Hydrator/ListItemHydrator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function hydrate(SavedSearchConfiguration $data, bool $owner): Configurat
3131
modificationDate: $data->getModificationDate()->getTimestamp(),
3232
creationDate: $data->getCreationDate()->getTimestamp(),
3333
menuShortcutGroup: $data->getMenuShortcutGroup(),
34+
elementType: $data->getElementType(),
3435
);
3536
}
3637
}

src/Search/MappedParameter/SavedSearchParameter.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function __construct(
3434
private ?Filter $filter = null,
3535
private ?string $description = null,
3636
private ?string $classId = null,
37+
private ?string $elementType = null,
3738
private bool $shareGlobal = false,
3839
private bool $createMenuShortcut = false,
3940
private ?string $menuShortcutGroup = null,
@@ -70,6 +71,11 @@ public function getClassId(): ?string
7071
return $this->classId;
7172
}
7273

74+
public function getElementType(): ?string
75+
{
76+
return $this->elementType;
77+
}
78+
7379
public function shareGlobal(): bool
7480
{
7581
return $this->shareGlobal;

src/Search/Repository/SavedSearchConfigurationRepository.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,20 @@ public function getById(int $id): SavedSearchConfiguration
4242
return $configuration;
4343
}
4444

45-
public function getList(?string $searchTerm): array
45+
public function getList(?string $searchTerm, ?string $sortBy = null, ?string $sortOrder = null): array
4646
{
47+
// Whitelist the sortable fields to keep the ORDER BY safe; default to newest first.
48+
$sortField = match ($sortBy) {
49+
'name' => 'c.name',
50+
'modificationDate' => 'c.modificationDate',
51+
default => 'c.modificationDate',
52+
};
53+
$direction = strtoupper((string) $sortOrder) === 'ASC' ? 'ASC' : 'DESC';
54+
4755
$queryBuilder = $this->entityManager->createQueryBuilder()
4856
->select('c')
4957
->from(SavedSearchConfiguration::class, 'c')
50-
->orderBy('c.modificationDate', 'DESC');
58+
->orderBy($sortField, $direction);
5159

5260
$searchTerm = $searchTerm !== null ? trim($searchTerm) : null;
5361
if ($searchTerm !== null && $searchTerm !== '') {

src/Search/Repository/SavedSearchConfigurationRepositoryInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function getById(int $id): SavedSearchConfiguration;
2929
/**
3030
* @return SavedSearchConfiguration[]
3131
*/
32-
public function getList(?string $searchTerm): array;
32+
public function getList(?string $searchTerm, ?string $sortBy = null, ?string $sortOrder = null): array;
3333

3434
/**
3535
* @return SavedSearchConfiguration[]

0 commit comments

Comments
 (0)