Skip to content

Commit b0f2658

Browse files
committed
Implement reviewer comments
1 parent ba76f48 commit b0f2658

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

code_samples/api/public_php_api/src/Command/FindContentTypeCommand.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,24 @@ public function __construct(private readonly ContentTypeService $contentTypeServ
2424

2525
protected function execute(InputInterface $input, OutputInterface $output): int
2626
{
27-
// Find content types whose identifier is "folder" or "article",
28-
// or content type "user"
27+
// Find content types from the "Content" group that contains a specific field definition (in this case, a "Body" field).
2928
$query = new ContentTypeQuery(
30-
new Criterion\LogicalOr([
31-
new Criterion\LogicalAnd([
32-
new Criterion\ContentTypeIdentifier(['folder', 'article']),
33-
]),
34-
new Criterion\ContentTypeIdentifier(['user']),
29+
new Criterion\LogicalAnd([
30+
new Criterion\ContentTypeGroupId(['1']),
31+
new Criterion\ContainsFieldDefinitionId(['121']),
3532
]),
3633
[
3734
new SortClause\Id(),
38-
new SortClause\Identifiers(),
35+
new SortClause\Identifier(),
3936
new SortClause\Name(),
4037
]
4138
);
4239

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

45-
$output->writeln('Found ' . $searchResult->totalCount . ' content types:');
42+
$output->writeln('Found ' . $searchResult->totalCount . ' content type(s):');
4643

47-
foreach ($searchResult->searchHits as $searchHit) {
48-
$contentType = $searchHit->valueObject;
44+
foreach ($searchResult->items as $contentType) {
4945
$output->writeln(sprintf(
5046
'- [%d] %s (identifier: %s)',
5147
$contentType->id,

docs/content_management/content_api/managing_content.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ This method accepts a `ContentTypeQuery` object that supports filtering and sort
177177

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

180-
```php hl_lines="12-17"
181-
[[= include_file('code_samples/api/public_php_api/src/Command/FindContentTypeCommand.php', 17, 43) =]]
180+
```php hl_lines="11-14"
181+
[[= include_file('code_samples/api/public_php_api/src/Command/FindContentTypeCommand.php', 17, 41) =]]
182182
```
183183

184184
#### Query parameters

docs/search/content_type_search_reference/content_type_sort_clauses.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ Sort Clauses are found in the [`Ibexa\Contracts\Core\Repository\Values\ContentTy
1919

2020
The following example shows how to use them to sort the searched content items:
2121

22-
```php hl_lines="37-39"
23-
[[= include_file('code_samples/api/public_php_api/src/Command/FindContentTypeCommand.php') =]]
22+
```php hl_lines="17-19"
23+
[[= include_file('code_samples/api/public_php_api/src/Command/FindContentTypeCommand.php', 17, 41) =]]
2424
```
2525

2626
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).

0 commit comments

Comments
 (0)