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

Enhance search doc #2540

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Enhance search doc #2540

wants to merge 4 commits into from

Conversation

adriendupuis
Copy link
Contributor

@adriendupuis adriendupuis commented Nov 12, 2024

Question Answer
JIRA Ticket
Versions
Edition

Checklist

  • Text renders correctly
  • Text has been checked with vale
  • Description metadata is up to date
  • Redirects cover removed/moved pages
  • 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

Copy link

code_samples/ change report

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

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

docs/search/search_api.md@134:``` php hl_lines="17"
docs/search/search_api.md@135:// ...
docs/search/search_api.md@136:[[= include_file('code_samples/api/public_php_api/src/Command/FilterLocationCommand.php', 4, 9) =]]// ...
docs/search/search_api.md@137:[[= include_file('code_samples/api/public_php_api/src/Command/FilterLocationCommand.php', 32, 52) =]]
docs/search/search_api.md@138:```

001⫶// ...
002⫶use Ibexa\Contracts\Core\Repository\LocationService;
003⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query;
004⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
005⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause;
006⫶use Ibexa\Contracts\Core\Repository\Values\Filter\Filter;
007⫶// ...
008⫶ protected function execute(InputInterface $input, OutputInterface $output): int
009⫶ {
010⫶ $parentLocationId = (int)$input->getArgument('parentLocationId');
011⫶
012⫶ $filter = new Filter();
013⫶ $filter
014⫶ ->withCriterion(new Criterion\ParentLocationId($parentLocationId))
015⫶ ->withSortClause(new SortClause\ContentName(Query::SORT_DESC));
016⫶
017⫸ $result = $this->locationService->find($filter, []);
018⫶

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

docs/search/search_api.md@134:``` php hl_lines="17"
docs/search/search_api.md@135:// ...
docs/search/search_api.md@136:[[= include_file('code_samples/api/public_php_api/src/Command/FilterLocationCommand.php', 4, 9) =]]// ...
docs/search/search_api.md@137:[[= include_file('code_samples/api/public_php_api/src/Command/FilterLocationCommand.php', 32, 52) =]]
docs/search/search_api.md@138:```

001⫶// ...
002⫶use Ibexa\Contracts\Core\Repository\LocationService;
003⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query;
004⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
005⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause;
006⫶use Ibexa\Contracts\Core\Repository\Values\Filter\Filter;
007⫶// ...
008⫶ protected function execute(InputInterface $input, OutputInterface $output): int
009⫶ {
010⫶ $parentLocationId = (int)$input->getArgument('parentLocationId');
011⫶
012⫶ $filter = new Filter();
013⫶ $filter
014⫶ ->withCriterion(new Criterion\ParentLocationId($parentLocationId))
015⫶ ->withSortClause(new SortClause\ContentName(Query::SORT_DESC));
016⫶
017⫸ $result = $this->locationService->find($filter, []);
018⫶
019⫶        $output->writeln('Found ' . $result->totalCount . ' items');
019⫶        $output->writeln('Found ' . $result->getTotalCount() . ' items');
020⫶
021⫶ foreach ($result as $content) {
022⫶ $output->writeln($content->getContent()->getName());
023⫶ }
024⫶
025⫶ return self::SUCCESS;
026⫶ }
027⫶}

020⫶
021⫶ foreach ($result as $content) {
022⫶ $output->writeln($content->getContent()->getName());
023⫶ }
024⫶
025⫶ return self::SUCCESS;
026⫶ }
027⫶}

Download colorized diff

@adriendupuis adriendupuis marked this pull request as ready for review November 15, 2024 12:55
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.

1 participant