-1

I want to override the controller (RegistartionController) of FosUserbundle by the using of compilerPass in Symfony 3.4 so this is my code

=== 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) ; 
    }
}

and this is file when add add it to the main bundle class

<?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() );
    }

}

when access to my register path i get

Compile Error: Class MyBundle\DependencyInjection\Compiler\RegisterUserCompilerPass cannot extend from interface Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface

1
  • 1
    You should understand your error messages, not just read them, it will make your life simpler :) Commented Apr 20, 2018 at 10:42

1 Answer 1

6
class RegisterUserCompilerPass extends CompilerPassInterface

should be

class RegisterUserCompilerPass implements CompilerPassInterface

See PHP can't extend from interface?

Sign up to request clarification or add additional context in comments.

1 Comment

You should explain why even if the answer is basic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.