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

Disable group support in FOSUserBundle #999

Closed
lukepass opened this issue Jan 18, 2018 · 10 comments
Closed

Disable group support in FOSUserBundle #999

lukepass opened this issue Jan 18, 2018 · 10 comments

Comments

@lukepass
Copy link

In the guide for FOS User Bundle there is an option to disable groups:

https://symfony.com/doc/current/bundles/FOSUserBundle/groups.html

There is also a note:

Symfony supports role inheritance so inheriting roles from groups is not always needed. If the role inheritance is enough for your use case, it is better to use it instead of groups as it is more efficient (loading the groups triggers the database).

I tried to disable it using SonataUserBundle but it complains about a missing parameter:

  [Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException]                            
  The service "sonata.user.orm.group_manager" has a dependency on a non-existent parameter "fos_user.mod  
  el.group.class". Did you mean this: "fos_user.model.user.class"?    

Is there a solution for it?

Environment

Symfony 2.8

Composer packages

$ composer show
cocur/slugify                            v3.0.1  Converts a string into a slug.
doctrine/annotations                     v1.6.0  Docblock Annotations Parser
doctrine/cache                           v1.7.1  Caching library offering an object-oriented API for m...
doctrine/collections                     v1.5.0  Collections Abstraction library
doctrine/common                          v2.8.1  Common Library for Doctrine projects
doctrine/dbal                            v2.6.3  Database Abstraction Layer
doctrine/doctrine-bundle                 1.8.1   Symfony DoctrineBundle
doctrine/doctrine-cache-bundle           1.3.2   Symfony Bundle for Doctrine Cache
doctrine/inflector                       v1.3.0  Common String Manipulations with regard to casing and...
doctrine/instantiator                    1.1.0   A small, lightweight utility to instantiate objects i...
doctrine/lexer                           v1.0.1  Base library for a lexer that can be used in Top-Down...
doctrine/orm                             v2.5.14 Object-Relational-Mapper for PHP
friendsofsymfony/user-bundle             v2.0.2  Symfony FOSUserBundle
imagine/imagine                          v0.6.3  Image processing for PHP 5.3
incenteev/composer-parameter-handler     v2.1.2  Composer script handling your ignored parameter file
ircmaxell/password-compat                v1.0.4  A compatibility library for the proposed simplified p...
jdorn/sql-formatter                      v1.2.17 a PHP SQL highlighting library
jms/metadata                             1.6.0   Class/method/property metadata management in PHP
jms/parser-lib                           1.0.0   A library for easily creating recursive-descent parsers.
jms/serializer                           1.10.0  Library for (de-)serializing data of any complexity; ...
jms/serializer-bundle                    2.3.1   Allows you to easily serialize, and deserialize data ...
knplabs/gaufrette                        v0.3.1  PHP5 library that provides a filesystem abstraction l...
knplabs/knp-menu                         2.3.0   An object oriented menu library
knplabs/knp-menu-bundle                  v2.2.1  This bundle provides an integration of the KnpMenu li...
kriswallsmith/buzz                       v0.15.2 Lightweight HTTP client
monolog/monolog                          1.23.0  Sends your logs to files, sockets, inboxes, databases...
paragonie/random_compat                  v2.0.11 PHP 5.x polyfill for random_bytes() and random_int() ...
phpcollection/phpcollection              0.5.0   General-Purpose Collection Library for PHP
phpoption/phpoption                      1.5.0   Option Type for PHP
psr/log                                  1.0.2   Common interface for logging libraries
sensio/distribution-bundle               v4.0.39 Base bundle for Symfony Distributions
sensio/framework-extra-bundle            v3.0.29 This bundle provides a way to configure your controll...
sensio/generator-bundle                  v3.1.7  This bundle generates code for you
sensiolabs/security-checker              v3.0.7  A security checker for your composer.lock
sonata-project/admin-bundle              3.30.1  The missing Symfony Admin Generator
sonata-project/block-bundle              3.10.0  Symfony SonataBlockBundle
sonata-project/cache                     2.0.1   Cache library
sonata-project/core-bundle               3.9.0   Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.3.1   Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.0.2   Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.4.0   Symfony Sonata / Integrate Doctrine ORM into the Sona...
sonata-project/easy-extends-bundle       2.3.1   Symfony SonataEasyExtendsBundle
sonata-project/exporter                  1.8.0   Lightweight Exporter library
sonata-project/media-bundle              3.10.0  Symfony SonataMediaBundle
sonata-project/notification-bundle       3.2.0   Symfony SonataNotificationBundle
sonata-project/user-bundle               4.0.1   Symfony SonataUserBundle
swiftmailer/swiftmailer                  v5.4.8  Swiftmailer, free feature-rich PHP mailer
symfony/monolog-bundle                   v3.1.2  Symfony MonologBundle
symfony/phpunit-bridge                   v2.8.33 Symfony PHPUnit Bridge
symfony/polyfill-apcu                    v1.6.0  Symfony polyfill backporting apcu_* functions to lowe...
symfony/polyfill-intl-icu                v1.6.0  Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring                v1.6.0  Symfony polyfill for the Mbstring extension
symfony/polyfill-php54                   v1.6.0  Symfony polyfill backporting some PHP 5.4+ features t...
symfony/polyfill-php55                   v1.6.0  Symfony polyfill backporting some PHP 5.5+ features t...
symfony/polyfill-php56                   v1.6.0  Symfony polyfill backporting some PHP 5.6+ features t...
symfony/polyfill-php70                   v1.6.0  Symfony polyfill backporting some PHP 7.0+ features t...
symfony/polyfill-util                    v1.6.0  Symfony utilities for portability of PHP codes
symfony/security-acl                     v3.0.1  Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle               v2.6.7  Symfony SwiftmailerBundle
symfony/symfony                          v2.8.33 The Symfony PHP framework
twig/extensions                          v1.5.1  Common additional features for Twig that do not direc...
twig/twig                                v2.4.4  Twig, the flexible, fast, and secure template languag...
zendframework/zenddiagnostics            v1.1.0  A set of components for performing diagnostic tests i...

