Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ServiceSubscriberInterface, voters and private services issue #89

Open
@vandroids

Description

Support question

Hello!
I'm trying to use ServiceSubscriberInterface after reading this article https://symfonycasts.com/screencast/symfony-doctrine/service-subscriber

They suggest to use service locator pattern for the sake of performance in voters.
And the problem is this:

namespace App\Voters;
use Psr\Container\ContainerInterface;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
use Symfony\Contracts\Service\ServiceSubscriberInterface;
class MyVoter extends Voter implements ServiceSubscriberInterface
{
 /**
 * @var ContainerInterface
 */
 private $container;
 public function __construct(ContainerInterface $container)
 {
 $this->container = $container;
 }
 protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
 {
 $this->container->get(AccessDecisionManagerInterface::class)->decide...
 }
 public static function getSubscribedServices()
 {
 return [
 AccessDecisionManagerInterface::class
 ];
 }
}

Phpstan tells me that Service "Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface" is private.
But my code actually works without any problems.

Can you please help me to find out what to do in this situation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /