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

[Sluggable] getSimilarSlugs with locale context #2530

Closed
tharsanvn opened this issue Oct 31, 2022 · 3 comments · Fixed by #2620
Closed

[Sluggable] getSimilarSlugs with locale context #2530

tharsanvn opened this issue Oct 31, 2022 · 3 comments · Fixed by #2620

Comments

@tharsanvn
Copy link

When using sluggable with translations the getSimilarSlugs method must use the entity object locale:

example in Gedmo\Sluggable\Mapping\Event\Adapter\ORM

...
$q = $qb->getQuery();

$q->setHint(
  Query::HINT_CUSTOM_OUTPUT_WALKER,
  'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker'
);

$q->setHint(
  TranslatableListener::HINT_TRANSLATABLE_LOCALE,
  $locale // got with object parameter
);

$q->setHydrationMode(Query::HYDRATE_ARRAY);
        
return $q->execute();
...
@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Apr 29, 2023
@ambroisemaupate
Copy link
Contributor

This does not require to set locale : just adding

$q->setHint(
    Query::HINT_CUSTOM_OUTPUT_WALKER,
    \Gedmo\Translatable\Query\TreeWalker\TranslationWalker::class
);

will work.

This would fix #100

ambroisemaupate added a commit to ambroisemaupate/DoctrineExtensions that referenced this issue May 24, 2023
…oking for similar slugs

Force translation walker to look for slug translations to avoid duplicated slugs.

---

Fixes doctrine-extensions#100, fixes doctrine-extensions#2530
@github-actions github-actions bot removed the Stale label Jun 19, 2023
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Dec 16, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 15, 2024
franmomu pushed a commit to ambroisemaupate/DoctrineExtensions that referenced this issue Jun 9, 2024
…oking for similar slugs

Force translation walker to look for slug translations to avoid duplicated slugs.

---

Fixes doctrine-extensions#100, fixes doctrine-extensions#2530
franmomu added a commit that referenced this issue Jun 9, 2024
…ng for similar slugs (#2620)

* fix(Sluggable): Use TranslationWalker for Translatable object when looking for similar slugs

Force translation walker to look for slug translations to avoid duplicated slugs.

---

Fixes #100, fixes #2530

* chore: Added CHANGELOG notice

* chore: Missing issue references to CHANGELOG entry

* chore: Added Sluggable/Issue/Issue100Test

* chore: Rewrite changelog entry and phpstan fix

* feat(Sluggable): Added new option `uniqueOverTranslations` to enable uniqueness across translated slug as well

* chore: Move `$uniqueOverTranslations` new argument at the end for BC

* chore: Missing `uniqueOverTranslations` option in legacy annotation

* docs: Moved Changelog entry to Unreleased section

* Update Changelog

* Fix PHPStan types

* Fix tests

* Make mandatory keys in SlugConfiguration

* Add a check for YAML driver

---------

Co-authored-by: Fran Moreno <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants