PHP Class Scalr\Api\DataType\ApiEntityAdapter

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

Protected Properties

Свойство Type Description
$controller Scalr\Api\Rest\Controller\ApiController Controller instance

Méthodes publiques

Méthode 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 méthode

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

convertInputValue() public static méthode

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

convertOutputValue() public static méthode

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

copyAlterableProperties() public méthode

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 méthode

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
Résultat ApiEntityAdapter Returns current instance that actually is iterator of the found records

getCriteria() public méthode

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

getDescribeResult() public méthode

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
Résultat Scalr\Api\DataType\ListResultEnvelope Returns describe result

getSettingsCollection() public méthode

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

getSettingsRules() public méthode

Gets settings to data rules
public getSettingsRules ( ) : array
Résultat array

getSorting() public méthode

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

toData() public méthode

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

toEntity() public méthode

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

validateEntity() public méthode

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 méthode

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 méthode

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
Résultat Scalr\Api\Rest\Controller\ApiController