Skip to content
This repository has been archived by the owner on Nov 15, 2018. It is now read-only.

Additional service options #54

Open
akomm opened this issue Aug 22, 2016 · 6 comments
Open

Additional service options #54

akomm opened this issue Aug 22, 2016 · 6 comments

Comments

@akomm
Copy link

akomm commented Aug 22, 2016

I want to also add public: false property to all Voters.
I have the following entry:

dunglas_action:
  directories:
    - '../src/AppBundle/Security/Voter'
  tags:
    Symfony\Component\Security\Core\Authorization\Voter\VoterInterface:
      - 'security.voter'

I would not like to define all the Voter services, just because I want them all to be private.
Do you think a config key for options (excluding autowire) would be a good solution for this?

dunglas_action:
  options:
    # or by directory?
    Symfony\Component\Security\Core\Authorization\Voter\VoterInterface:
      public: false
@GuilhemN
Copy link
Contributor

GuilhemN commented Aug 22, 2016

👍
What about:

dunglas_action:
    must_be_public:
        - Symfony\Component\Security\Core\Authorization\Voter\VoterInterface

and make all the others private (or maybe also add an option for that)?

IMO every service should be able to be private but it was refused in the core.

@dunglas
Copy link
Owner

dunglas commented Aug 22, 2016

Why not using a user-land compiler pass for that? You can do a simple check on the namespace.

@GuilhemN
Copy link
Contributor

GuilhemN commented Aug 22, 2016

@dunglas that's indeed already possible but it complexify the installation of the bundle.
Including it here would also permit to follow the core autowiring behavior (private by default).

@akomm
Copy link
Author

akomm commented Aug 22, 2016

👍 private by default and public by option sounds good.

@theofidry
Copy link
Contributor

theofidry commented Oct 19, 2016

👎 for private services by default, I would rather just follow the Symfony convention here. As services are not private by default (although there is an issue to change that, symfony/symfony#20048), I don't think it should be done here.

Instead of just having tags, why not having services instead to which we can append things to the service definition, i.e. tags and public properties?

dunglas_action:
    services:
        'Symfony\Component\Security\Core\Authorization\Voter\VoterInterface':
            tags: [ name: 'mytag' ]
            public: false

EDIT: actually isn't it already doable by overriding the service definition?

services:
    'Symfony\Component\Security\Core\Authorization\Voter\VoterInterface':
        tags: [ name: 'mytag' ]
        public: false

@magarzon
Copy link

I have created a CompilerPass for another "service option" that resolves a "problem" with the "autotag" feature: if you need to set a priority for a service, then you can't use autotag.

I have implemented an interface PrioritizedInterface with a method getPriority, and the CompilerPass searches for services with this interface and set the priority calling this method.

That way I can use autotag and priority.

If you think this is of interest for this bundle, I can make a PR

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

No branches or pull requests

5 participants