[4.2] Add interfaces for the objects who need a user#37498
[4.2] Add interfaces for the objects who need a user#37498roland-d merged 21 commits intojoomla:4.2-devfrom
Conversation
|
will you be replacing getIdentity everywhere? |
|
Not really as this is different than getIdentity in terms of logic. GetIdentity is basically the identity of the application which comes from the authentication process. While this here can be anything where the view or model should work with. But as I said, I'm open here for suggestions as the similarities are very obvious. |
|
Just when I thought I understood the reason for this PR |
|
Why not make a trait to get the application object and the go from there? |
|
Don't think so it would be a good decision to pass around the application in whole core. Like that there is only a dependency to a simple user and not the app. It brings the benefit to be usable on places where no application is available. |
|
Here, the current user object will only be available in model if the model is created by our normal MVC workflow (users access to the component via web browser). What if model is created by by MVCFactory ? In this case, |
|
That's not current user, but an empty user object? |
|
After reading your comment a couple of times I think I do understand what you mean now. So when an extension is loading a model like |
|
Yes, that's what I wanted to say. |
|
@laoneo We have a codestyle failure: |
|
@joomdonation Is everything OK for you now on this PR? |
|
@roland-d The logical bug I concerned before is fixed with latest change, so it is fine now. The architecture change in this PR, right or wrong, I'm not qualify enough to say, sorry. So it's up to you to decide :D . |
|
Thanks everybody |
Summary of Changes
As many classes need a user to check permissions or get an email address from it, there is no common way to get a current user instance. This pr introduces a new interface and trait to get/set a current user on an object. The identity aware trait offers a similar functionality but is intended to be used on applications only. But I'm open here for suggestions if we should reuse the identity trait or go with the approach in this pr.
Also I'm not sure about the name of the new interface or trait, also here open for suggestions.
This pr is mainly needed as @wilsonge doesn't want to inject the application into the models or views. If the app would be available, then we can just load the identity from it.
Testing Instructions
In the back end, open the articles list.
Actual result BEFORE applying this Pull Request
Works.
Expected result AFTER applying this Pull Request
Works.