PHP Class Scalr\Api\DataType\ApiEntityAdapter

Since: 5.4.0 (02.03.2015)
Author: Vitaliy Demidov ([email protected])
Inheritance: extends Scalr\Model\Objects\BaseAdapter
Exibir arquivo Open project: scalr/scalr Class Usage Examples

Protected Properties

Property Type Description
$controller Scalr\Api\Rest\Controller\ApiController Controller instance

Public Methods

Method Description
__construct ( ApiController $controller ) Constructor
convertInputValue ( $fieldType, $value, $fieldName = '' )
convertOutputValue ( string $fieldType, string $value ) : mixed Converts output value
copyAlterableProperties ( object $object, AbstractEntity $entity ) Copies all alterable properties from the request object to Entity
find ( array $criteria = null, callable $findCallback = null ) : ApiEntityAdapter Fetches records according to rules set
getCriteria ( array $criteria = null ) : array | null Adjusts search criteria according to RULE_TYPE_FILTERABLE rules and Request
getDescribeResult ( array $criteria = null, callable $findCallback = null ) : Scalr\Api\DataType\ListResultEnvelope Gets describe result
getSettingsCollection ( AbstractEntity $entity ) : SettingsCollection Gets settings collection from entity.
getSettingsRules ( ) : array Gets settings to data rules
getSorting ( ) : array | null Gets sorting option for the find method of the Entity
toData ( $entity )
toEntity ( $data )
validateEntity ( AbstractEntity $entity ) Validates entity
validateObject ( object $object, string $method = null ) Validates object
validateString ( string $string, string $message = 'Invalid string' ) Validates specified string

Method Details

__construct() public method

Constructor
public __construct ( ApiController $controller )
$controller Scalr\Api\Rest\Controller\ApiController The controller instance

convertInputValue() public static method

See also: BaseAdapter::convertInputValue()
public static convertInputValue ( $fieldType, $value, $fieldName = '' )

convertOutputValue() public static method

Converts output value
public static convertOutputValue ( string $fieldType, string $value ) : mixed
$fieldType string Field type
$value string A value taken from input
return mixed Returns value which can be used in the response

copyAlterableProperties() public method

It does not validate the values. It only checks whether the request contains only alterable properties. If not it will raise ApiErrorExceptions
public copyAlterableProperties ( object $object, AbstractEntity $entity )
$object object An object (source)
$entity Scalr\Model\AbstractEntity An Entity (destination)

find() public method

Fetches records according to rules set
public find ( array $criteria = null, callable $findCallback = null ) : ApiEntityAdapter
$criteria array optional Default search criteria
$findCallback callable optional Find method. Default value: find
return ApiEntityAdapter Returns current instance that actually is iterator of the found records

getCriteria() public method

Adjusts search criteria according to RULE_TYPE_FILTERABLE rules and Request
public getCriteria ( array $criteria = null ) : array | null
$criteria array optional Default search criteria
return array | null Returns adjusted criteria

getDescribeResult() public method

Gets describe result
public getDescribeResult ( array $criteria = null, callable $findCallback = null ) : Scalr\Api\DataType\ListResultEnvelope
$criteria array Default search criteria
$findCallback callable optional Find method. Default value: find
return Scalr\Api\DataType\ListResultEnvelope Returns describe result

getSettingsCollection() public method

Gets settings collection from entity.
public getSettingsCollection ( AbstractEntity $entity ) : SettingsCollection
$entity Scalr\Model\AbstractEntity Entity containing collection of settings
return Scalr\Model\Collections\SettingsCollection

getSettingsRules() public method

Gets settings to data rules
public getSettingsRules ( ) : array
return array

getSorting() public method

It processes HTTP Request and takes RULE_TYPE_SORTING of rules into account
public getSorting ( ) : array | null
return array | null Returns sorting option for the find method of the Entity

toData() public method

See also: BaseAdapter::toData()
public toData ( $entity )

toEntity() public method

See also: BaseAdapter::toEntity()
public toEntity ( $data )

validateEntity() public method

It is applicable only to either POST or PATCH methods. It should be used on GET methods.
public validateEntity ( AbstractEntity $entity )
$entity Scalr\Model\AbstractEntity An Entity

validateObject() public method

It is applicable only to either POST or PATCH methods. It should be used on GET methods.
public validateObject ( object $object, string $method = null )
$object object An object provided with the request
$method string optional HTTP METHOD

validateString() public method

Validates specified string
public validateString ( string $string, string $message = 'Invalid string' )
$string string A string
$message string optional A error message

Property Details

$controller protected_oe property

Controller instance
protected ApiController,Scalr\Api\Rest\Controller $controller
return Scalr\Api\Rest\Controller\ApiController