Skip to content
Open
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
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

View workflow job for this annotation

GitHub Actions / Validate code samples (8.3)

Parameter #1 $value of class Ibexa\Contracts\Core\Repository\Values\ContentType\Query\Criterion\ContentTypeGroupId constructor expects int|list<int>, array{'1'} given.
new Criterion\ContainsFieldDefinitionId(['121']),

Check failure on line 31 in code_samples/api/public_php_api/src/Command/FindContentTypeCommand.php

View workflow job for this annotation

GitHub Actions / Validate code samples (8.3)

Parameter #1 $value of class Ibexa\Contracts\Core\Repository\Values\ContentType\Query\Criterion\ContainsFieldDefinitionId constructor expects int|list<int>, array{'121'} given.
]),
[
new SortClause\Id(),
new SortClause\Identifier(),
new SortClause\Name(),
]
);

$searchResult = $this->contentTypeService->findContentTypes($query);

$output->writeln('Found ' . $searchResult->totalCount . ' content type(s):');

Check failure on line 42 in code_samples/api/public_php_api/src/Command/FindContentTypeCommand.php

View workflow job for this annotation

GitHub Actions / Validate code samples (8.3)

Access to protected property Ibexa\Contracts\Core\Repository\Values\ContentType\SearchResult::$totalCount.

foreach ($searchResult->items as $contentType) {

Check failure on line 44 in code_samples/api/public_php_api/src/Command/FindContentTypeCommand.php

View workflow job for this annotation

GitHub Actions / Validate code samples (8.3)

Access to protected property Ibexa\Contracts\Core\Repository\Values\ContentType\SearchResult::$items.
$output->writeln(sprintf(
'- [%d] %s (identifier: %s)',
$contentType->id,
$contentType->getName(),
$contentType->identifier
));
}

