Skip to content

Non-inheritance resource models #39

@nohponex

Description

@nohponex

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

  • We should look into get(..., $targetModel = null) solution if it works

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions