-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[String] Slugger: Adding setSymbolsMap() #44199
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
Conversation
Am I right that there is no way to configure the `$ymbolsMap` when using the Symfony framework integration (i.e. dependency injection)? What about adding a public method for this? The feature to set it in the constructor was added in symfony#36456
Besides, it would be nice to be able to set global options for the slugger (i.e. at https://symfony.com/doc/current/reference/configuration/framework.html) - just like |
Given the reason why you wanted to introduce this method I think it would make more sense to introduce that possibility than adding the setter method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it was an intentional design decision to make the symbols map immutable. The map can be set via the constructor and you could easily wire your own configuration of the slugger if you need a different map.
Making the map configurable in FrameworkBundle could also be feasible, but I'm afraid that it's a bit too late to squeeze that into the already frozen 5.4 release.
Yep, this is intentional: having the service immutable is desired. |
Setter vs. configuration: Well, both would be nice ;-) If you're using the slugger in 100 services, you need the configuration; if you have one exception, you need the setter ;-) Version: I didn't really mean to get this into 5.4 ;-) This is the default
... and this looks like a "template" to me, showcasing how to set it up. So at least an easy way to get This is the first Symfony feature I'm seeing where the framework integration is harder to use than the standalone (cause you can't just pass it to the constructor). Shouldn't this be the other way round? "wire your own configuration" or "replacing the service definition": How does this work? |
No. You need a separate instance. If you use the setter for this exception, you also affect the usages done in other services after you called that setter. |
Should we close this one? |
Indeed, if I pass $services->set('slugger', AsciiSlugger::class)->args(['de', ['de' => ['&' => 'und']]]); However, if I pass $services->set('slugger', AsciiSlugger::class)->arg('$symbolsMap', ['de' => ['&' => 'und']]); Does anybody have an idea, why? |
Am I right that there is no way to configure the
$ymbolsMap
when using the Symfony framework integration (i.e. dependency injection)?What about adding a public method for this?
The feature to set it in the constructor was added in #36456
Waiting for feedback before continuing.