PHP Class Piwik\API\ResponseBuilder

Mostrar archivo Open project: piwik/piwik Class Usage Examples

Public Methods

Method Description
__construct ( string $outputFormat, array $request = [] )
disableDataTablePostProcessor ( )
disableSendHeader ( )
getResponse ( mixed $value = null, boolean | string $apiModule = false, boolean | string $apiMethod = false ) : mixed This method processes the data resulting from the API call.
getResponseException ( Exceptio\Exception | Throwable $e ) : string Returns an error $message in the requested $format

Private Methods

Method Description
decorateExceptionWithDebugTrace ( Exceptio\Exception | Throwable $e ) : Exception
formatExceptionMessage ( Exceptio\Exception | Throwable $exception ) : string
handleArray ( $array )
handleDataTable ( Piwik\DataTable\DataTableInterface $datatable )
sendHeaderIfEnabled ( )

Method Details

__construct() public method

public __construct ( string $outputFormat, array $request = [] )
$outputFormat string
$request array

disableDataTablePostProcessor() public method

disableSendHeader() public method

public disableSendHeader ( )

getResponse() public method

- If the data resulted from the API call is a DataTable then - we apply the standard filters if the parameters have been found in the URL. For example to offset,limit the Table you can add the following parameters to any API call that returns a DataTable: filter_limit=10&filter_offset=20 - we apply the filters that have been previously queued on the DataTable
See also: DataTable::queueFilter() - we apply the renderer that generate the DataTable in a given format (XML, PHP, HTML, JSON, etc.) the format can be changed using the 'format' parameter in the request. Example: format=xml - If there is nothing returned (void) we display a standard success message - If there is a PHP array returned, we try to convert it to a dataTable It is then possible to convert this datatable to any requested format (xml/etc) - If a bool is returned we convert to a string (true is displayed as 'true' false as 'false') - If an integer / float is returned, we simply return it
public getResponse ( mixed $value = null, boolean | string $apiModule = false, boolean | string $apiMethod = false ) : mixed
$value mixed The initial returned value, before post process. If set to null, success response is returned.
$apiModule boolean | string The API module that was called
$apiMethod boolean | string The API method that was called
return mixed Usually a string, but can still be a PHP data structure if the format requested is 'original'

getResponseException() public method

Returns an error $message in the requested $format
public getResponseException ( Exceptio\Exception | Throwable $e ) : string
$e Exceptio\Exception | Throwable
return string