-
Notifications
You must be signed in to change notification settings - Fork 75
Split IdentityInterface #87
Comments
@dynasource, @cebe, @klimov-paul, @SilverFire thoughts? |
Such change seems to be logical, but it make implementation more complicated. Keep in mind that Current Identity finding methods Keeping 'find' methods as static already allows you to create separated implementation for finding - it just need to be encapsulated in those static methods of Identity class. I am against such change. |
It will be in the same class. Thus not separate. |
class MyIdentity implements IdentityInterface
{
// ....
public static function findIdentity($id)
{
return Yii::$app->identityRepository->find($id);
}
} |
I'm positive applying the interface-segregation principle. In the end this will result to less complex code which is more flexible and easier to extend. |
@klimov-paul right but that's adding intermediate class. Feels hacky. I understand your concerns about complicating yii\web\User though... |
I need to actually attempt it to say if it's possible to do it w/o much hassle. |
I'm all for it. |
Разделять надо, т.к. IdentityInterface не должен уметь и находить и быть идентификацией, но репозитори интерфейс не нужен со статикой, его надо вынести в yii\web\User::findIdentity (там есть identityClass) |
@lynicidn please use English in discussions which are conducted using English. Thanks. |
@samdark ok, sorry, no problem, wait pr, may be i have wrong opinion |
This makes sense to me as well. The parameter would accept an object or a configuration array or closure (as normal for Yii).
Note that the user component would have a default configuration for its repository which contains:
|
While at it, would it be possible to add another method to the new I guess the reason why it was originally omitted is things like oauth where you don't necessarily obtain a string name? Maybe introduce as separate identity (e.g. |
Identity doesn't necessary represent a human. It could be API client or another project or a service. |
Closing since the implementation has it split. |
What's the problem?
Currently
IdentityInterface
contains both methods to get an identity and methods which belong to the identity instance. While it is OK in context of Active Record it is an obstacle for implementing repository and entity separated.What is the expected result?
Being able to separately implement repository which responsibility is to get an instance of identity, and an entity which actually holds the data.
What do you get instead?
A single interface forces us to implement everything in a single class.
Additional info
That's how new interfaces would look like:
The text was updated successfully, but these errors were encountered: