-
-
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
WIP: Default injected services #3319
WIP: Default injected services #3319
Conversation
Did you see this documentation : https://sonata-project.org/bundles/admin/master/doc/reference/translation.html#label-strategies ? |
Oh my god no… how did I miss that ? |
I should add a search engine :) |
Yeah, and I should get some sleep :P |
I'm going to merge both docs. |
9d63a2a
to
831b7d7
Compare
After reading the compiler pass that applies the default translator strategy, I'm under the impression that the default actually is the native translator strategy.
It is the use case for definition lists.
Closes sonata-project#2419 When people configure this, they probably want to do it on a global basis rather than for each of their admins.
831b7d7
to
b4e7482
Compare
any news @greg0ire |
I'm waiting for your input on item 1. |
First of all, are we talking about a new feature or a fix? |
using an existing feature more easily by a global config option, right? |
It's a new feature : being able to configure strategies globally. For the moment, you have to set them admin by admin, which is a bit painful. I think the best would be if every bundle could have its own strategy : sonata_admin:
label_translator_strategy:
bundle1: some_strategy
bundle2: some_other_strategy |
exactly, that would avoid a lot of repetition if one's admin.yml |
what about: sonata_admin:
label_translator_strategy:
global: some_strategy
bundles:
bundle1: some_strategy
bundle2: some_other_strategy |
As new feature, it should be on master and not 2.3. |
Duly noted, I'll fix that |
@OskarStark : not sure about global : it could apply to vendor bundles that did not specify anything, and break their translations |
Maybe this would be better : sonata_admin:
label_translator_strategy:
bundles:
some_strategy: [bundle1, bundle2, bundle3]
some_other_strategy: [bundle4, bundle5] |
Although global should be optional, so if it breaks anything, "just do not use it" seems sensible |
Other question, what should |
you're right, global is not a great idea... like this version of you, it looks wrong with sonata_admin:
label_translator_strategy:
bundles:
some_strategy: [bundle1, bundle2, bundle3]
some_other_strategy: [bundle4, bundle5] i think you mean something like this? sonata_admin:
label_translator_strategy:
strategies:
some_strategy: [bundle1, bundle2, bundle3]
some_other_strategy: [bundle4, bundle5] |
Looks better indeed! What about the "bundle1" reference ? What would you actually use here ? |
I don't see the use case where this should be useful. It will be a pain to update the provided the translation for the new generated keys. |
sonata_admin:
label_translator_strategy:
strategies:
sonata.admin.label.strategy.native:
- app.admin.foo
- app.admin.bar
sonata.admin.label.strategy.underscore:
- app.admin.product i would recommend to use the admin service id, because the strategies are already applied on the admin service configuration, what do you think? |
It would not be configured globally by the bundle user. Instead, each bundle would merge their |
I was thinking about something more general, like a bundle name or a namespace prefix, so that you do not have to specify every admin in your bundle (it is unlikely that you would mix strategies in a given bundle, but you should still be able to by not using this new feature and sticking with what already exists). |
@rande :
You cannot change the defaults for all the admin in your bundle, can you ? You are forced to configure it for each and every admin, aren't you ? |
I think in the end it should look like that : # config.yml
sonata_admin:
label_translator_strategy:
bundles:
MyBundle: my_strategy_id Then, in sonataUserBundle, you would prepend this config: sonata_admin:
label_translator_strategy:
bundles:
SonataCoreBundle: whatever.strategy.is.used.in.the.core.bundle |
@greg0ire no, and I don't see the use case where you need to update all services. It is very sensible, and I guess it will be easier for someone you really want to do that to create a dedicated CompilerPass. |
if this should be implemented, it will be better to have: sonata_admin:
default_services:
model_manager: the service id
form_contractor: another service id
label_translator_strategy: sonata.admin.label.strategy.native |
@rande : here is how my admin.yml file looks at the moment : admin.library:
class: SomeAdmin
tags:
-
name: sonata.admin
manager_type: orm
label_translator_strategy: "sonata.admin.label.strategy.underscore"
admin.admin_entity:
class: SomeOtherADmin
tags:
-
name: sonata.admin
manager_type: orm
label_translator_strategy: "sonata.admin.label.strategy.underscore"
admin.prospect:
class: YetAnotherAdmin
tags:
-
name: sonata.admin
manager_type: orm
label_translator_strategy: "sonata.admin.label.strategy.underscore" How can I avoid repeating the |
Indeed, let's be more generic. But I think there should be an additional thing to specify : what should this defaults be limited to ? For instance, people probably do not want to change the strategy for, say, sonata_admin:
default_services:
my_bundle:
model_manager: the service id
form_contractor: another service id
label_translator_strategy: sonata.admin.label.strategy.native That way, SonataUserBundle can also specify its config and get it merged with |
@greg0ire you are also repeating the |
I wouldn't if I could…
That's not what I was looking for, I was looking for better DX
I get that, there are already many way to change the strategy, but it is not possible globally… too bad. But in the end it's your call, so I am closing. |
@greg0ire The feature can be implemented in a dedicated bundle, also I am not the only one to choose. I just raise my voice ;) |
Ok, @OskarStark @soullivaneuh , what do you think ? Useful or not ? Do not hesitate to say if not, I haven't coded anything yet, so, no worries :) |
what about using the proposition by @rande sonata_admin:
default_services:
model_manager: the service id
form_contractor: another service id
label_translator_strategy: sonata.admin.label.strategy.native but IF the strategy is set directly on an admin, this one gets used? same like the group for example: sonata.admin.group.settings:
label: navigation.folder.settings
label_catalogue: messages
icon: '<i class="fa fa-cog"></i>'
items:
- setting.admin.portal_setting services:
setting.admin.portal_setting:
class: SettingBundle\Admin\PortalSettingAdmin
arguments: [~, SettingBundle\Entity\PortalSetting, SettingBundle:CRUD]
tags:
- {name: sonata.admin, manager_type: orm, group: admin, label: Portal Setting List } In this case For the strategies i would like to use the reverse case. this already helps us to stay BC, because if its set directly on an admin, it works again |
My point exactly, we are going to replace the defaults in the compiler pass |
This is an RFC Some questions before I start :