我想通过在Symfony 3.4中使用compilerPass来覆盖FosUserbundle的控制器(RegistartionController),所以这是我的代码
=== RegisterUserCompilerPass ===
<?php
namespace myBundle;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class RegisterUserCompilerPass extends CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
$container
->getDefinition('fos_user.registration.controller')
->setClass(MyBundle\Controller\ReplaceRegistrationController::class) ;
}
}
这是添加时将其添加到主bundle类的文件
<?php
namespace MyBundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use MyBundle\DependencyInjection\Compiler\RegisterUserCompilerPass ;
// use Crypto\UserBundle\Manager\ReplaceRegistration ;
class CryptoUserBundle extends Bundle
{
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->addCompilerPass(new RegisterUserCompilerPass() );
}
}
当我访问我的注册路径时
编译错误:类MyBundle \ DependencyInjection \ Compiler \ RegisterUserCompilerPass无法从接口Symfony \ Component \ DependencyInjection \ Compiler \ CompilerPassInterface扩展
1 回答
应该
见PHP can't extend from interface?