Controller for handling resources.
Extends the base AbstractRestfulController in order to provide very specific semantics for building a RESTful JSON service. All operations return either
You may specify what specific HTTP method types you wish to respond to, and OPTIONS will then report those; attempting any HTTP method falling outside that list will result in a 405 (Method Not Allowed) response.
I recommend using resource-specific factories when using this controller, to allow injecting the specific resource you wish to use (and its listeners), which will also allow you to have multiple instances of the controller when desired.
see | \PhlyRestfully\http://tools.ietf.org/html/draft-kelly-json-hal-03 |
---|---|
see | \PhlyRestfully\http://tools.ietf.org/html/draft-nottingham-http-problem-02 |
__construct(null | string $eventIdentifier)
Allows you to set the event identifier, which can be useful to allow multiple instances of this controller to react to different sets of shared events.
null
string
create(array $data) : \Zend\Http\Response | \PhlyRestfully\ApiProblem | \PhlyRestfully\HalResource
array
delete(int | string $id) : \Zend\Http\Response | \PhlyRestfully\ApiProblem
deleteList()
get(int | string $id) : \Zend\Http\Response | \PhlyRestfully\ApiProblem | \PhlyRestfully\HalResource
int
string
getIdentifierName() : string
string
getList() : \Zend\Http\Response | \PhlyRestfully\HalCollection
\Zend\Http\Response
\PhlyRestfully\HalCollection
getResource() : \PhlyRestfully\ResourceInterface
head(null | mixed $id) : \Zend\Http\Response | \PhlyRestfully\ApiProblem | \PhlyRestfully\HalResource | \PhlyRestfully\HalCollection
null
mixed
onDispatch(\Zend\Mvc\MvcEvent $e) : mixed
Does several "pre-flight" checks: - Raises an exception if no resource is composed. - Raises an exception if no route is composed. - Returns a 405 response if the current HTTP request method is not in $options
When the dispatch is complete, it will check to see if an array was returned; if so, it will cast it to a view model using the AcceptableViewModelSelector plugin, and the $acceptCriteria property.
\Zend\Mvc\MvcEvent
\PhlyRestfully\Exception\DomainException |
---|
mixed
patch(int | string $id, array $data) : \Zend\Http\Response | \PhlyRestfully\ApiProblem | \PhlyRestfully\HalResource
int
string
array
replaceList(array $data) : array
array
array
setAcceptCriteria(array $criteria)
array
setCollectionHttpOptions(array $options)
array
setCollectionName(string $name)
string
setContentTypes(array $contentTypes)
array
setIdentifierName(string $name)
string
setPageSize(int $count)
int
setResource(\PhlyRestfully\ResourceInterface $resource)
\PhlyRestfully\ResourceInterface
setResourceHttpOptions(array $options)
array
setRoute(string $route)
string
update(int | string $id, array $data) : \Zend\Http\Response | \PhlyRestfully\ApiProblem | \PhlyRestfully\HalResource
int
string
array