Skip to content

Commit

Permalink
feat: add properties for tree sorting to data object indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
lukmzig committed Jan 15, 2025
1 parent b67e728 commit 2b39366
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/pimcore/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ pimcore_generic_data_index:
type: keyword
index:
type: integer
childrenSortBy:
type: keyword
childrenSortOrder:
type: keyword
asset:
mimetype:
type: keyword
Expand Down
2 changes: 2 additions & 0 deletions src/Enum/SearchIndex/FieldCategory/SystemField.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ enum SystemField: string
case HAS_WORKFLOW_WITH_PERMISSIONS = 'hasWorkflowWithPermissions';
case FILE_SIZE = 'fileSize';
case DEPENDENCIES = 'dependencies';
case CHILDREN_SORT_BY = 'childrenSortBy';
case CHILDREN_SORT_ORDER = 'childrenSortOrder';

/**
* Not persisted in search index but dynamically calculated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class DataObjectSearchResultItem implements ElementSearchResultItemInterface

private int $index;

private string $childrenSortBy;

private string $childrenSortOrder;

private bool $published;

private string $path;
Expand Down Expand Up @@ -130,6 +134,30 @@ public function setIndex(int $index): DataObjectSearchResultItem
return $this;
}

public function getChildrenSortBy(): string
{
return $this->childrenSortBy;
}

public function setChildrenSortBy(string $childrenSortBy): DataObjectSearchResultItem
{
$this->childrenSortBy = $childrenSortBy;

return $this;
}

public function getChildrenSortOrder(): string
{
return $this->childrenSortOrder;
}

public function setChildrenSortOrder(string $childrenSortOrder): DataObjectSearchResultItem
{
$this->childrenSortOrder = $childrenSortOrder;

return $this;
}

public function isPublished(): bool
{
return $this->published;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public function denormalize(
->setPublished($published)
->setKey(SystemField::KEY->getData($data))
->setIndex(SystemField::INDEX->getData($data))
->setChildrenSortBy(SystemField::CHILDREN_SORT_BY->getData($data))
->setChildrenSortOrder(SystemField::CHILDREN_SORT_ORDER->getData($data))
->setPath(SystemField::PATH->getData($data))
->setFullPath(SystemField::FULL_PATH->getData($data))
->setUserOwner(SystemField::USER_OWNER->getData($data) ?? 0)
Expand Down
2 changes: 2 additions & 0 deletions src/Service/Serializer/Normalizer/DataObjectNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ private function normalizeSystemFields(AbstractObject $dataObject, bool $skipLaz
SystemField::TYPE->value => $dataObject->getType(),
SystemField::KEY->value => $dataObject->getKey(),
SystemField::INDEX->value => $dataObject->getIndex(),
SystemField::CHILDREN_SORT_BY->value => $dataObject->getChildrenSortBy(),
SystemField::CHILDREN_SORT_ORDER->value => $dataObject->getChildrenSortOrder(),
SystemField::PATH->value => $dataObject->getPath(),
SystemField::FULL_PATH->value => $dataObject->getRealFullPath(),
SystemField::USER_OWNER->value => $dataObject->getUserOwner(),
Expand Down

0 comments on commit 2b39366

Please sign in to comment.