PHP version

$ php -v
PHP 7.1.13-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Jan  5 2018 13:26:45) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.13-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies
@greg0ire
Copy link
Contributor

Hmm so this parameter should be nullable? I know the sf DIC supports nullable services, but does it support nullable parameters?

@lukepass
Copy link
Author

It seems yes but only with XML declaration:

https://symfony.com/doc/current/service_container/optional_dependencies.html

@greg0ire
Copy link
Contributor

Good thing we use XML then

@greg0ire
Copy link
Contributor

I think the group manager shouldn't even be defined in that case, which would mean splitting this file:

<service id="sonata.user.orm.group_manager" class="Sonata\UserBundle\Entity\GroupManager" public="false">

And loading it conditionally, based on the existence of the parameter. Not sure what other problem could arise after that. Would you like to give it a try @lukepass ?

@lukepass
Copy link
Author

Hello, I am embarassed but I never forked and edited a GitHub project :)
I could try and edit it! Could you please guide me a bit about the files using that conf and how could I make a pull request for a public project?

Thanks.

@greg0ire
Copy link
Contributor

Don't be embarrassed, it's OK, props for willing to do it. I'm in the train right now, so I'll give more details later, but first step would be to figure out if this can work, which you can assess without any forking, just by applying the suggestion on the files inside your vendor directory.

@Hanmac
Copy link
Contributor

Hanmac commented Jan 19, 2018

while doing a way to disable the GroupManager, can we talk about if we really need different manager for both Entity and Document or if a another way to optimise that?
i currently don't see the benefit of the SonataUserManager and SonataGroupManager compared to the FosUser ones?

if we need to do something there, why not use service decoration?
https://symfony.com/doc/current/service_container/service_decoration.html

@mauriau
Copy link

mauriau commented Apr 5, 2018

Hello, I got the same issue, I want to disable the BaseGroup entity from Sonata. Is it possible ?

@jordisala1991
Copy link
Member

Not for now Im afraid. Feel free to provide a PR

@stale
Copy link

stale bot commented Jan 30, 2020

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the wontfix label Jan 30, 2020
@SonataCI SonataCI removed the wontfix label Jan 30, 2020
@core23 core23 added the stale label Feb 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants