Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isA proposal #37

Open
nohponex opened this issue May 27, 2016 · 3 comments
Open

isA proposal #37

nohponex opened this issue May 27, 2016 · 3 comments

Comments

@nohponex
Copy link
Member

nohponex commented May 27, 2016

Each resource model should define a method bool isA(string $class, string $id, $resourceObject = null)
also each resource model should define zero or more classes

<?php
const CLASSES = [
    'ADMINISTRATOR',
    'MODERATOR'
];

literal values of the classes can be constants

In this way we can have a standard method to check the definitions and the criteria for each resource's classes (and/or states).

The resource model is responsible to implement isA method in order to return true or false for each of the available classes.

Examples:

<?php
$isAdministrator = User::isA('ADMINISTRATOR', $user->id);

$isNotAdministrator = !User::isA('ADMINISTRATOR', $user->id, $user);

//if $resourceObject argument is available and provided we can eliminate call to resource model's `getById` method,
//isA` may require to make additional calls (meta etc) to fetch all required data to reach a decision about a certain class.
@nohponex nohponex added this to the Release 2.x milestone May 27, 2016
@nohponex
Copy link
Member Author

An alternative name may be better, "CLASSES" is confusing

@tchronis
Copy link

tchronis commented May 29, 2016

How about ENTITY ?

@nohponex
Copy link
Member Author

nohponex commented Jun 4, 2016

How about ENTITY ?

We need something that shows that some resources of that type share common properties, i.e. the form a group or a class.

I would prefer class but it's confusing for the developers since we are working with OOP

@nohponex nohponex modified the milestones: Release 3.x, Release 2.x Oct 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants