Base resource class
Essentially, simply marshalls arguments and triggers events; it is useless without listeners to do the actual work.
create(array | object $data) : array | object
Expects either an array or object representing the item to create. If a non-array, non-object is provided, raises an exception.
The value returned by the last listener to the "create" event will be returned as long as it is an array or object; otherwise, the original $data is returned. If you wish to indicate failure to create, raise a PhlyRestfully\Exception\CreationException from a listener.
array
object
\PhlyRestfully\Exception\InvalidArgumentException |
---|
array
object
delete(string | int $id) : bool
Use to delete the item indicated by $id. The value returned by the last listener will be used, as long as it is a boolean; otherwise, a boolean false will be returned, indicating failure to delete.
string
int
bool
deleteList(null | array $data) : bool
null
array
bool
fetch(string | int $id) : false | array | object
Retrieve an existing item indicated by $id. The value of the last listener will be returned, as long as it is an array or object; otherwise, a boolean false value will be returned, indicating a lookup failure.
string
int
false
array
object
fetchAll() : array | \Traversable
Use to retrieve a collection of items. The value of the last listener will be returned, as long as it is an array or Traversable; otherwise, an empty array will be returned.
The recommendation is to return a \Zend\Paginator\Paginator instance, which will allow performing paginated sets, and thus allow the view layer to select the current page based on the query string or route.
array
\Traversable
getEventManager() : \Zend\EventManager\EventManagerInterface
Lazy-instantiates an EM instance if none provided.
\Zend\EventManager\EventManagerInterface
getEventParam(mixed $name, mixed $default) : mixed
mixed
mixed
mixed
getEventParams() : array
array
getQueryParams() : null | \Zend\Stdlib\Parameters
null
\Zend\Stdlib\Parameters
getRouteMatch() : null | \Zend\Mvc\Router\RouteMatch
null
\Zend\Mvc\Router\RouteMatch
patch(string | int $id, array | object $data) : array | object
Update the item indicated by $id, using the information from $data; $data should be merged with the existing item in order to provide a partial update. Additionally, $data should be an array or object; any other value will raise an exception.
Like create(), the return value of the last executed listener will be returned, as long as it is an array or object; otherwise, $data is returned. If you wish to indicate failure to update, raise a PhlyRestfully\Exception\PatchException.
string
int
array
object
\PhlyRestfully\Exception\InvalidArgumentException |
---|
array
object
replaceList(array $data) : array | object
Replaces the collection with the items contained in $data. $data should be a multidimensional array or array of objects; if otherwise, an exception will be raised.
Like update(), the return value of the last executed listener will be returned, as long as it is an array or object; otherwise, $data is returned. If you wish to indicate failure to update, raise a PhlyRestfully\Exception\UpdateException.
array
\PhlyRestfully\Exception\InvalidArgumentException |
---|
array
object
setEventManager(\Zend\EventManager\EventManagerInterface $events) : Resource
Sets the event manager identifiers to the current class, this class, and the resource interface.
\Zend\EventManager\EventManagerInterface
Resource
setEventParam(string $name, mixed $value) : mixed
string
mixed
mixed
setEventParams(array $params) : \PhlyRestfully\Resource
fluent | This method is part of a fluent interface and will return the same instance |
---|
array
setQueryParams(\Zend\Stdlib\Parameters $params) : \PhlyRestfully\Resource
fluent | This method is part of a fluent interface and will return the same instance |
---|
\Zend\Stdlib\Parameters
setRouteMatch(\Zend\Mvc\Router\RouteMatch $matches) : \PhlyRestfully\Resource
fluent | This method is part of a fluent interface and will return the same instance |
---|
\Zend\Mvc\Router\RouteMatch
update(string | int $id, array | object $data) : array | object
Updates the item indicated by $id, replacing it with the information in $data. $data should be a full representation of the item, and should be an array or object; if otherwise, an exception will be raised.
Like create(), the return value of the last executed listener will be returned, as long as it is an array or object; otherwise, $data is returned. If you wish to indicate failure to update, raise a PhlyRestfully\Exception\UpdateException.
string
int
array
object
\PhlyRestfully\Exception\InvalidArgumentException |
---|
array
object