PHP Класс Zend\Mvc\Controller\AbstractRestfulController

Наследование: extends AbstractController
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$contentTypes array
$customHttpMethodsMap array Map of custom HTTP methods and their handlers
$eventIdentifier {@inheritDoc}
$identifierName string Name of request or query parameter containing identifier
$jsonDecodeType integer | boolean 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.

Открытые методы

Метод Описание
addHttpMethodHandler ( string $method, Callable $handler ) : AbstractRestfulController Register a handler for a custom HTTP method
create ( mixed $data ) : mixed Create a new resource
delete ( mixed $id ) : mixed Delete an existing resource
deleteList ( $data ) : mixed Delete the entire resource collection
dispatch ( Zend\Stdlib\RequestInterface $request, Zend\Stdlib\ResponseInterface $response = null ) : mixed | Zend\Stdlib\ResponseInterface Dispatch a request
get ( mixed $id ) : mixed Return single resource
getIdentifierName ( ) : string Retrieve the route match/query parameter name containing the identifier
getList ( ) : mixed Return list of resources
head ( null | mixed $id = null ) : mixed Retrieve HEAD metadata for the resource
notFoundAction ( ) : array Basic functionality for when a page is not available
onDispatch ( MvcEvent $e ) : mixed Handle the request
options ( ) : mixed Respond to the OPTIONS method
patch ( $id, $data ) : array Respond to the PATCH method
patchList ( mixed $data ) : mixed Modify a resource collection without completely replacing it
processPostData ( Zend\Stdlib\RequestInterface $request ) : mixed Process post data and call create
replaceList ( mixed $data ) : mixed Replace an entire resource collection
requestHasContentType ( Zend\Stdlib\RequestInterface $request, string | null $contentType = '' ) : boolean Check if request has certain content type
setIdentifierName ( string $name ) : self Set the route match/query parameter name containing the identifier
update ( mixed $id, mixed $data ) : mixed Update an existing resource

Защищенные методы

Метод Описание
getIdentifier ( Zend\Router\RouteMatch $routeMatch, Zend\Stdlib\RequestInterface $request ) : false | mixed Retrieve the identifier, if any
jsonDecode ( $string ) : mixed Decode a JSON string.
processBodyContent ( mixed $request ) : object | string | array Process the raw body content

Описание методов

addHttpMethodHandler() публичный Метод

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.
public addHttpMethodHandler ( string $method, Callable $handler ) : AbstractRestfulController
$method string
$handler Callable
Результат AbstractRestfulController

create() публичный Метод

Create a new resource
public create ( mixed $data ) : mixed
$data mixed
Результат mixed

delete() публичный Метод

Delete an existing resource
public delete ( mixed $id ) : mixed
$id mixed
Результат mixed

deleteList() публичный Метод

Not marked as abstract, as that would introduce a BC break (introduced in 2.1.0); instead, raises an exception if not implemented.
public deleteList ( $data ) : mixed
Результат mixed

dispatch() публичный Метод

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.
public dispatch ( Zend\Stdlib\RequestInterface $request, Zend\Stdlib\ResponseInterface $response = null ) : mixed | Zend\Stdlib\ResponseInterface
$request Zend\Stdlib\RequestInterface
$response Zend\Stdlib\ResponseInterface
Результат mixed | Zend\Stdlib\ResponseInterface

get() публичный Метод

Return single resource
public get ( mixed $id ) : mixed
$id mixed
Результат mixed

getIdentifier() защищенный Метод

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 getIdentifier ( Zend\Router\RouteMatch $routeMatch, Zend\Stdlib\RequestInterface $request ) : false | mixed
$routeMatch Zend\Router\RouteMatch
$request Zend\Stdlib\RequestInterface
Результат false | mixed

getIdentifierName() публичный Метод

Retrieve the route match/query parameter name containing the identifier
public getIdentifierName ( ) : string
Результат string

getList() публичный Метод

Return list of resources
public getList ( ) : mixed
Результат mixed

head() публичный Метод

Not marked as abstract, as that would introduce a BC break (introduced in 2.1.0); instead, raises an exception if not implemented.
public head ( null | mixed $id = null ) : mixed
$id null | mixed
Результат mixed

jsonDecode() защищенный Метод

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.
protected jsonDecode ( $string ) : mixed
Результат mixed

notFoundAction() публичный Метод

Basic functionality for when a page is not available
public notFoundAction ( ) : array
Результат array

onDispatch() публичный Метод

Handle the request
public onDispatch ( MvcEvent $e ) : mixed
$e Zend\Mvc\MvcEvent
Результат mixed

options() публичный Метод

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 options ( ) : mixed
Результат mixed

patch() публичный Метод

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 ) : array
$id
$data
Результат array

patchList() публичный Метод

Not marked as abstract, as that would introduce a BC break (introduced in 2.2.0); instead, raises an exception if not implemented.
public patchList ( mixed $data ) : mixed
$data mixed
Результат mixed

processBodyContent() защищенный Метод

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 processBodyContent ( mixed $request ) : object | string | array
$request mixed
Результат object | string | array

processPostData() публичный Метод

Process post data and call create
public processPostData ( Zend\Stdlib\RequestInterface $request ) : mixed
$request Zend\Stdlib\RequestInterface
Результат mixed

replaceList() публичный Метод

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 ) : mixed
$data mixed
Результат mixed

requestHasContentType() публичный Метод

Check if request has certain content type
public requestHasContentType ( Zend\Stdlib\RequestInterface $request, string | null $contentType = '' ) : boolean
$request Zend\Stdlib\RequestInterface
$contentType string | null
Результат boolean

setIdentifierName() публичный Метод

Set the route match/query parameter name containing the identifier
public setIdentifierName ( string $name ) : self
$name string
Результат self

update() публичный Метод

Update an existing resource
public update ( mixed $id, mixed $data ) : mixed
$id mixed
$data mixed
Результат mixed

Описание свойств

$contentTypes защищенное свойство

protected array $contentTypes
Результат array

$customHttpMethodsMap защищенное свойство

Map of custom HTTP methods and their handlers
protected array $customHttpMethodsMap
Результат array

$eventIdentifier защищенное свойство

{@inheritDoc}
protected $eventIdentifier

$identifierName защищенное свойство

Name of request or query parameter containing identifier
protected string $identifierName
Результат string

$jsonDecodeType защищенное свойство

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.
protected int|bool $jsonDecodeType
Результат integer | boolean