TestHttpSource

Extends \HttpSource

Test source

package

HttpSourceTestSource

subpackage

Model.Datasource.Http

Methods

Constructor

__construct(array $config = array(), \HttpSourceConnection $Connection = null) 
inherited
throws

Arguments

$config

array

$Connection

\HttpSourceConnection

Store request transaction

_addTransaction(string $method, array $request) : boolean
inherited

Arguments

$method

string

$request

array

Response

boolean

Build request depends on parameters and config and store it in $model->request

_buildRequest(string $method, \Model $model, array $queryData = array(), array $fields = null, array $values = null, array $conditions = null, integer $recursive = null) 
inherited
throws

Arguments

$method

string

create/read/update/delete

$model

\Model

The model being read.

$queryData

array

Query data for read

$fields

array

Fields for save/create

$values

array

Fields values for update/create

$conditions

array

Conditions for update

$recursive

integer

Number of levels of association. NOT USED YET

Remove not specified fields from result

_emulateFields(\Model $Model, array &$result) 
inherited

Arguments

$Model

\Model

$result

array

Apply function if specified in fields

_emulateFunctions(\Model $Model, array &$result) : boolean
inherited

Arguments

$Model

\Model

$result

array

Response

boolean

True if function applied

Slice result

_emulateLimit(\Model $Model, array &$result) 
inherited

Arguments

$Model

\Model

$result

array

Sort result

_emulateOrder(\Model $Model, array &$result) 
inherited

Arguments

$Model

\Model

$result

array

Extract data from decoded response

_extractResult(\Model $model, array $result, string $requestMethod, boolean $force = false) : array
inherited

Arguments

$model

\Model

$result

array

$requestMethod

string

$force

boolean

Response

array

Format result to match Cake conventions

_formatResult(\Model $Model, array &$result) 
inherited

Arguments

$Model

\Model

$result

array

Return current endpoint or create new

_getCurrentEndpoint() : \HttpSourceEndpoint
inherited

Return current query data

_getQueryData(string $path = null) : mixed
inherited

Arguments

$path

string

Response

mixed

Join responses into single response

_joinResponses(array $responses) : array
inherited

Arguments

$responses

array

Response

array

Load config wrapper

_loadConfig(string $plugin) 
inherited

Arguments

$plugin

string

Fill request parameter of the model, if no model specified - create basic model

_requestToModel(array $request, \Model $Model = null) : \AppModel
inherited

Arguments

$request

array

$Model

\Model

Response

\AppModel

Make requests based on schema

_schemaToRequests(\CakeSchema $Schema, string $tableName, array $options) : array
inherited

Arguments

$Schema

\CakeSchema

$tableName

string

$options

array

Response

array

Private helper method to remove query metadata in given data array.

_scrubQueryData(array $data) : array
inherited

Arguments

$data

array

Response

array

Set config

_setConfig(\HttpSourceConfig $Config) 
inherited
throws

Arguments

Single request

_singleRequest(array $request, string $requestMethod, \Model $model = null) : array|boolean
inherited

Arguments

$request

array

$requestMethod

string

$model

\Model

Response

array|boolean

Split request into subequests

_splitRequest(array $request) : array
inherited

Arguments

$request

array

Response

array

Writes a new key for the in memory query cache and cache specified by current endpoint

_writeQueryCache(array $request, mixed $data) 
inherited

Arguments

$request

array

Http request

$data

mixed

result of $request query

After request callback Filter data by fields, emulate limit, offset, order etc.

afterRequest(\Model $model, array $result, string $requestMethod) : array
inherited

Override this method for your DataSource.

Arguments

$model

\Model

$result

array

$requestMethod

string

Create, update, read or delete

Response

array

Just-In-Time callback for any last-minute request modifications

beforeRequest(array $request, string $requestMethod) : array
inherited

Arguments

$request

array

$requestMethod

string

Create, update, read or delete

Response

array

$request

{@inheritdoc}

begin() : boolean
inherited

Response

boolean

Returns true if a transaction is not in progress

