PHP Класс Drest\Service

Is also injected into custom service actions
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$dm drest\Manager Drest Manager
$error_handler DrestCommon\Error\Handler\AbstractHandler The error handler instance
$matched_route Drest\Mapping\RouteMetaData When a route object is matched, it's injected into the service class
$representation DrestCommon\Representation\AbstractRepresentation A representation instance determined either from configuration or client media accept type - can be null if none matched Note this will be present on both a fetch (GET) request and on a push (POST / PUT) request if using the drest client
$service_action_registry Drest\Service\Action\Registry Service Action Registry

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

Метод Описание
__construct ( drest\Manager $dm, Drest\Service\Action\Registry $service_action_registry ) Initialise a new instance of a Drest service
getDrestManager ( ) : drest\Manager Get the Drest Manager
getEntityManager ( ) : EntityManager Get the entity manager This will return the default manager, to choose a specific one use getEntityManagerRegistry()
getEntityManagerRegistry ( ) : drest\EntityManagerRegistry Get the entity manager registry
getMatchedRoute ( ) : RouteMetaData Get the route object that was matched
getRepresentation ( ) : DrestCommon\Representation\AbstractRepresentation Get the predetermined representation
getRequest ( ) : DrestCommon\Request\Request Get the request object
getResponse ( ) : DrestCommon\Response\Response Get the response object
getServiceActionRegistry ( ) : Drest\Service\Action\Registry Get the service action registry
handleError ( Exception $e, integer $defaultResponseCode = 500, DrestCommon\Error\Response\ResponseInterface $errorDocument = null ) : DrestCommon\ResultSet Handle an error - set the resulting error document to the response object
renderDeterminedRepresentation ( DrestCommon\ResultSet $resultSet ) Write out as result set on the representation object that was determined - if no representation has been determined - defaults to text
runCallMethod ( ) Run the call method required on this service object
setErrorHandler ( DrestCommon\Error\Handler\AbstractHandler $error_handler ) Set the error handler object
setMatchedRoute ( RouteMetaData $matched_route ) Set the matched route object
setRepresentation ( DrestCommon\Representation\AbstractRepresentation $representation ) Set any predetermined representation instance
setUpAndRunRequest ( ) Set up and run the required call method

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

Метод Описание
getActionInstance ( ) : Drest\Service\Action\AbstractAction Get an instance of the action class to be used
getDefaultAction ( ) : Drest\Service\Action\AbstractAction Gets an instance of the "default" action based of request information
setupRequest ( ) : boolean Called on successful routing of a service call Prepares the service to a request to be rendered

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

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

Initialise a new instance of a Drest service
public __construct ( drest\Manager $dm, Drest\Service\Action\Registry $service_action_registry )
$dm drest\Manager - The Drest Manager object
$service_action_registry Drest\Service\Action\Registry - registry use to look up service actions

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

Get an instance of the action class to be used
protected getActionInstance ( ) : Drest\Service\Action\AbstractAction
Результат Drest\Service\Action\AbstractAction $action

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

Gets an instance of the "default" action based of request information
protected getDefaultAction ( ) : Drest\Service\Action\AbstractAction
Результат Drest\Service\Action\AbstractAction $action

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

Get the Drest Manager
public getDrestManager ( ) : drest\Manager
Результат drest\Manager $dm

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

Get the entity manager This will return the default manager, to choose a specific one use getEntityManagerRegistry()
public getEntityManager ( ) : EntityManager
Результат Doctrine\ORM\EntityManager $em

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

Get the entity manager registry
public getEntityManagerRegistry ( ) : drest\EntityManagerRegistry
Результат drest\EntityManagerRegistry

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

Get the route object that was matched
public getMatchedRoute ( ) : RouteMetaData
Результат Drest\Mapping\RouteMetaData $matched_route

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

Get the predetermined representation
public getRepresentation ( ) : DrestCommon\Representation\AbstractRepresentation
Результат DrestCommon\Representation\AbstractRepresentation

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

Get the request object
public getRequest ( ) : DrestCommon\Request\Request
Результат DrestCommon\Request\Request $request

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

Get the response object
public getResponse ( ) : DrestCommon\Response\Response
Результат DrestCommon\Response\Response $response

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

Get the service action registry
public getServiceActionRegistry ( ) : Drest\Service\Action\Registry
Результат Drest\Service\Action\Registry $service_action_registry

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

Handle an error - set the resulting error document to the response object
public handleError ( Exception $e, integer $defaultResponseCode = 500, DrestCommon\Error\Response\ResponseInterface $errorDocument = null ) : DrestCommon\ResultSet
$e Exception
$defaultResponseCode integer the default response code to use if no match on exception type occurs
$errorDocument DrestCommon\Error\Response\ResponseInterface
Результат DrestCommon\ResultSet the error result set

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

Write out as result set on the representation object that was determined - if no representation has been determined - defaults to text
public renderDeterminedRepresentation ( DrestCommon\ResultSet $resultSet )
$resultSet DrestCommon\ResultSet

runCallMethod() закрытый публичный Метод

Run the call method required on this service object
final public runCallMethod ( )

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

Set the error handler object
public setErrorHandler ( DrestCommon\Error\Handler\AbstractHandler $error_handler )
$error_handler DrestCommon\Error\Handler\AbstractHandler

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

Set the matched route object
public setMatchedRoute ( RouteMetaData $matched_route )
$matched_route Drest\Mapping\RouteMetaData

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

Set any predetermined representation instance
public setRepresentation ( DrestCommon\Representation\AbstractRepresentation $representation )
$representation DrestCommon\Representation\AbstractRepresentation

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

Set up and run the required call method
public setUpAndRunRequest ( )

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

Called on successful routing of a service call Prepares the service to a request to be rendered
protected setupRequest ( ) : boolean
Результат boolean $result - if false then fail fast no call to runCallMethod() should be made.

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

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

Drest Manager
protected Manager,drest $dm
Результат drest\Manager

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

The error handler instance
protected AbstractHandler,DrestCommon\Error\Handler $error_handler
Результат DrestCommon\Error\Handler\AbstractHandler

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

When a route object is matched, it's injected into the service class
protected RouteMetaData,Drest\Mapping $matched_route
Результат Drest\Mapping\RouteMetaData

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

A representation instance determined either from configuration or client media accept type - can be null if none matched Note this will be present on both a fetch (GET) request and on a push (POST / PUT) request if using the drest client
protected AbstractRepresentation,DrestCommon\Representation $representation
Результат DrestCommon\Representation\AbstractRepresentation

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

Service Action Registry
protected Registry,Drest\Service\Action $service_action_registry
Результат Drest\Service\Action\Registry