documentation-developer
documentation-developer copied to clipboard
Documented CustomField criterion
Target: 5.0, 4.6
As reported on Slack - https://doc.ibexa.co/en/latest/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-Query-Criterion-CustomField.html is missing from the list
Tested on Solr and Elasticsearch with the following command:
<?php
namespace App;
use DateTimeImmutable;
use Ibexa\Collaboration\SessionService;
use Ibexa\Contracts\Collaboration\Session\SessionQuery;
use Ibexa\Contracts\Core\Repository\ContentService;
use Ibexa\Contracts\Core\Repository\PermissionResolver;
use Ibexa\Contracts\Core\Repository\SearchService;
use Ibexa\Contracts\Core\Repository\UserService;
use Ibexa\Contracts\Core\Repository\Values\Content\Content;
use Ibexa\Contracts\Collaboration\Session\Query\Criterion;
use Ibexa\Contracts\Collaboration\Session\Query\SortClause;
use Ibexa\Contracts\Core\Repository\Values\Content\Query;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator;
use Ibexa\Contracts\CoreSearch\Values\Query\SortClause\FieldValueSortClause;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Ibexa\Contracts\CoreSearch\Values\Query\Criterion\FieldValueCriterion;
class SearchCommand extends Command
{
protected static $defaultName = 'app:search';
private SearchService $searchService;
private PermissionResolver $permissionResolver;
private UserService $userService;
private ContentService $contentService;
private SessionService $sessionService;
public function __construct(
SearchService $searchService,
PermissionResolver $permissionResolver,
UserService $userService,
ContentService $contentService,
SessionService $sessionService
)
{
parent::__construct();
$this->searchService = $searchService;
$this->permissionResolver = $permissionResolver;
$this->userService = $userService;
$this->contentService = $contentService;
$this->sessionService = $sessionService;
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->permissionResolver->setCurrentUserReference($this->userService->loadUserByLogin('admin'));
$query = new Query();
$query->query = new Query\Criterion\CustomField('content_translated_name_s', Operator::EQ, 'Default');
$query->offset = 0;
$query->limit = 10;
$query->sortClauses = [new Query\SortClause\ContentId()];
$output->writeln('Searching content!');
$result = $this->searchService->findContent($query);
foreach ($result->searchHits as $searchHit) {
/** @var Content $content */
$content = $searchHit->valueObject;
$output->writeln('Found content: ' . $content->getName() . 'Section: ' . $content->getContentInfo()->getSection()->name);
}
return 0;
}
}
Preview of modified files
Preview of modified Markdown:
code_samples/ change report
| Before (on target branch) | After (in current PR) |
|---|---|
|
|
|