Skip to content

Conversation

@dabrt
Copy link
Contributor

@dabrt dabrt commented Nov 6, 2025

Question Answer
JIRA Ticket IBX-10885
Versions 4.6, 5.0
Edition all

Document Content Type search API

Checklist

  • Text renders correctly
  • Text has been checked with vale
  • Description metadata is up to date
  • Code samples are working
  • PHP code samples have been fixed with PHP CS fixer
  • Added link to this PR in relevant JIRA ticket or code PR

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

@dabrt dabrt requested a review from barw4 November 7, 2025 12:30
@github-actions
Copy link

code_samples/ change report

Before (on target branch)After (in current PR)

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


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

docs/content_management/content_api/managing_content.md@180:```php hl_lines="11-14"
docs/content_management/content_api/managing_content.md@181:[[= include_file('code_samples/api/public_php_api/src/Command/FindContentTypeCommand.php', 17, 41) =]]
docs/content_management/content_api/managing_content.md@182:```

001⫶class FindContentTypeCommand extends Command
002⫶{
003⫶ public function __construct(private readonly ContentTypeService $contentTypeService)
004⫶ {
005⫶ parent::__construct();
006⫶ }
007⫶
008⫶ protected function execute(InputInterface $input, OutputInterface $output): int
009⫶ {
010⫶ // Find content types from the "Content" group that contains a specific field definition (in this case, a "Body" field).
011❇️ $query = new ContentTypeQuery(
012❇️ new Criterion\LogicalAnd([
013❇️ new Criterion\ContentTypeGroupId(['1']),
014❇️ new Criterion\ContainsFieldDefinitionId(['121']),
015⫶ ]),
016⫶ [
017⫶ new SortClause\Id(),
018⫶ new SortClause\Identifier(),
019⫶ new SortClause\Name(),
020⫶ ]
021⫶ );
022⫶
023⫶ $searchResult = $this->contentTypeService->findContentTypes($query);

docs/search/content_type_search_reference/content_type_sort_clauses.md@22:```php hl_lines="17-19"
docs/search/content_type_search_reference/content_type_sort_clauses.md@23:[[= include_file('code_samples/api/public_php_api/src/Command/FindContentTypeCommand.php', 17, 41) =]]
docs/search/content_type_search_reference/content_type_sort_clauses.md@24:```

001⫶class FindContentTypeCommand extends Command
002⫶{
003⫶ public function __construct(private readonly ContentTypeService $contentTypeService)
004⫶ {
005⫶ parent::__construct();
006⫶ }
007⫶
008⫶ protected function execute(InputInterface $input, OutputInterface $output): int
009⫶ {
010⫶ // Find content types from the "Content" group that contains a specific field definition (in this case, a "Body" field).
011⫶ $query = new ContentTypeQuery(
012⫶ new Criterion\LogicalAnd([
013⫶ new Criterion\ContentTypeGroupId(['1']),
014⫶ new Criterion\ContainsFieldDefinitionId(['121']),
015⫶ ]),
016⫶ [
017❇️ new SortClause\Id(),
018❇️ new SortClause\Identifier(),
019❇️ new SortClause\Name(),
020⫶ ]
021⫶ );
022⫶
023⫶ $searchResult = $this->contentTypeService->findContentTypes($query);

Download colorized diff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants