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 Criterion\LanguageCode example #2550

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

Conversation

adriendupuis
Copy link
Contributor

@adriendupuis adriendupuis commented Nov 25, 2024

Question Answer
JIRA Ticket N/A
Versions 4.6, master
Edition All

A clarified specification could be available in https://issues.ibexa.co/browse/IBX-9303

  • Add another …\Content\Query\Criterion\LanguageCode use case.
  • Use …\Content\Query with SearchService::findContent() instead of …\Content\LocationQuery.

Preview:

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

@adriendupuis adriendupuis marked this pull request as ready for review November 26, 2024 11:08
@adriendupuis adriendupuis requested a review from reithor November 26, 2024 11:08
@ibexa ibexa deleted a comment from github-actions bot Nov 26, 2024
Copy link

code_samples/ change report

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

code_samples/search/language/config/append_to_routes.yaml


code_samples/search/language/src/Command/SearchTestCommand.php


code_samples/search/language/config/append_to_routes.yaml


code_samples/search/language/src/Command/SearchTestCommand.php

docs/search/criteria_reference/languagecode_criterion.md@54:``` php hl_lines="3 6"
docs/search/criteria_reference/languagecode_criterion.md@55:[[= include_file('code_samples/search/language/src/Command/SearchTestCommand.php', 35, 47) =]]
docs/search/criteria_reference/languagecode_criterion.md@56:```

001⫶ $query = new Query(['query' => new Criterion\LogicalAnd([
002⫶ new Criterion\FullText($text),
003⫸ new Criterion\LanguageCode(['eng-GB'], false),
004⫶ ])]);
005⫶
006⫸ $results = $this->searchService->findContent($query, ['languages' => ['eng-GB', 'fre-FR', 'ger-DE']]);
007⫶ foreach ($results->searchHits as $searchHit) {
008⫶ /** @var \Ibexa\Core\Repository\Values\Content\Content $content */
009⫶ $content = $searchHit->valueObject;
010⫶ dump($content->getName('eng-GB'));
011⫶ }


code_samples/search/language/src/Controller/ArticlesToTranslateController.php


code_samples/search/language/src/Controller/ArticlesToTranslateController.php

docs/search/criteria_reference/languagecode_criterion.md@47:``` php hl_lines="5"
docs/search/criteria_reference/languagecode_criterion.md@48:[[= include_file('code_samples/search/language/src/Controller/ArticlesToTranslateController.php', 24, 41) =]]
docs/search/criteria_reference/languagecode_criterion.md@49:```

001⫶ $query = new Query();
002⫶ $query->query = new Criterion\LogicalAnd([
003⫶ new Criterion\ContentTypeIdentifier('article'),
004⫶ new Criterion\LogicalNot(
005⫸ new Criterion\LanguageCode($languageCode, false)
006⫶ ),
007⫶ ]);
008⫶
009⫶ $results = $this->searchService->findContent($query);
010⫶ $articles = [];
011⫶ foreach ($results->searchHits as $searchHit) {
012⫶ $articles[] = $searchHit->valueObject;
013⫶ }
014⫶
015⫶ return $this->render('@ibexadesign/list/articles_to_translate.html.twig', [
016⫶ 'articles' => $articles,
017⫶ ]);


code_samples/search/language/templates/themes/standard/list/articles_to_translate.html.twig


code_samples/search/language/templates/themes/standard/list/articles_to_translate.html.twig

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.

1 participant