PHP 클래스 RESTfulAPI

파일 보기 프로젝트 열기: colymba/silverstripe-restfulapi 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$authenticator RESTfulAPI_Authenticator Current Authenticator instance
$authority RESTfulAPI_PermissionManager Current Permission Manager instance
$queryHandler RESTfulAPI_QueryHandler Current QueryHandler instance
$serializer RESTfulAPI_Serializer Current serializer instance

보호된 프로퍼티들

프로퍼티 타입 설명
$instance RESTfulAPI Current RESTfulAPI instance

공개 메소드들

메소드 설명
__construct ( ) Constructor.
acl ( SS_HTTPRequest $request ) Handles Access Control methods get response from API PermissionManager then passes it on to $answer()
answer ( string $json = null, boolean $corsPreflight = false ) Output the API response to client then exit.
api_access_control ( string | DataObject $model, string $httpMethod = 'GET' ) : boolean Checks a class or model api access depending on access_control_policy and the provided model.
auth ( SS_HTTPRequest $request ) Handles authentications methods get response from API Authenticator then passes it on to $answer()
error ( RESTfulAPI_Error $error ) Handles formatting and output error message then exit.
getqueryHandler ( ) : RESTfulAPI_QueryHandler Returns current query handler instance
getserializer ( ) : RESTfulAPI_Serializer Returns current serializer instance
index ( SS_HTTPRequest $request ) : string Main API hub switch All requests pass through here and are redirected depending on HTTP verb and params
init ( ) Controller inititalisation Catches CORS preflight request marked with HTTPMethod 'OPTIONS'

비공개 메소드들

메소드 설명
api_access_config_check ( string $className, string $httpMethod = 'GET' ) : boolean Checks a model's api_access config.
model_permission_check ( string | DataObject $model, string $httpMethod = 'GET' ) : boolean Checks a Model's permission for the currently authenticated user via the Permission Manager dependency.
setAnswerCORS ( SS_HTTPResponse $answer ) Apply the proper CORS response heardes to an SS_HTTPResponse

메소드 상세

__construct() 공개 메소드

...
public __construct ( )

acl() 공개 메소드

Handles Access Control methods get response from API PermissionManager then passes it on to $answer()
public acl ( SS_HTTPRequest $request )
$request SS_HTTPRequest HTTP request

answer() 공개 메소드

Output the API response to client then exit.
public answer ( string $json = null, boolean $corsPreflight = false )
$json string Response body
$corsPreflight boolean Set to true if this is a XHR preflight request answer. CORS shoud be enabled.

api_access_control() 공개 정적인 메소드

- 1st config check - 2nd permission check if config access passes
public static api_access_control ( string | DataObject $model, string $httpMethod = 'GET' ) : boolean
$model string | DataObject Model's classname or DataObject
$httpMethod string API request HTTP method
리턴 boolean true if access is granted, false otherwise

auth() 공개 메소드

Handles authentications methods get response from API Authenticator then passes it on to $answer()
public auth ( SS_HTTPRequest $request )
$request SS_HTTPRequest HTTP request

error() 공개 메소드

Handles formatting and output error message then exit.
public error ( RESTfulAPI_Error $error )
$error RESTfulAPI_Error Error object to return

getqueryHandler() 공개 메소드

Returns current query handler instance
public getqueryHandler ( ) : RESTfulAPI_QueryHandler
리턴 RESTfulAPI_QueryHandler QueryHandler instance

getserializer() 공개 메소드

Returns current serializer instance
public getserializer ( ) : RESTfulAPI_Serializer
리턴 RESTfulAPI_Serializer Serializer instance

index() 공개 메소드

Main API hub switch All requests pass through here and are redirected depending on HTTP verb and params
public index ( SS_HTTPRequest $request ) : string
$request SS_HTTPRequest HTTP request
리턴 string json object of the models found

init() 공개 메소드

Controller inititalisation Catches CORS preflight request marked with HTTPMethod 'OPTIONS'
public init ( )

프로퍼티 상세

$authenticator 공개적으로 프로퍼티

Current Authenticator instance
public RESTfulAPI_Authenticator $authenticator
리턴 RESTfulAPI_Authenticator

$authority 공개적으로 프로퍼티

Current Permission Manager instance
public RESTfulAPI_PermissionManager $authority
리턴 RESTfulAPI_PermissionManager

$instance 보호되어 있는 정적으로 프로퍼티

Current RESTfulAPI instance
protected static RESTfulAPI $instance
리턴 RESTfulAPI

$queryHandler 공개적으로 프로퍼티

Current QueryHandler instance
public RESTfulAPI_QueryHandler $queryHandler
리턴 RESTfulAPI_QueryHandler

$serializer 공개적으로 프로퍼티

Current serializer instance
public RESTfulAPI_Serializer $serializer
리턴 RESTfulAPI_Serializer