PHP 클래스 Elgg\Ajax\Service

부터: 1.12.0
파일 보기 프로젝트 열기: elgg/elgg 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( PluginHooksService $hooks, SystemMessagesService $msgs, Input $input, Elgg\Amd\Config $amdConfig ) Constructor
appendDeps ( string $hook, string $type, Elgg\Services\AjaxResponse $response, array $params ) : Elgg\Services\AjaxResponse Send required AMD modules list back with the response
appendMessages ( string $hook, string $type, Elgg\Services\AjaxResponse $response, array $params ) : Elgg\Services\AjaxResponse Send system messages back with the response
decodeJson ( mixed $string ) : mixed Attempt to JSON decode the given string
getViews ( ) : string[] Returns an array of views allowed for ajax calls
isAjax2Request ( ) : boolean Did the request come from the elgg/Ajax module?
isReady ( ) : boolean Is the service ready to respond to the request?
registerView ( string $view ) : void Register a view to be available for ajax calls
respondFromApiResponse ( Elgg\Services\AjaxResponse $api_response, string $hook_type = '' ) : Symfony\Component\HttpFoundation\JsonResponse Send a JSON HTTP response based on the given API response
respondFromOutput ( mixed $output, string $hook_type = '', boolean $try_decode = true ) : Symfony\Component\HttpFoundation\JsonResponse Send a JSON HTTP response with the given output
respondWithError ( string $msg = '', integer $status = 400 ) : Symfony\Component\HttpFoundation\JsonResponse Send a JSON HTTP 400 response
unregisterView ( string $view ) : void Unregister a view for ajax calls

비공개 메소드들

메소드 설명
buildHttpResponse ( Elgg\Services\AjaxResponse $api_response, boolean $allow_removing_headers = null ) : Symfony\Component\HttpFoundation\JsonResponse Build a JsonResponse based on an API response object
filterApiResponse ( Elgg\Services\AjaxResponse $api_response, string $hook_type = '' ) : Elgg\Services\AjaxResponse Filter an AjaxResponse through a plugin hook

메소드 상세

__construct() 공개 메소드

Constructor
public __construct ( PluginHooksService $hooks, SystemMessagesService $msgs, Input $input, Elgg\Amd\Config $amdConfig )
$hooks Elgg\PluginHooksService Hooks service
$msgs Elgg\SystemMessagesService System messages service
$input Elgg\Http\Input Input service
$amdConfig Elgg\Amd\Config AMD config

appendDeps() 공개 메소드

Send required AMD modules list back with the response
public appendDeps ( string $hook, string $type, Elgg\Services\AjaxResponse $response, array $params ) : Elgg\Services\AjaxResponse
$hook string "ajax_response"
$type string "all"
$response Elgg\Services\AjaxResponse Ajax response
$params array Hook params
리턴 Elgg\Services\AjaxResponse

appendMessages() 공개 메소드

Send system messages back with the response
public appendMessages ( string $hook, string $type, Elgg\Services\AjaxResponse $response, array $params ) : Elgg\Services\AjaxResponse
$hook string "ajax_response"
$type string "all"
$response Elgg\Services\AjaxResponse Ajax response
$params array Hook params
리턴 Elgg\Services\AjaxResponse

decodeJson() 공개 메소드

Attempt to JSON decode the given string
public decodeJson ( mixed $string ) : mixed
$string mixed Output string
리턴 mixed

getViews() 공개 메소드

Returns an array of views allowed for ajax calls
public getViews ( ) : string[]
리턴 string[]

isAjax2Request() 공개 메소드

Did the request come from the elgg/Ajax module?
public isAjax2Request ( ) : boolean
리턴 boolean

isReady() 공개 메소드

Some code paths involve multiple layers of handling (e.g. router calls actions/ajax views) so we must check whether the response has already been sent to avoid sending it twice. We can't use headers_sent() because Router needs to use output buffering.
public isReady ( ) : boolean
리턴 boolean

registerView() 공개 메소드

Register a view to be available for ajax calls
public registerView ( string $view ) : void
$view string The view name
리턴 void

respondFromApiResponse() 공개 메소드

Send a JSON HTTP response based on the given API response
public respondFromApiResponse ( Elgg\Services\AjaxResponse $api_response, string $hook_type = '' ) : Symfony\Component\HttpFoundation\JsonResponse
$api_response Elgg\Services\AjaxResponse API response
$hook_type string The hook type. If given, the response will be filtered by hook
리턴 Symfony\Component\HttpFoundation\JsonResponse

respondFromOutput() 공개 메소드

Send a JSON HTTP response with the given output
public respondFromOutput ( mixed $output, string $hook_type = '', boolean $try_decode = true ) : Symfony\Component\HttpFoundation\JsonResponse
$output mixed Output from a page/action handler
$hook_type string The hook type. If given, the response will be filtered by hook
$try_decode boolean Try to convert a JSON string back to an abject
리턴 Symfony\Component\HttpFoundation\JsonResponse

respondWithError() 공개 메소드

Send a JSON HTTP 400 response
public respondWithError ( string $msg = '', integer $status = 400 ) : Symfony\Component\HttpFoundation\JsonResponse
$msg string The error message (not displayed to the user)
$status integer The HTTP status code
리턴 Symfony\Component\HttpFoundation\JsonResponse

unregisterView() 공개 메소드

Unregister a view for ajax calls
public unregisterView ( string $view ) : void
$view string The view name
리턴 void