-
-
Notifications
You must be signed in to change notification settings - Fork 67
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
only load service.xml if SonataDoctrineORMAdminBundle is registered #151
Conversation
What if you don't use the ORM? |
ATM the file https://github.com/sonata-project/SonataTranslationBundle/blob/2.x/Resources/config/service.xml is always loaded. Maybe we should load it with a condition like the other services instead. |
afaik this bundle can also be used with the phpcr-odm admin (or at least it used to be possible at some time) so we should avoid a hard dependency. |
then we should suggest it? |
Yes, and we should add the missing condition in the config |
what do you mean? |
Add a check if the doctrine orm bundle is defined: |
Add a check if the doctrine orm bundle is defined:
https://github.com/sonata-project/SonataTranslationBundle/blob/2.x/DependencyInjection/SonataTranslationExtension.php#L39
please do not check for class_exists, but do
```php
$bundles = $container->getParameter('kernel.bundles');
if (array_key_exists('SonataDoctrineOrmAdminBundle', $bundles)) {
$loader->load('service_orm.xml');
}
```
and move the orm dependent services to a separate configuration file to
not skip loading everything.
|
I removed the dependency and added the check |
I updated the PR Header |
What about composer.json? No changes? |
shall we rename |
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 am not sure we need to suggest orm in composer.json. suggestions are used to tell there is additional features if the optional dependency is available. but this bundle adds additional features to the admins, so people already use orm and want translations, not the other way around.
$loader->load('service.xml'); | ||
|
||
$bundles = $container->getParameter('kernel.bundles'); | ||
if (array_key_exists('SonataDoctrineOrmAdminBundle', $bundles)) { |
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.
looking at the other places, its checking for phpcr.enabled. should we do the same here? or is there no explicit configuration for that?
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.
Not needed, imo, because we don't have a config node which can be enabled...
$rootNode
->children()
->arrayNode('locales')
->info('The list of your frontend locales in which your models will be translatable.')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->scalarNode('default_locale')
->defaultValue('en')
->info('The frontend locale that is used by default.')
->end()
->arrayNode('gedmo')
->canBeEnabled()
->children()
->arrayNode('implements')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->arrayNode('instanceof')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->end()
->end()
->arrayNode('knplabs')
->canBeEnabled()
->children()
->arrayNode('implements')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->arrayNode('instanceof')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->end()
->end()
->arrayNode('phpcr')
->canBeEnabled()
->children()
->arrayNode('implements')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->arrayNode('instanceof')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->end()
->end()
->end();
``
but how could we achieve this without a BC break, or shall I do this in
You are right @dbu |
i don't see renaming a service file as a BC break. people are not supposed to use those directly. and not loading dead services (that would trigger php fatal errors when trying to use) when not using sonata orm seems also not like a BC break to me. |
if somebody wrote a compiler pass to remove them instead of doing this bugfix PR you are now doing, they deserve at least some surprise. |
done |
Thanks @OskarStark ! |
Thanks for your feedback guys! |
I am targetting this branch, because this is BC.
Changelog