Label305 / Dug

PHP library for combining different data sources to create webservice responses efficiently and manageable.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DataProvider that directly returns a ReferenceToSingle still returns an array

JBlaak opened this issue · comments

For example:

$domain = Domain::get();

return [
    Data::build(
        ['reseller'],
        new ReferenceToSingle(['resellers', $domain->getResellerId()])
    )
];

Will return on fetchSingle:

[
   [
      //Here the result of the ReferenceToSingle
   ]
]

So this isn't a bug, since there are situations which you might want to combine several references. However this can be solve with a solution such as:

$domain = Domain::get();

return new ReferenceToSingle(['resellers', $domain->getResellerId()]);

So you can "alias" a route to another and use that result.