Skip to content

isA proposal #37

@nohponex

Description

@nohponex

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions