Answer the question
In order to leave comments, you need to log in
What is the correct way to pass a service parameter in Symfony?
Symfony 3.0.2 When I run the bundle, I get an error:
ContextErrorException in GitkiExtension.php line 30: Catchable Fatal Error: Argument 1 passed to Dontdrinkandroot\GitkiBundle\Twig\GitkiExtension::__construct() must be an instance of Symfony\Component\Security\Core\Security, instance of Symfony\Component\Security\Core\Authorization\AuthorizationChecker given, called in /var/www/teralit.local/var/cache/dev/appDevDebugProjectContainer.php on line 856 and defined
use Dontdrinkandroot\GitkiBundle\Service\ExtensionRegistry\ExtensionRegistryInterface;
use Dontdrinkandroot\GitkiBundle\Service\Role\RoleServiceInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Security\Core\Authorization\AuthorizationChecker;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
class GitkiExtension extends \Twig_Extension
{
/**
* @var Security
*/
private $securityContext;
/**
* @var ExtensionRegistryInterface
*/
private $extensionRegistry;
/**
* @var RoleServiceInterface
*/
private $roleService;
public function __construct(
Security $securityContext,
RoleServiceInterface $roleService,
ExtensionRegistryInterface $extensionRegistry
){
$this->securityContext = $securityContext;
$this->roleService = $roleService;
$this->extensionRegistry = $extensionRegistry;
}
ddr.gitki.twig.gitki_extension:
class: Dontdrinkandroot\GitkiBundle\Twig\GitkiExtension
arguments:
- '@security.authorization_checker'
- '@ddr.gitki.service.role'
- '@ddr.gitki.registry.extension'
tags:
- { name: twig.extension }
public function __construct(
AuthorizationCheckerInterface $securityContext,
RoleServiceInterface $roleService,
ExtensionRegistryInterface $extensionRegistry
){
$this->securityContext = $securityContext;
$this->roleService = $roleService;
$this->extensionRegistry = $extensionRegistry;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question