Comments (17)
@dynasource, @cebe, @klimov-paul, @SilverFire thoughts?
from yii-core.
Such change seems to be logical, but it make implementation more complicated.
Keep in mind that identity
is bound to yii\web\User
. There is a single property yii\web\User::$identityClass
at the moment. Spliting IdentityInterface
into several ones will also make yii\web\User
to be more complex.
Current Identity finding methods findIdentity()
and findIdentityByAccessToken()
are static. Thier notation was inspired by ActiveRecord paradigm.
Extracting IndentityRepositoryInterface
with static methods looks odd - those methods should not be static then: identity repository should be an instance, which finds instances of identity. Such change eliminates the ability of usage same ActiveRecord class for IdentityInterface
and IndentityRepositoryInterface
.
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.
from yii-core.
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.
It will be in the same class. Thus not separate.
from yii-core.
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);
}
}
from yii-core.
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.
from yii-core.
@klimov-paul right but that's adding intermediate class. Feels hacky. I understand your concerns about complicating yii\web\User though...
from yii-core.
I need to actually attempt it to say if it's possible to do it w/o much hassle.
from yii-core.
I'm all for it.
from yii-core.
Разделять надо, т.к. IdentityInterface не должен уметь и находить и быть идентификацией, но репозитори интерфейс не нужен со статикой, его надо вынести в yii\web\User::findIdentity (там есть identityClass)
from yii-core.
http://slides.rmcreative.ru/2016/yii2-architecture/#/26 =)
from yii-core.
@lynicidn please use English in discussions which are conducted using English. Thanks.
from yii-core.
@samdark ok, sorry, no problem, wait pr, may be i have wrong opinion
from yii-core.
This makes sense to me as well.
Note that yii\web\User::$identityClass
would then become yii\web\User::$identityRepository
.
It no longer needs to know the class for an identity.
The parameter would accept an object or a configuration array or closure (as normal for Yii).
A basic ActiveRecordUserRepository
could be implemented and provided with core, configuration would then become:
'components' => [
'user' => [
'identityRepository' => [
'modelClass' => 'app\models\User'
]
Note that the user component would have a default configuration for its repository which contains:
['class' => 'yii\db\ActiveRecordUserRepository']
from yii-core.
While at it, would it be possible to add another method to the new IdentityInterface
: something that produces a human-readable string of the underlying identity (such as getName()
, getUsername()
or getLabel()
)? It makes sense to me at least. What else is an identity if not an abstraction of a person, and as far as I know all humans come with a name.
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. HumanIdentityInterface
) instead? Just something to consider.
from yii-core.
Identity doesn't necessary represent a human. It could be API client or another project or a service.
from yii-core.
from yii-core.
Closing since the implementation has it split.
from yii-core.
Related Issues (20)
- 我认为yii3最应该解决的就是composer包过大的问题 HOT 2
- Should not require yii-web HOT 11
- Enhancement: BaseJson::decode supports decode options HOT 1
- Discuss: Do we still need controllers? HOT 2
- Enhancement: StringHelper::isEmpty() HOT 7
- can't visit yii forum site HOT 1
- Review helpers naming and usage HOT 33
- Url::ensureScheme should fail hard for non absolute paths HOT 2
- What is the current dependency between repo? HOT 20
- Yii3 assets path not correctly reference if installed in subfolder HOT 2
- SOLID compliance HOT 3
- cannot use @web or @webroot in config. HOT 53
- Deal with relative links in Formatter::asUrl() HOT 4
- Nested model attribute label issue HOT 12
- Custom reference syntax to class or class member in comments make impossible to navigate in IDE HOT 19
- Change namespace to Yiisoft\Core? HOT 8
- When will yii3 be released? HOT 1
- Request to separate FileHelper from yii-core HOT 19
- Pack requirements checker into separate package HOT 1
- Repo merges into a repo and then splits HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yii-core.