return Command::SUCCESS;
}
}
29 changes: 29 additions & 0 deletions docs/content_management/content_api/managing_content.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,35 @@
[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 87, 93) =]]
```

### Finding and filtering content types

You can find content types that match specific criteria by using the `ContentTypeService::findContentTypes()` method.
This method accepts a `ContentTypeQuery` object that supports filtering and sorting by IDs, identifiers, group membership, and other criteria.

!!! note "Criterions and sort clauses"

Check failure on line 173 in docs/content_management/content_api/managing_content.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content_management/content_api/managing_content.md#L173

[Ibexa.DomainTermCapitalization] Use 'Sort Clause(s)' instead of 'sort clauses'
Raw output
{"message": "[Ibexa.DomainTermCapitalization] Use 'Sort Clause(s)' instead of 'sort clauses'", "location": {"path": "docs/content_management/content_api/managing_content.md", "range": {"start": {"line": 173, "column": 26}}}, "severity": "ERROR"}

For a full list of available criterions and sort clauses that you can use when finding and filtering content types, see [Content Type Search Criteria](content_type_criteria.md) and [Content Type Search Sort Clauses](content_type_sort_clauses.md) references.


The following example shows how you can use the criteria to find content types:

```php hl_lines="11-14"
[[= include_file('code_samples/api/public_php_api/src/Command/FindContentTypeCommand.php', 17, 41) =]]
```

#### Query parameters

When constructing a `ContentTypeQuery`, you can pass the following parameters:

- `?CriterionInterface $criterion = null` — a filter to apply (use one or a combination of the criterions above)

- `array $sortClauses = []` — list of sort clauses to order the results

Check failure on line 190 in docs/content_management/content_api/managing_content.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/content_management/content_api/managing_content.md#L190

[Ibexa.DomainTermCapitalization] Use 'Sort Clause(s)' instead of 'sort clauses'
Raw output
{"message": "[Ibexa.DomainTermCapitalization] Use 'Sort Clause(s)' instead of 'sort clauses'", "location": {"path": "docs/content_management/content_api/managing_content.md", "range": {"start": {"line": 190, "column": 39}}}, "severity": "ERROR"}

- `int $offset = 0` — starting offset (for pagination)

- `int $limit = 25` — maximum number of results to return


## Calendar events

You can handle the calendar using `CalendarServiceInterface` (`Ibexa\Contracts\Calendar\CalendarServiceInterface`).
Expand Down
22 changes: 22 additions & 0 deletions docs/search/content_type_search_reference/content_type_criteria.md
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

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/search/content_type_search_reference/content_type_criteria.md#L1

[Ibexa.ReadingLevel] The grade level is 10.12. Aim for 8th grade or lower by using shorter sentences and words.
Raw output
{"message": "[Ibexa.ReadingLevel] The grade level is 10.12. Aim for 8th grade or lower by using shorter sentences and words.", "location": {"path": "docs/search/content_type_search_reference/content_type_criteria.md", "range": {"start": {"line": 1, "column": 1}}}, "severity": "WARNING"}
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

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/search/content_type_search_reference/content_type_criteria.md#L9

[Ibexa.DontCapitalize] Don't capitalize 'Content Type' if inside the sentence.
Raw output
{"message": "[Ibexa.DontCapitalize] Don't capitalize 'Content Type' if inside the sentence.", "location": {"path": "docs/search/content_type_search_reference/content_type_criteria.md", "range": {"start": {"line": 9, "column": 1}}}, "severity": "WARNING"}

| 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

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/search/content_type_search_reference/content_type_criteria.md#L13

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/search/content_type_search_reference/content_type_criteria.md", "range": {"start": {"line": 13, "column": 69}}}, "severity": "ERROR"}
| [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

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/search/content_type_search_reference/content_type_criteria.md#L14

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/search/content_type_search_reference/content_type_criteria.md", "range": {"start": {"line": 14, "column": 62}}}, "severity": "ERROR"}
| [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

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/search/content_type_search_reference/content_type_criteria.md#L15

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/search/content_type_search_reference/content_type_criteria.md", "range": {"start": {"line": 15, "column": 57}}}, "severity": "ERROR"}
| [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

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/search/content_type_search_reference/content_type_criteria.md#L16

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/search/content_type_search_reference/content_type_criteria.md", "range": {"start": {"line": 16, "column": 65}}}, "severity": "ERROR"}
| [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

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/search/content_type_search_reference/content_type_criteria.md#L17

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/search/content_type_search_reference/content_type_criteria.md", "range": {"start": {"line": 17, "column": 52}}}, "severity": "ERROR"}
| [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

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/search/content_type_search_reference/content_type_criteria.md#L18

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/search/content_type_search_reference/content_type_criteria.md", "range": {"start": {"line": 18, "column": 54}}}, "severity": "ERROR"}
| [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

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/search/content_type_search_reference/content_type_criteria.md#L19

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/search/content_type_search_reference/content_type_criteria.md", "range": {"start": {"line": 19, "column": 53}}}, "severity": "ERROR"}
| [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

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/search/content_type_search_reference/content_type_criteria.md#L20

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/search/content_type_search_reference/content_type_criteria.md", "range": {"start": {"line": 20, "column": 54}}}, "severity": "ERROR"}

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

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/search/content_type_search_reference/content_type_sort_clauses.md#L1

[Ibexa.ReadingLevel] The grade level is 14.39. Aim for 8th grade or lower by using shorter sentences and words.
Raw output
{"message": "[Ibexa.ReadingLevel] The grade level is 14.39. Aim for 8th grade or lower by using shorter sentences and words.", "location": {"path": "docs/search/content_type_search_reference/content_type_sort_clauses.md", "range": {"start": {"line": 1, "column": 1}}}, "severity": "WARNING"}
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

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/search/content_type_search_reference/content_type_sort_clauses.md#L11

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/search/content_type_search_reference/content_type_sort_clauses.md", "range": {"start": {"line": 11, "column": 141}}}, "severity": "ERROR"}

| 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

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/search/content_type_search_reference/content_type_sort_clauses.md#L15

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/search/content_type_search_reference/content_type_sort_clauses.md", "range": {"start": {"line": 15, "column": 47}}}, "severity": "ERROR"}
| [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

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/search/content_type_search_reference/content_type_sort_clauses.md#L16

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/search/content_type_search_reference/content_type_sort_clauses.md", "range": {"start": {"line": 16, "column": 55}}}, "severity": "ERROR"}
| [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

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/search/content_type_search_reference/content_type_sort_clauses.md#L17

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/search/content_type_search_reference/content_type_sort_clauses.md", "range": {"start": {"line": 17, "column": 49}}}, "severity": "ERROR"}


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

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/search/content_type_search_reference/content_type_sort_clauses.md#L26

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/search/content_type_search_reference/content_type_sort_clauses.md", "range": {"start": {"line": 26, "column": 159}}}, "severity": "ERROR"}
2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ nav:
- LogicalAnd Criterion: search/criteria_reference/logicaland_criterion.md
- LogicalNot Criterion: search/criteria_reference/logicalnot_criterion.md
- LogicalOr Criterion: search/criteria_reference/logicalor_criterion.md
- Content Type Search Criteria: search/content_type_search_reference/content_type_criteria.md
- Product Search Criteria:
- Product Search Criteria: search/criteria_reference/product_search_criteria.md
- AttributeName: search/criteria_reference/attributename_criterion.md
Expand Down Expand Up @@ -705,6 +706,7 @@ nav:
- SectionName: search/sort_clause_reference/sectionname_sort_clause.md
- UserLogin: search/sort_clause_reference/userlogin_sort_clause.md
- Visibility: search/sort_clause_reference/visibility_sort_clause.md
- Content Type Sort Clauses: search/content_type_search_reference/content_type_sort_clauses.md
- Product Sort Clauses:
- Product Sort Clauses: search/sort_clause_reference/product_sort_clauses.md
- BasePrice: search/sort_clause_reference/baseprice_sort_clause.md
Expand Down
Loading