sonata-project / SonataUserBundle

Symfony SonataUserBundle
https://docs.sonata-project.org/projects/SonataUserBundle
MIT License
339 stars 488 forks source link

Using this bundle without SonataAdminBundle #1499

Closed supersmile2009 closed 2 years ago

supersmile2009 commented 2 years ago

Hi. Would making the SonataAdminBundle an optional dependency for v5 be something you could consider? It wouldn't be a BC break, since v5 is still in pre-release. And I could volunteer to implement the necessary changes. In fact running it without the Admin bundle was possible with v4 with a bit of trickery in composer.json. But service configuration in v5 makes things a bit more complicated. The key changes required to make it work are:

  1. Moving some config processing logic into this if block
    # Sonata\UserBundle\DependencyInjection\SonataUserExtension.php
        if (isset($bundles['SonataAdminBundle'])) {
            $loader->load('admin.php');
            $loader->load(sprintf('admin_%s.php', $config['manager_type']));
        }
  2. And sonata.user.twig.global (Sonata\UserBundle\Twig\GlobalVariables) shouldn't have a hard dependency on Sonata\AdminBundle\Admin\Pool.

Would you be open to such PR?

core23 commented 2 years ago

I'm not a big fan of optional dependencies. They can bring complex problems, e.g. if you want sonata admin functionality, but not for the user bundle. The user bundle could restrict you from installing the latest bundle.

That's why I forked this project and the FOSUserBundle. If you're interested in smaller, atomic feature bundles, you can try this:

VincentLanglet commented 2 years ago

I'm not a big fan of optional dependencies. They can bring complex problems, e.g. if you want sonata admin functionality, but not for the user bundle. The user bundle could restrict you from installing the latest bundle.

The SonataAdminBundle is already an optional dependency of

So I think it's not a bad idea to do the same for the SonataUserBundle and I would say PR are welcomed.

WDYT @jordisala1991 ?

jordisala1991 commented 2 years ago

I was about to look at the same info. If that is the case for others, PRs welcome indeed.