AbstractRestfulController

Abstract RESTful controller
extends Zend\Mvc\Controller\AbstractController

Known subclasses

Omeka\Controller\ApiController
Abstract
Open source code
Methods Summary
public
# setIdentifierName( string $name )
Set the route match/query parameter name containing the identifier
public
# getIdentifierName( )
Retrieve the route match/query parameter name containing the identifier
public
# create( mixed $data )
Create a new resource
public
# delete( mixed $id )
Delete an existing resource
public
# deleteList( $data )
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.
public
# get( mixed $id )
Return single resource
public
# getList( )
Return list of resources
public
# head( null|mixed $id = NULL )
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.
public
# 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.
public
# patch( $id , $data )
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.
public
# replaceList( mixed $data )
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.
public
# patchList( mixed $data )
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.
public
# update( mixed $id , mixed $data )
Update an existing resource
public
# notFoundAction( )
Basic functionality for when a page is not available
public
# dispatch( Zend\Stdlib\RequestInterface $request , Zend\Stdlib\ResponseInterface $response = NULL )
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.

events


Overrides

public
# onDispatch( Zend\Mvc\MvcEvent $e )
Handle the request

todo


public
# processPostData( Zend\Stdlib\RequestInterface $request )
Process post data and call create
public
# requestHasContentType( Zend\Stdlib\RequestInterface $request , string|null $contentType = '' )
Check if request has certain content type
public
# addHttpMethodHandler( string $method , callable $handler )
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.
protected
# getIdentifier( \Zend\Router\RouteMatch $routeMatch , \Request $request )
Retrieve the identifier, if any Attempts to see if an identifier was passed in either the URI or the query string, returning it if found. Otherwise, returns a boolean false.
protected
# processBodyContent( mixed $request )
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 empty value, the method assumes that we have non-urlencoded content and returns the raw content; otherwise, the array created is returned.
protected
# jsonDecode( string $string )
Decode a JSON string. Uses json_decode by default. If that is not available, checks for availability of Zend\Json\Json, and uses that if present. Otherwise, raises an exception. Marked protected to allow usage from extending classes.
Methods inherited from Zend\Mvc\Controller\AbstractController
onDispatch(), dispatch(), getRequest(), getResponse(), setEventManager(), getEventManager(), setEvent(), getEvent(), getPluginManager(), setPluginManager(), plugin(), __call(), attachDefaultListeners(), getMethodFromAction()
Constants Summary
public string CONTENT_TYPE_JSON
# 'json'
Properties Summary
protected $eventIdentifier
{@inheritDoc}
# 'Zend\\Mvc\\Controller\\AbstractRestfulController'
protected array $contentTypes
# array ( 'json' => array ( 0 => 'application/hal+json', 1 => 'application/json', ), )
protected string $identifierName
Name of request or query parameter containing identifier
# 'id'
protected int|bool $jsonDecodeType
Flag to pass to json_decode and/or Zend\Json\Json::decode. The flags in Zend\Json\Json::decode are integers, but when evaluated in a boolean context map to the flag passed as the second parameter to json_decode(). As such, you can specify either the Zend\Json\Json constant or the boolean value. By default, starting in v3, we use the boolean value, and cast to integer if using Zend\Json\Json::decode. Default value is boolean true, meaning JSON should be cast to associative arrays (vs objects). Override the value in an extending class to set the default behavior for your class.
# true
protected array $customHttpMethodsMap
Map of custom HTTP methods and their handlers
# array ( )
Properties inherited from Zend\Mvc\Controller\AbstractController
$plugins, $request, $response, $event, $events, $eventIdentifier