phramework / jsonapi

jsonapi implementation for phramework
https://phramework.github.io/jsonapi/
Apache License 2.0
4 stars 2 forks source link

Non-inheritance resource models #39

Open nohponex opened 8 years ago

nohponex commented 8 years ago

Our goal is to get rid off resource Model inheritance drawbacks when extending an model

For example a major issue is get method implementation which relies on current model's getFields, getFilterable etc methods, modifications made for this method at the extended class are not effecting the behaviour of get, leading in errors or unnecessary rewrite of get method at the extended method.

Furthermore we have to improve and simplify the definitions of models.

class InternalModel
{
    function get
    function getById
}
class User extends ResourceModel
{
    protected static $model = null;

    public static getModel()
    {
        if (static::$model) {
            static::$model = new InternalModel()
                ->setPage(new Page(1))
        );
        return static::$model;
    }
}

in a controller

$users = User::get(new Page(25));

TODO


NOTES

nohponex commented 8 years ago

Working on https://github.com/phramework/jsonapi/tree/3.x branch