You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
@malarzm there is old deprecated interface Symfony\Component\DependencyInjection\ServiceSubscriberInterface in the commit c340de8 . It has been removed in symfony 4, AFAIR. For now it is Symfony\Contracts\Service\ServiceSubscriberInterface
@specdrum-agc thanks for the ping! From what I can see we were originally using the correct interface (god bless GitHub showing links in issues from my private repositories). But also nowadays we no longer have the error in our baseline so I reckon this was fixed somewhen in the past by the way :)
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:
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?
The text was updated successfully, but these errors were encountered: