New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
__construct() must implement interface Symfony\Component\EventDispatcher\EventDispatcherInterface, none given #2744
Comments
Actually I set in composer the version like that: |
@LailaMai This is probably due to the fact that Your Since I've reached out to @stof via Twitter on how to handle this and used his advice by overriding via routing - https://twitter.com/Stof70/status/968478748906541057, however this will not work, since controller still won't be injected with services. What I would suggest for now is creating compiler pass and overriding This proves to be working for me. P.S. Not sure if that's a game changer, but I'm on Symfony 2.8. 😢 |
OK I'll try this solution and see what will happen, Thanks @phpeek 👍 |
Thanks @phpeek |
@phpeek overriding via routing still allows you to use DI for yoru own class. And when creating your own controller replacing some action, you should probably not even make it extend the FOSUserbundle class (which does not provide inheritance-based extension point anyway) |
I have created a controller However how i get service from container? class ChangePasswordController extends FOSChangePasswordController
{
public function __construct() {
$eventDispatcher = $this->get('event_dispatcher');
$formFactory = $this->get('fos_user.change_password.form.factory');
$userManager = $this->get('fos_user.user_manager');
parent::__construct($eventDispatcher, $formFactory, $userManager);
}
} |
@stof Granted, this is probably not the best way on extending FOSUserBundle controllers. However, I see issues related to this problem being submitted, so looks like people took this bad approach. Do You think this should be treated as BC break and bump in major version ? @slince If you've created a compiler pass for Your |
@phpeek So to be sure, "good way" to do is to create a compiler pass, right ? |
Finally in my case, I had at first time, "AccountController extends FOS\UserBundle\Controller\ProfileController" , with overriding the editAction and I had also "RegistrationController extends FOS\UserBundle\Controller\RegistrationController" with overriding confirmAction and confirmedAction, I updated my composer as following: |
@blackarcanis No :) Consider it a "hacky" way. As @stof mentioned here extending any of the The problem here is that properties of base controller classes are marked as It means You won't be able to access them in Your controller when extending base controller unless You redefine them in Your controller, override |
I didn't override the Controller but used another (nasty) shortcut in an application where the user can request to reset his password in another application (not symfony) and that request is sent to the symfony application through a json api:
this doesn't work with
I'm actually surprised that $this->forward() doesn't know how to create a ResettingController. |
@LailaMai it's work fine for me after downgrading fosuserbundle with ~2.0.1 |
@DH-INT I know , I mentioned that on my second comment, but if you need to upgrade the bundle in future you need to make some modifications to make it work fine again. |
the version 2.0.2 fix the same problem for me. |
I had the same issue, see #2807. |
Hello,
My project was working just fine till I made composer update and I get this error:
My composer infos:
"require": {
"php": ">=5.5.9",
"symfony/symfony": "3.1.*",
"doctrine/orm": "^2.5",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-cache-bundle": "^1.2",
"symfony/swiftmailer-bundle": "^2.3.10",
"symfony/monolog-bundle": "^3.0.2",
"symfony/polyfill-apcu": "^1.0",
"sensio/distribution-bundle": "^5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "^2.0",
"friendsofsymfony/user-bundle": "~2.0",
"jms/i18n-routing-bundle": "^2.0",
"jms/translation-bundle": "^1.3",
"jms/di-extra-bundle": "^1.8",
"guzzlehttp/guzzle": "^6.2",
"stof/doctrine-extensions-bundle": "^1.2"
},
Stack Trace
**highlight the 39 line in log
I have tried many solutions like overriding the parent constructor or adding public function __construct(){parent::__construct();} in the override controller but nothing seems to work.
Is there something changed in the FosUserBundle that create this bug? how can I fix it ?
The text was updated successfully, but these errors were encountered: