-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 handlers (only available in annotations) #2841
Comments
When PHP 8.0 released, you couldn't instantiate objects in attributes, so this syntax wasn't valid: #[Gedmo\Slug(handlers: [new Gedmo\SlugHandler()])] As a side effect, projects providing annotations that had nested annotations needed to adjust how those nested objects were processed. Usually, that meant promoting those nested objects to the top level, such as: #[Gedmo\Slug]
#[Gedmo\SlugHandler] The Doctrine ORM has similar examples of this (compare the One of the features of PHP 8.1 (see https://stitcher.io/blog/php-81-new-in-initializers for more on that) removed that limitation. So, technically, the annotations syntax could be supported in the attributes mapping driver for PHP 8.1 and later, but at this point I personally don't trying to support both options in the attribute driver (both the original implementation and bringing back the annotation-related nested structure) is worth the effort. |
Can slug handler being chained in order to have multiple RelativeSlugHandler ? |
Yes, you can configure multiple slug handlers, see this test fixture as an example with both annotations and attributes. If your question is specifically whether you can have multiple RelativeSlugHandler's with different configurations for one property, I truthfully don't know as I've not personally used that feature. |
That's exactly what I want, I'd like the slug being build based on relations fields. And only the last relativeSlugHandler was user to build the slug. |
OK, well that's a separate feature request from this item (which is mainly about the config difference between annotations and attributes). On a quick glance, it seems like the mapping driver keys the handlers array by class name, so that would definitely preclude multiple slug handlers of the same type being used on one property. I was going to say maybe there's a way to work around it with a custom chain implementation of the |
Thank you ill dig into it and keep this post updated |
Hello,
I using doctrine-extension and I wodering why the argument
handlers
inside@Gedmo\Slug
is available in annotations and not in attributes ?It is a technical constraint or could I help with an PR ?
Thank you for anwser.
Have a nice day :-)
The text was updated successfully, but these errors were encountered: