PHP Class PhalconRest\Api\ApiEndpoint

Show file Open project: olivierandriessen/phalcon-rest Class Usage Examples

Protected Properties

Property Type Description
$allowedRoles
$deniedRoles
$description
$exampleResponse
$handlerMethod
$httpMethod
$name
$path
$postedDataMethod

Public Methods

Method Description
__construct ( $path, $httpMethod = HttpMethods::GET, $handlerMethod = null )
all ( ) : static Returns pre-configured all endpoint
allow ( ) : static Allows access to this endpoint for role with the given names.
create ( ) : static Returns pre-configured create endpoint
delete ( $path, string $handlerMethod = null ) : ApiEndpoint Returns pre-configured DELETE endpoint
deny ( ) : static Denies access to this endpoint for role with the given names.
description ( string $description ) : static
exampleResponse ( string $exampleResponse )
expectsJsonData ( ) : static Sets the posted data method to JSON_BODY
expectsPostData ( ) : static Sets the posted data method to POST
factory ( string $path, string $httpMethod = HttpMethods::GET, string $handlerMethod = null ) : static Returns endpoint with default values
find ( ) : static Returns pre-configured find endpoint
get ( $path, string $handlerMethod = null ) : ApiEndpoint Returns pre-configured GET endpoint
getAllowedRoles ( ) : string[]
getDeniedRoles ( ) : string[]
getDescription ( ) : string
getExampleResponse ( ) : string
getHandlerMethod ( ) : string
getHttpMethod ( ) : string
getIdentifier ( ) : string
getName ( ) : string | null
getPath ( ) : string
getPostedDataMethod ( ) : string
handlerMethod ( string $handlerMethod ) : static
head ( $path, string $handlerMethod = null ) : ApiEndpoint Returns pre-configured HEAD endpoint
name ( string $name ) : static
options ( $path, string $handlerMethod = null ) : ApiEndpoint Returns pre-configured OPTIONS endpoint
patch ( $path, string $handlerMethod = null ) : ApiEndpoint Returns pre-configured PATCH endpoint
post ( $path, string $handlerMethod = null ) : ApiEndpoint Returns pre-configured POST endpoint
postedDataMethod ( string $method ) : static
put ( $path, string $handlerMethod = null ) : ApiEndpoint Returns pre-configured PUT endpoint
remove ( ) : static Returns pre-configured remove endpoint
update ( ) : static Returns pre-configured update endpoint

Method Details

__construct() public method

public __construct ( $path, $httpMethod = HttpMethods::GET, $handlerMethod = null )

all() public static method

Returns pre-configured all endpoint
public static all ( ) : static
return static

allow() public method

Allows access to this endpoint for role with the given names.
public allow ( ) : static
return static

create() public static method

Returns pre-configured create endpoint
public static create ( ) : static
return static

delete() public static method

Returns pre-configured DELETE endpoint
public static delete ( $path, string $handlerMethod = null ) : ApiEndpoint
$path
$handlerMethod string
return ApiEndpoint

deny() public method

Denies access to this endpoint for role with the given names.
public deny ( ) : static
return static

description() public method

public description ( string $description ) : static
$description string Description for the endpoint
return static

exampleResponse() public method

public exampleResponse ( string $exampleResponse )
$exampleResponse string Example of the response of the endpoint

expectsJsonData() public method

Sets the posted data method to JSON_BODY
public expectsJsonData ( ) : static
return static

expectsPostData() public method

Sets the posted data method to POST
public expectsPostData ( ) : static
return static

factory() public static method

Returns endpoint with default values
public static factory ( string $path, string $httpMethod = HttpMethods::GET, string $handlerMethod = null ) : static
$path string
$httpMethod string
$handlerMethod string
return static

find() public static method

Returns pre-configured find endpoint
public static find ( ) : static
return static

get() public static method

Returns pre-configured GET endpoint
public static get ( $path, string $handlerMethod = null ) : ApiEndpoint
$path
$handlerMethod string
return ApiEndpoint

getAllowedRoles() public method

public getAllowedRoles ( ) : string[]
return string[] Array of allowed role-names

getDeniedRoles() public method

public getDeniedRoles ( ) : string[]
return string[] Array of denied role-names

getDescription() public method

public getDescription ( ) : string
return string Description for the endpoint

getExampleResponse() public method

public getExampleResponse ( ) : string
return string Example of the response of the endpoint

getHandlerMethod() public method

public getHandlerMethod ( ) : string
return string Name of controller-method to be called for the endpoint

getHttpMethod() public method

public getHttpMethod ( ) : string
return string HTTP method of the endpoint

getIdentifier() public method

public getIdentifier ( ) : string
return string Unique identifier for this endpoint (returns a combination of the HTTP method and the path)

getName() public method

public getName ( ) : string | null
return string | null Name of the endpoint

getPath() public method

public getPath ( ) : string
return string Path of the endpoint, relative to the collection

getPostedDataMethod() public method

public getPostedDataMethod ( ) : string
return string $method One of the method constants defined in PostedDataMethods

handlerMethod() public method

public handlerMethod ( string $handlerMethod ) : static
$handlerMethod string Name of controller-method to be called for the endpoint
return static

head() public static method

Returns pre-configured HEAD endpoint
public static head ( $path, string $handlerMethod = null ) : ApiEndpoint
$path
$handlerMethod string
return ApiEndpoint

name() public method

public name ( string $name ) : static
$name string Name for the endpoint
return static

options() public static method

Returns pre-configured OPTIONS endpoint
public static options ( $path, string $handlerMethod = null ) : ApiEndpoint
$path
$handlerMethod string
return ApiEndpoint

patch() public static method

Returns pre-configured PATCH endpoint
public static patch ( $path, string $handlerMethod = null ) : ApiEndpoint
$path
$handlerMethod string
return ApiEndpoint

post() public static method

Returns pre-configured POST endpoint
public static post ( $path, string $handlerMethod = null ) : ApiEndpoint
$path
$handlerMethod string
return ApiEndpoint

postedDataMethod() public method

public postedDataMethod ( string $method ) : static
$method string One of the method constants defined in PostedDataMethods
return static

put() public static method

Returns pre-configured PUT endpoint
public static put ( $path, string $handlerMethod = null ) : ApiEndpoint
$path
$handlerMethod string
return ApiEndpoint

remove() public static method

Returns pre-configured remove endpoint
public static remove ( ) : static
return static

update() public static method

Returns pre-configured update endpoint
public static update ( ) : static
return static

Property Details

$allowedRoles protected property

protected $allowedRoles

$deniedRoles protected property

protected $deniedRoles

$description protected property

protected $description

$exampleResponse protected property

protected $exampleResponse

$handlerMethod protected property

protected $handlerMethod

$httpMethod protected property

protected $httpMethod

$name protected property

protected $name

$path protected property

protected $path

$postedDataMethod protected property

protected $postedDataMethod