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

only load service.xml if SonataDoctrineORMAdminBundle is registered #151

Merged
merged 2 commits into from
Feb 9, 2017

Conversation

OskarStark
Copy link
Member

@OskarStark OskarStark commented Feb 8, 2017

I am targetting this branch, because this is BC.

Changelog

### Changed
- renamed `service.xml` to `service_orm.xml`
- only load `service_orm.xml` if `SonataDoctrineORMAdminBundle` is registered

@greg0ire
Copy link
Contributor

greg0ire commented Feb 8, 2017

What if you don't use the ORM?

@core23
Copy link
Member

core23 commented Feb 8, 2017

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.

@dbu
Copy link
Contributor

dbu commented Feb 8, 2017

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.

@OskarStark
Copy link
Member Author

then we should suggest it?

@core23
Copy link
Member

core23 commented Feb 8, 2017

Yes, and we should add the missing condition in the config

@OskarStark
Copy link
Member Author

Yes, and we should add the missing condition in the config

what do you mean?

@core23
Copy link
Member

core23 commented Feb 9, 2017

@dbu
Copy link
Contributor

dbu commented Feb 9, 2017 via email

@OskarStark
Copy link
Member Author

I removed the dependency and added the check

@OskarStark OskarStark changed the title added doctrine-orm-admin-bundle as dependency for TranslationFieldFilter only load service.xml if SonataDoctrineORMAdminBundle is registered Feb 9, 2017
@OskarStark
Copy link
Member Author

I updated the PR Header

@greg0ire
Copy link
Contributor

greg0ire commented Feb 9, 2017

What about composer.json? No changes?

@OskarStark
Copy link
Member Author

shall we rename service.xml to service_orm.xml analogously to service_phpcr.xml ?

Copy link
Contributor

@dbu dbu left a 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)) {
Copy link
Contributor

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?

Copy link
Member Author

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();
``

@OskarStark
Copy link
Member Author

shall we rename service.xml to service_orm.xml analogously to service_phpcr.xml ?

but how could we achieve this without a BC break, or shall I do this in master afterwards?

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.

You are right @dbu

@dbu
Copy link
Contributor

dbu commented Feb 9, 2017

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.

@dbu
Copy link
Contributor

dbu commented Feb 9, 2017

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.

@OskarStark
Copy link
Member Author

done

@greg0ire greg0ire merged commit 8ce47d4 into sonata-project:2.x Feb 9, 2017
@greg0ire
Copy link
Contributor

greg0ire commented Feb 9, 2017

Thanks @OskarStark !

@OskarStark
Copy link
Member Author

Thanks for your feedback guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants