-
Notifications
You must be signed in to change notification settings - Fork 81
IBX-10885: Document Content Type search API #2946
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
base: 5.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| <?php declare(strict_types=1); | ||
|
|
||
| namespace App\Command; | ||
|
|
||
| use Ibexa\Contracts\Core\Repository\ContentTypeService; | ||
| use Ibexa\Contracts\Core\Repository\Values\ContentType\Query\ContentTypeQuery; | ||
| use Ibexa\Contracts\Core\Repository\Values\ContentType\Query\Criterion; | ||
| use Ibexa\Contracts\Core\Repository\Values\ContentType\Query\SortClause; | ||
| use Symfony\Component\Console\Attribute\AsCommand; | ||
| use Symfony\Component\Console\Command\Command; | ||
| use Symfony\Component\Console\Input\InputInterface; | ||
| use Symfony\Component\Console\Output\OutputInterface; | ||
|
|
||
| #[AsCommand( | ||
| name: 'doc:find_content_types', | ||
| description: 'Lists content types that match specific criteria.' | ||
| )] | ||
| class FindContentTypeCommand extends Command | ||
| { | ||
| public function __construct(private readonly ContentTypeService $contentTypeService) | ||
| { | ||
| parent::__construct(); | ||
| } | ||
|
|
||
| protected function execute(InputInterface $input, OutputInterface $output): int | ||
| { | ||
| // Find content types from the "Content" group that contains a specific field definition (in this case, a "Body" field). | ||
| $query = new ContentTypeQuery( | ||
| new Criterion\LogicalAnd([ | ||
| new Criterion\ContentTypeGroupId(['1']), | ||
|
Check failure on line 30 in code_samples/api/public_php_api/src/Command/FindContentTypeCommand.php
|
||
| new Criterion\ContainsFieldDefinitionId(['121']), | ||
|
Check failure on line 31 in code_samples/api/public_php_api/src/Command/FindContentTypeCommand.php
|
||
| ]), | ||
| [ | ||
| new SortClause\Id(), | ||
| new SortClause\Identifier(), | ||
| new SortClause\Name(), | ||
| ] | ||
| ); | ||
|
|
||
| $searchResult = $this->contentTypeService->findContentTypes($query); | ||
|
|
||
| $output->writeln('Found ' . $searchResult->totalCount . ' content type(s):'); | ||
|
|
||
| foreach ($searchResult->items as $contentType) { | ||
| $output->writeln(sprintf( | ||
| '- [%d] %s (identifier: %s)', | ||
| $contentType->id, | ||
| $contentType->getName(), | ||
| $contentType->identifier | ||
| )); | ||
| } | ||
|
|
||
| return Command::SUCCESS; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| --- | ||
|
Check warning on line 1 in docs/search/content_type_search_reference/content_type_criteria.md
|
||
| description: Content Type Search Criteria help define and fine-tune search queries for content types. | ||
| page_type: reference | ||
| month_change: true | ||
| --- | ||
|
|
||
| # Content Type Search Criteria reference | ||
|
|
||
| Content Type Search Criteria are only supported by Content Type Search (`ContentTypeService::findContentTypes`). | ||
|
Check warning on line 9 in docs/search/content_type_search_reference/content_type_criteria.md
|
||
|
|
||
| | Criterion | Description | | ||
| |-------|-------------| | ||
| | [ContainsFieldDefinitionId](api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-ContentType-Query-Criterion-ContainsFieldDefinitionId.html) | Matches content types that contain a field definition with the specified ID. | | ||
|
Check failure on line 13 in docs/search/content_type_search_reference/content_type_criteria.md
|
||
| | [ContentTypeGroupId](api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-ContentType-Query-Criterion-ContentTypeGroupId.html) | Matches content types by their assigned group ID. | | ||
|
Check failure on line 14 in docs/search/content_type_search_reference/content_type_criteria.md
|
||
| | [ContentTypeId](api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-ContentType-Query-Criterion-ContentTypeId.html) | Matches content types by their ID. | | ||
|
Check failure on line 15 in docs/search/content_type_search_reference/content_type_criteria.md
|
||
| | [ContentTypeIdentifier](api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-ContentType-Query-Criterion-ContentTypeIdentifier.html) | Matches content types by their identifier. | | ||
|
Check failure on line 16 in docs/search/content_type_search_reference/content_type_criteria.md
|
||
| | [IsSystem](api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-ContentType-Query-Criterion-IsSystem.html) | Matches content types based on whether the group they belong to is system or not. | | ||
|
Check failure on line 17 in docs/search/content_type_search_reference/content_type_criteria.md
|
||
| | [LogicalAnd](api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-ContentType-Query-Criterion-LogicalAnd.html) | Implements a logical AND Criterion. It matches if ALL of the provided Criteria match. | | ||
|
Check failure on line 18 in docs/search/content_type_search_reference/content_type_criteria.md
|
||
| | [LogicalOr](api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-ContentType-Query-Criterion-LogicalOr.html) | Implements a logical OR Criterion. It matches if at least one of the provided Criteria matches. | | ||
|
Check failure on line 19 in docs/search/content_type_search_reference/content_type_criteria.md
|
||
| | [LogicalNot](api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-ContentType-Query-Criterion-LogicalNot.html) | Implements a logical NOT Criterion. It matches if the provided Criterion doesn't match. | | ||
|
Check failure on line 20 in docs/search/content_type_search_reference/content_type_criteria.md
|
||
|
|
||
| For an example that shows how you can use the criteria to find content types, see [Finding and filtering content types](managing_content.md#finding-and-filtering-content-types). | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| --- | ||
|
Check warning on line 1 in docs/search/content_type_search_reference/content_type_sort_clauses.md
|
||
| description: Content Type Search Sort Clauses | ||
| month_change: true | ||
| --- | ||
|
|
||
| # Content Type Search Sort Clauses | ||
|
|
||
| Content Type Search Sort Clauses are the sorting options for content types. | ||
| They're only supported by [Content Type Search (`ContentTypeService::findContentTypes`)](managing_content.md#finding-and-filtering-content-types). | ||
|
|
||
| Sort Clauses are found in the [`Ibexa\Contracts\Core\Repository\Values\ContentType\Query\SortClause`](api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-ContentType-Query-SortClause.html) namespace: | ||
|
Check failure on line 11 in docs/search/content_type_search_reference/content_type_sort_clauses.md
|
||
|
|
||
| | Name | Description | | ||
| | --- | --- | | ||
| | [Id](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-ContentType-Query-SortClause-Id.html)| Sort by content type's id | | ||
|
Check failure on line 15 in docs/search/content_type_search_reference/content_type_sort_clauses.md
|
||
| | [Identifier](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-ContentType-Query-SortClause-Identifier.html)| Sort by content type's identifier | | ||
|
Check failure on line 16 in docs/search/content_type_search_reference/content_type_sort_clauses.md
|
||
| | [Name](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-ContentType-Query-SortClause-Name.html)| Sort by content type's name | | ||
|
Check failure on line 17 in docs/search/content_type_search_reference/content_type_sort_clauses.md
|
||
|
|
||
|
|
||
| The following example shows how to use them to sort the searched content items: | ||
|
|
||
| ```php hl_lines="17-19" | ||
| [[= include_file('code_samples/api/public_php_api/src/Command/FindContentTypeCommand.php', 17, 41) =]] | ||
| ``` | ||
|
|
||
| You can change the default sorting order by using the `SORT_ASC` and `SORT_DESC` constants from [`AbstractSortClause`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-CoreSearch-Values-Query-AbstractSortClause.html#constants). | ||
|
Check failure on line 26 in docs/search/content_type_search_reference/content_type_sort_clauses.md
|
||
Uh oh!
There was an error while loading. Please reload this page.