Class AbstractRestfulController

Summary

Fully Qualified Name: Laminas\Mvc\Controller\AbstractRestfulController
Extends: AbstractController

Description

Abstract RESTful controller

Methods

Name Description Defined By
__call() Method overloading: return/call plugins AbstractController
addHttpMethodHandler() Register a handler for a custom HTTP method AbstractRestfulController
create() Create a new resource AbstractRestfulController
delete() Delete an existing resource AbstractRestfulController
deleteList() Delete the entire resource collection AbstractRestfulController
dispatch() Dispatch a request AbstractRestfulController
get() Return single resource AbstractRestfulController
getEvent() Get the attached event AbstractController
getEventManager() Retrieve the event manager AbstractController
getIdentifierName() Retrieve the route match/query parameter name containing the identifier AbstractRestfulController
getList() Return list of resources AbstractRestfulController
getMethodFromAction() Transform an "action" token into a method name AbstractController
getPluginManager() Get plugin manager AbstractController
getRequest() Get request object AbstractController
getResponse() Get response object AbstractController
head() Retrieve HEAD metadata for the resource AbstractRestfulController
notFoundAction() Basic functionality for when a page is not available AbstractRestfulController
onDispatch() Handle the request AbstractRestfulController
options() Respond to the OPTIONS method AbstractRestfulController
patch() Respond to the PATCH method AbstractRestfulController
patchList() Modify a resource collection without completely replacing it AbstractRestfulController
plugin() Get plugin instance AbstractController
processPostData() Process post data and call create AbstractRestfulController
replaceList() Replace an entire resource collection AbstractRestfulController
requestHasContentType() Check if request has certain content type AbstractRestfulController
setEvent() Set an event to use during dispatch AbstractController
setEventManager() Set the event manager instance used by this context AbstractController
setIdentifierName() Set the route match/query parameter name containing the identifier AbstractRestfulController
setPluginManager() Set plugin manager AbstractController
update() Update an existing resource AbstractRestfulController

Method Details

__call()

Method overloading: return/call plugins

If the plugin is a functor, call it, passing the parameters provided. Otherwise, return the plugin instance.

Parameter Name Type Description
$method string
$params array

Returns: mixed

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 retrieve the body content data, use "$data = $this->processBodyContent($request)"; that method will return a string, array, or, in the case of JSON, an object.

Parameter Name Type Description
$method string
$handler callable

Returns: \AbstractRestfulController

create()

Create a new resource

Parameter Name Type Description
$data mixed

Returns: mixed

delete()

Delete an existing resource

Parameter Name Type Description
$id mixed

Returns: mixed

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.

Parameter Name Type Description
$data

Returns: mixed

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.

Parameter Name Type Description
$request \Request
$response null|\Response

Returns: mixed|\Response

get()

Return single resource

Parameter Name Type Description
$id mixed

Returns: mixed

getEvent()

Get the attached event

Will create a new MvcEvent if none provided.

Returns: \MvcEvent

getEventManager()

Retrieve the event manager

Lazy-loads an EventManager instance if none registered.

Returns: \EventManagerInterface

getIdentifierName()

Retrieve the route match/query parameter name containing the identifier

Returns: string

getList()

Return list of resources

Returns: mixed

getMethodFromAction()

Transform an "action" token into a method name

Parameter Name Type Description
$action string

Returns: string

getPluginManager()

Get plugin manager

Returns: \PluginManager

getRequest()

Get request object

Returns: \Request

getResponse()

Get response object

Returns: \Response

head()

Retrieve HEAD metadata for the resource

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

Parameter Name Type Description
$id null|mixed

Returns: mixed

notFoundAction()

Basic functionality for when a page is not available

Returns: array

onDispatch()

Handle the request

Parameter Name Type Description
$e \MvcEvent

Returns: mixed

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.

Returns: mixed

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.

Parameter Name Type Description
$data
$id
$data

Returns: array

patchList()

Modify a resource collection without completely replacing it

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

Parameter Name Type Description
$data mixed

Returns: mixed

plugin()

Get plugin instance

Parameter Name Type Description
$name string Name
$options null|array Options

Returns: mixed

processPostData()

Process post data and call create

Parameter Name Type Description
$request \Request

Returns: mixed

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.

Parameter Name Type Description
$data mixed

Returns: mixed

requestHasContentType()

Check if request has certain content type

Parameter Name Type Description
$request \Request
$contentType string|null

Returns: bool

setEvent()

Set an event to use during dispatch

By default, will re-cast to MvcEvent if another event type is provided.

Parameter Name Type Description
$e \Event

Returns: void

setEventManager()

Set the event manager instance used by this context

Parameter Name Type Description
$events \EventManagerInterface

Returns: \AbstractController

setIdentifierName()

Set the route match/query parameter name containing the identifier

Parameter Name Type Description
$name string

Returns: self

setPluginManager()

Set plugin manager

Parameter Name Type Description
$plugins \PluginManager

Returns: \AbstractController

update()

Update an existing resource

Parameter Name Type Description
$id mixed
$data mixed

Returns: mixed

Top