Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-6878: Customize search sorting #2226

Merged
merged 17 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
@@ -0,0 +1,5 @@
services:

App\Search\SortingDefinition\Provider\RandomSortingDefinitionProvider:
tags:
- name: ibexa.search.sorting_definition.provider
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php declare(strict_types=1);

namespace App\Search\SortingDefinition\Provider;

use Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause;
use Ibexa\Contracts\Search\SortingDefinition\SortingDefinition;
use Ibexa\Contracts\Search\SortingDefinition\SortingDefinitionProviderInterface;
use JMS\TranslationBundle\Model\Message;
use JMS\TranslationBundle\Translation\TranslationContainerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

final class RandomSortingDefinitionProvider implements SortingDefinitionProviderInterface, TranslationContainerInterface
{
private TranslatorInterface $translator;

public function __construct(TranslatorInterface $translator)
{
$this->translator = $translator;
}

public function getSortingDefinitions(): array
{
return [
new SortingDefinition(
'random',
$this->translator->trans('sort_definition.random.label'),
[
new SortClause\Random(),
adriendupuis marked this conversation as resolved.
Show resolved Hide resolved
],
400
),
];
}

public static function getTranslationMessages(): array
{
return [
(new Message('sort_definition.random.label', 'ibexa_search'))->setDesc('Shuffle'),
];
}
}
adriendupuis marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sort_definition.random.label: 'Shuffle'
7 changes: 7 additions & 0 deletions docs/administration/back_office/search_sorting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---

Check warning on line 1 in docs/administration/back_office/search_sorting.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/administration/back_office/search_sorting.md#L1

[Ibexa.ReadingLevel] The grade level is 8.53. Aim for 8th grade or lower by using shorter sentences and words.
Raw output
{"message": "[Ibexa.ReadingLevel] The grade level is 8.53. Aim for 8th grade or lower by using shorter sentences and words.", "location": {"path": "docs/administration/back_office/search_sorting.md", "range": {"start": {"line": 1, "column": 1}}}, "severity": "WARNING"}
adriendupuis marked this conversation as resolved.
Show resolved Hide resolved
description: Add a "sort by" method to the Back Office search result page.
---

- Implements `SortingDefinitionProviderInterface::getSortingDefinitions`
- Implements `TranslationContainerInterface::getTranslationMessages`
- Tag as `ibexa.search.sorting_definition.provider`
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ nav:
- Multi-file upload: administration/back_office/multifile_upload.md
- Sub-items list: administration/back_office/subitems_list.md
- Notifications: administration/back_office/notifications.md
- Customize search sorting: administration/back_office/search_sorting.md
adriendupuis marked this conversation as resolved.
Show resolved Hide resolved
- Content management:
- Content management: content_management/content_management.md
- Content management guide: content_management/content_management_guide.md
Expand Down