If a Model
, View
, Table
with the MVCFactory
not all (required) options are injected to the objects eg. CurrentUserInterface
because its injected by BaseController
and not by the factory itself.
joomla-cms/libraries/src/MVC/Controller/BaseController.php
Lines 580 to 582 in 8868adc
joomla-cms/libraries/src/MVC/Controller/BaseController.php
Lines 611 to 613 in 8868adc
if you disabled this deprecated code
joomla-cms/libraries/src/User/CurrentUserTrait.php
Lines 43 to 49 in 8868adc
no additional injects necessary if model/view/table etc. is created with MVCFactory
you get problems with this code
ping @laoneo
Labels |
Added:
No Code Attached Yet
|
The MVCFactory per se is not created in a context where a user is available. So where should this user come from?
I have no idea, that's why I asked for advice. This means that every time you boot a different model in a plugin/module etc. you would have to inject the user separately - this will be a few places and the 3rd party developers will not be happy about it either.
That's how I've always understood it so far: If the model/view/table is created via the MVCFactory, you are on the safe side.
The MVC doens't know the current User context, only the calling code knows what's the current user is. It would be more intuitive to provide a container with everything the model might need in the current context but that's not the design here...
This is what dependency injection is about. You need a context where it is running in
MVCFactory doesn't allow you to provide a container...
The MVCFactory per se is not created in a context where a user is available. So where should this user come from?