PHP 클래스 Zend\Mvc\Controller\AbstractRestfulController

상속: extends AbstractController
파일 보기 프로젝트 열기: zendframework/zend-mvc 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$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