313. Class

313.1. Zend\Mvc\Controller\AbstractRestfulController

Abstract RESTful controller

313.1.1. Methods

313.1.1.1. create

create()

Create a new resource

Parameters:mixed
Return type:mixed

313.1.1.2. delete

delete()

Delete an existing resource

Parameters:mixed
Return type:mixed

313.1.1.3. deleteList

deleteList()

Delete the entire resource collection

Not marked as abstract, as that would introduce a BC break (introduced in 2.1.0); instead, raises an exception if not implemented.

Return type:mixed
Throws :ExceptionRuntimeException

313.1.1.4. get

get()

Return single resource

Parameters:mixed
Return type:mixed

313.1.1.5. getList

getList()

Return list of resources

Return type:mixed

313.1.1.7. options

options()

Respond to the OPTIONS method

Typically, set the Allow header with allowed HTTP methods, and return the response.

Not marked as abstract, as that would introduce a BC break (introduced in 2.1.0); instead, raises an exception if not implemented.

Return type:mixed
Throws :ExceptionRuntimeException

313.1.1.8. patch

patch()

Respond to the PATCH method

Not marked as abstract, as that would introduce a BC break (introduced in 2.1.0); instead, raises an exception if not implemented.

Return type:mixed
Throws :ExceptionRuntimeException

313.1.1.9. replaceList

replaceList()

Replace an entire resource collection

Not marked as abstract, as that would introduce a BC break (introduced in 2.1.0); instead, raises an exception if not implemented.

Parameters:mixed
Return type:mixed
Throws :ExceptionRuntimeException

313.1.1.10. update

update()

Update an existing resource

Parameters:
  • mixed
  • mixed
Return type:

mixed

313.1.1.11. notFoundAction

notFoundAction()

Basic functionality for when a page is not available

Return type:array

313.1.1.12. dispatch

dispatch()

Dispatch a request

If the route match includes an “action” key, then this acts basically like a standard action controller. Otherwise, it introspects the HTTP method to determine how to handle the request, and which method to delegate to.

Parameters:
  • Request
  • null|Response
Return type:

mixed|Response

Throws :

ExceptionInvalidArgumentException

313.1.1.13. onDispatch

onDispatch()

Handle the request

Parameters:MvcEvent
Return type:mixed
Throws :ExceptionDomainException if no route matches in event or invalid HTTP method

313.1.1.14. processPostData

processPostData()

Process post data and call create

Parameters:Request
Return type:mixed

313.1.1.15. requestHasContentType

requestHasContentType()

Check if request has certain content type

Return type:boolean

313.1.1.16. addHttpMethodHandler

addHttpMethodHandler()

Register a handler for a custom HTTP method

This method allows you to handle arbitrary HTTP method types, mapping them to callables. Typically, these will be methods of the controller instance: e.g., array($this, ‘foobar’). The typical place to register these is in your constructor.

Additionally, as this map is checked prior to testing the standard HTTP methods, this is a way to override what methods will handle the standard HTTP methods. However, if you do this, you will have to retrieve the identifier and any request content manually.

Callbacks will be passed the current MvcEvent instance.

To retrieve the identifier, you can use “$id = $this->getIdentifier($routeMatch, $request)”, passing the appropriate objects.

To retrive the body content data, use “$data = $this->processBodyContent($request)”; that method will return a string, array, or, in the case of JSON, an object.

Parameters:
  • string
  • Callable
Return type:

AbstractRestfulController

313.1.1.17. getIdentifier

getIdentifier()

Retrieve the identifier, if any

Attempts to see if an identifier was passed in either the URI or the query string, returning if if found. Otherwise, returns a boolean false.

Parameters:
  • ZendMvcRouterRouteMatch
  • Request
Return type:

false|mixed

313.1.1.18. processBodyContent

processBodyContent()

Process the raw body content

If the content-type indicates a JSON payload, the payload is immediately decoded and the data returned. Otherwise, the data is passed to parse_str(). If that function returns a single-member array with a key of “0”, the method assumes that we have non-urlencoded content and returns the raw content; otherwise, the array created is returned.

Parameters:mixed
Return type:object|string|array

313.1.2. Constants

313.1.2.1. CONTENT_TYPE_JSON