Returns an calculation, i.e. COUNT

calculate(\Model $model, string $func, array $params = array()) : string
inherited
throws

Arguments

$model

\Model

$func

string

Lowercase name of function, i.e. 'count'

$params

array

Function parameters (any values must be quoted manually)

Response

string

An calculation function

{@inheritdoc}

commit() : boolean
inherited

Response

boolean

Returns true if a transaction is in progress

{inheritdoc}

create(\Model $model, array $fields = null, array $values = null) 
inherited

Arguments

$model

\Model

$fields

array

Unused

$values

array

Unused

Returns requests array for create schema(s)

createSchema(\CakeSchema $Schema, string $tableName = null) : array
inherited

Arguments

$Schema

\CakeSchema

$tableName

string

Response

array

{inheritdoc}

delete(\Model $model, array $conditions = null) 
inherited

Arguments

$model

\Model

$conditions

array

{@inheritdoc}

describe(\Model $model) : array
inherited

Arguments

$model

\Model

Response

array

Returns requests array for drop schema(s)

dropSchema(\CakeSchema $Schema, string $tableName = null) : array
inherited

Arguments

$Schema

\CakeSchema

$tableName

string

Response

array

Execute single or multiple requests

execute(array $request) : array
inherited

Arguments

$request

array

Response

array

Check if record identified by conditions is exists

exists(\Model $model, array $conditions = array()) 
inherited

Arguments

$model

\Model

$conditions

array

Returns config

getConfig() : \HttpSourceConfig
inherited

Returns connection

getConnection() : \HttpSourceConnection
inherited

Gets credentials data

getCredentials() : array
inherited

Response

array

Get decoder for given $contentType

getDecoder(string $contentType) 
inherited

Arguments

$contentType

string

Content type

Get the query log as an array.

getLog(boolean $sorted = false, boolean $clear = true) : array
inherited

Arguments

$sorted

boolean

Get the queries sorted by time taken, defaults to false.

$clear

boolean

If True the existing log will cleared.

Response

array

Array of queries run as an array

List of constants METHOD_*

getMethods() : array
inherited static

Response

array

Returns the result for a query if it is already cached

getQueryCache(array $request) : mixed
inherited

Arguments

$request

array

query

Response

mixed

results for query if it is cached, false otherwise

Returns record for log

getRequestLog() : array
inherited

Response

array

Return transaction params

getTransactionParams() : array
inherited

Response

array

Returns all available sources

listSources(mixed $data = null) : array
inherited

Arguments

$data

mixed

Response

array

Array of sources available in this datasource.

Log given query.

logRequest() : void
inherited

Http query abstraction

query(mixed $request) : array|false
inherited
throws

Arguments

$request

mixed

Array of request or string uri

Response

array|false

Queries associations. Used to fetch results on recursive models.

queryAssociation(\Model $model, \Model &$linkModel, string $type, string $association, array $assocData, array &$queryData, boolean $external, array &$resultSet, integer $recursive, array $stack) : mixed
inherited
throws

Arguments

$model

\Model

Primary Model object

$linkModel

\Model

Linked model that

$type

string

Association type, one of the model association types ie. hasMany

$association

string

$assocData

array

$queryData

array

$external

boolean

Whether or not the association query is on an external datasource.

$resultSet

array

Existing results

$recursive

integer

Number of levels of association

$stack

array

Response

mixed

{inheritdoc}

read(string $model, string $queryData = array(), integer $recursive = null) : mixed
inherited
access

public

Arguments

$model

string

The model being read.

$queryData

string

An array of query data used to find the data you want

$recursive

integer

Response

mixed

Sends HttpSocket requests. Builds your uri and formats the response too.

request(\Model $model = null, mixed $requestData = null, string $requestMethod = \HttpSource::METHOD_READ) : array|false
inherited
throws

Arguments

$model

\Model

Model object

$requestData

mixed

Array of request or string uri

$requestMethod

string

read, create, update, delete

Response

array|false

$response

{@inheritdoc}

rollback() : boolean
inherited

