0
votes

I use FOSUserBundle in my Symfony site (3.0.6). I recently updated my dependencies with composer, and now I have FOSUserBundle version 2.1.0.

Problem: I overrode the Registration controller (it worked well), but now I have this error when I want to access my Registration page:

Catchable Fatal Error: Argument 1 passed to FOS\UserBundle\Controller\RegistrationController::__construct() must implement interface Symfony\Component\EventDispatcher\EventDispatcherInterface, none given, called in D:\wamp64\www\mySite\var\cache\dev\classes.php on line 2457 and defined 500 Internal Server Error - ContextErrorException

In the Registration controller of FOSUserBundle, these lines have been added:

class RegistrationController extends Controller
{
    private $eventDispatcher;
    private $formFactory;
    private $userManager;
    private $tokenStorage;

    public function __construct(
        EventDispatcherInterface $eventDispatcher,
        FactoryInterface $formFactory,
        UserManagerInterface $userManager,
        TokenStorageInterface $tokenStorage
    ) {
        $this->eventDispatcher = $eventDispatcher;
        $this->formFactory = $formFactory;
        $this->userManager = $userManager;
        $this->tokenStorage = $tokenStorage;
    }

    // ...
}

In the previous version of the bundle, there was no constructor.

Does anyone have any idea

Thank you in advance.

1
Some discussion here: stackoverflow.com/questions/50487275/… Your best bet might be to just "freeze" the fos version to one that works.Cerad

1 Answers

0
votes

Have a look in the fos user CHangelog (https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Changelog.md), they changed the way you need to overwrite a controller :

"Refactored controllers and commands to use DI. Projects extending these classes will need to adapt their code (but should rather use supported extension points when possible)."