Our goal is remove argument order restrictions on resource model get and getById calls allowing
future expansion
omission of directives with null value (unset/unused)
Proposal is to have an interface class named IDirective each of the above MUST implemented.
get method signature MUST change to:
function get(IDirective ...$directives)
An execution example:
$users = Users::get(
new Sort('name'),
new Page()
);
Internally in get method value of given directive if any can be found like this:
$page = array_filter(
$directives,
function ($directive) {
return get_class($directive) === Page::class;
}
) ?? null; // or it can be get default instead of null
NOTES:
The signature proposal is not final, it should probably not restrict additional arguments if needed in future
It's important to solve the issue when a relationship inclusion requires the existence of a resource attribute (forced fields)
As a directive we define
page
,sort
,fields
andfilter
Our goal is remove argument order restrictions on resource model
get
andgetById
calls allowingnull
value (unset/unused)Proposal is to have an interface class named
IDirective
each of the above MUST implemented.get
method signature MUST change to:An execution example:
Internally in
get
method value of given directive if any can be found like this:NOTES: