Class \Prado\Web\Services\TJsonService
TJsonService class provides to end-users javascript content response in
JSON format.
TJsonService manages a set of TJsonResponse, each representing specific response with javascript content. The service parameter, referring to the ID of the service, specifies which javascript content to be provided to end-users.
To use TJsonService, configure it in application configuration as follows,
<service id="json" class="Prado\Web\Services\TJsonService">
<json id="get_article" class="Path\To\JsonResponseClass1" .../>
<json id="register_rating" class="Path\To\JsonResponseClass2" .../>
</service>
where each JSON response is specified via a <json> element. Initial property values can be configured in a <json> element.
PHP configuration style:
'services' => array(
'get_article' => array(
'class' => 'Path\To\JsonResponseClass1',
'properties' => array(
...
)
)
)
To retrieve the JSON content provided by "get_article", use the URL
index.php?json=get_article
Class hierarchy
- \Prado\Web\Services\TJsonService
- \Prado\TService implements IService
- \Prado\TApplicationComponent
- \Prado\TComponent
Author: Carl G. Mathisen <carlgmathisen@gmail.com>
Since: 3.1
public
|
|
public
|
|
protected
|
createJsonResponse(mixed $service, mixed $properties, mixed $config) : mixed
Renders content provided by TJsonResponse::getJsonContent() as
javascript in JSON format.
|
protected
|
\Prado\TApplicationComponent::FX_CACHE_FILE, \Prado\TComponent::GLOBAL_RAISE_EVENT_LISTENER |