Response

boolean

Returns true if a transaction is in progress

Sets credentials data

setCredentials(array $credentials = array()) 
inherited

Arguments

$credentials

array

Add decoder for given $contentType

setDecoder(string|array $contentType, callable $callback, boolean $replace = false) 
inherited

Arguments

$contentType

string|array

Content type

$callback

callable

Function used for decoding

$replace

boolean

Replace decoder if already set or not. Default false

Set parameters for endpoint wich handle transactions

setTransactionParams(string $table, array $params, string $transactionsField, string $method) 
inherited

Arguments

$table

string

$params

array

$transactionsField

string

$method

string

Outputs the contents of the queries log. If in a non-CLI environment the sql_log element will be rendered and output. If in a CLI environment, a plain text log is generated.

showLog(boolean $sorted = false, boolean $html = null) : void
inherited

Arguments

$sorted

boolean

Get the queries sorted by time taken, defaults to false.

$html

boolean

True for html output, null for auto

Iterates through the tokens (passed or request items) and replaces them into the url

swapTokens(array &$request) 
inherited

Arguments

$request

array

{inheritdoc}

update(\Model $model, array $fields = null, array $values = null, array $conditions = null) 
inherited

Arguments

$model

\Model

$fields

array

$values

array

$conditions

array

Constants

Count function constant

FUNCTION_COUNT
inherited

CRUD constants

METHOD_READ
inherited

METHOD_CREATE

METHOD_CREATE
inherited

METHOD_UPDATE

METHOD_UPDATE
inherited

METHOD_DELETE

METHOD_DELETE
inherited

METHOD_CHECK

METHOD_CHECK
inherited

Http methods constants

HTTP_METHOD_READ
inherited

HTTP_METHOD_CREATE

HTTP_METHOD_CREATE
inherited

HTTP_METHOD_UPDATE

HTTP_METHOD_UPDATE
inherited

HTTP_METHOD_DELETE

HTTP_METHOD_DELETE
inherited

HTTP_METHOD_CHECK

HTTP_METHOD_CHECK
inherited

Maximum log length

LOG_MAX_LENGTH
inherited

String to replace truncated part of log

LOG_TRUNCATED
inherited

Properties

The description of this data source

description : string
inherited
var

Type(s)

string

Print full query debug info?

fullDebug : boolean
inherited
var

Type(s)

boolean

Holds the datasource configuration

config : array
inherited
var

Type(s)

array

Time the last query took

took : integer
inherited
var

Type(s)

integer

Last query

query : string
inherited
var

Type(s)

string

Rows affected

affected : integer
inherited
var

Type(s)

integer

Rows number

numRows : integer
inherited
var

Type(s)

integer

Time the last query error

error : string
inherited
var

Type(s)

string

Configuration object

Config : \HttpSourceConfig
inherited
var

Type(s)

\HttpSourceConfig

Columns info by type.

columns : array
inherited

Used in Model::save, Model::create methods

var

Type(s)

array

Instance of HttpSourceConnection class

_Connection : \HttpSourceConnection
inherited
var

Type(s)

\HttpSourceConnection

Current requested endpoint

_currentEndpoint : \HttpSourceEndpoint
inherited
var

Type(s)

\HttpSourceEndpoint

Queries count.

_requestsCnt : integer
inherited
var

Type(s)

integer

Total duration of all queries.

_requestsTime : integer
inherited
var

Type(s)

integer

Log of queries executed by this DataSource

_requestsLog : array
inherited
var

Type(s)

array

Maximum number of items in query log

_requestsLogMax : integer
inherited

This is to prevent query log taking over too much memory.

var

Maximum number of queries in the queries log.

Type(s)

integer

Caches serialized results of executed queries

_requestCache : array
inherited
var

Cache of results from executed queries.

Type(s)

array

Query data passed in read method

_queryData : array
inherited
var

Type(s)

array

Params for commit transaction

_transactionParams : array
inherited
var

Type(s)

array

Transactions

_transactions : array
inherited
var

Type(s)

array