why bindMethod don't work #50216
Replies: 2 comments 2 replies
-
I don't think there's binding support at all on those methods on a subscriber on events. if it was, it would have tried to bind that folderService instance and never complained about a thing. i also think you have misunderstood how events work. How does the event get dispatched here? |
Beta Was this translation helpful? Give feedback.
-
The fact is that there is no description of bindMethod in the Service Container manual for version 10. The only mention of bindMethod is at https://laravel.com/docs/10.x/queues#handle-method-dependency-injection Accordingly, I have a question - to what extent is it a working concept at the moment to use bindMethod? And if this is a working concept, why doesn't it work in this case? What needs to be done to make it work? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello. I need to introduce a second argument to the events subscriber class. I do this via app->bindMethod as recommended.
However, the application throws an error.
Too few arguments to function SportEventScheduleSubscriber::handleSportEventScheduleCreated(), 1 passed in /var/www/e/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php on line 478 and exactly 2 expected SportEventScheduleSubscriber.php
and does not pass 2 argument.
I tried moving bindMethod to boot method of my App\Providers\AppServiceProvider service provider.
And it doesn't work either.
When I debug the application, I can see that it does not go to the method binding point in the provider.
If i pass FolderService $folderService to the class constructor SportEventScheduleSubscriber and use $this everything will work. But I only need this class for a single method, not in the constructor for the whole class. How can I make the bindMethod work?
How to fix the problem?
Beta Was this translation helpful? Give feedback.
All reactions