PHP Class Cake\ElasticSearch\Marshaller

Useful when converting request data into documents.
ファイルを表示 Open project: cakephp/elastic-search

Protected Properties

Property Type Description
$type Type Type instance this marshaller is for.

Public Methods

Method Description
__construct ( Type $type ) Constructor
many ( array $data, array $options = [] ) : array Hydrate a collection of entities.
merge ( Cake\Datasource\EntityInterface $entity, array $data, array $options = [] ) : Cake\Datasource\EntityInterface Merges $data into $document.
mergeMany ( array $entities, array $data, array $options = [] ) : array Update a collection of entities.
one ( array $data, array $options = [] ) : Cake\ElasticSearch\Document; Hydrate a single document.

Protected Methods

Method Description
_prepareDataAndOptions ( array $data, array $options ) : array Returns data and options prepared to validate and marshall.
_validate ( array $data, array $options, boolean $isNew ) : array Returns the validation errors for a data set based on the passed options
mergeNested ( Embedded $embed, Document | array $existing, array $data ) : array | Document Merge an embedded document.
newNested ( Embedded $embed, array $data ) : array | Document Marshal an embedded document.

Method Details

__construct() public method

Constructor
public __construct ( Type $type )
$type Type The type instance this marshaller is for.

_prepareDataAndOptions() protected method

Returns data and options prepared to validate and marshall.
protected _prepareDataAndOptions ( array $data, array $options ) : array
$data array The data to prepare.
$options array The options passed to this marshaller.
return array An array containing prepared data and options.

_validate() protected method

Returns the validation errors for a data set based on the passed options
protected _validate ( array $data, array $options, boolean $isNew ) : array
$data array The data to validate.
$options array The options passed to this marshaller.
$isNew boolean Whether it is a new entity or one to be updated.
return array The list of validation errors.

many() public method

### Options: * fieldList: A whitelist of fields to be assigned to the entity. If not present, the accessible fields list in the entity will be used. * accessibleFields: A list of fields to allow or deny in entity accessible fields.
public many ( array $data, array $options = [] ) : array
$data array A list of entity data you want converted into objects.
$options array Options
return array An array of hydrated entities

merge() public method

### Options: * fieldList: A whitelist of fields to be assigned to the entity. If not present the accessible fields list in the entity will be used. * associated: A list of embedded documents you want to marshal.
public merge ( Cake\Datasource\EntityInterface $entity, array $data, array $options = [] ) : Cake\Datasource\EntityInterface
$entity Cake\Datasource\EntityInterface the entity that will get the data merged in
$data array key value list of fields to be merged into the entity
$options array List of options.
return Cake\Datasource\EntityInterface

mergeMany() public method

Merges each of the elements from $data into each of the entities in $entities. Records in $data are matched against the entities using the id field. Entries in $entities that cannot be matched to any record in $data will be discarded. Records in $data that could not be matched will be marshalled as a new entity. ### Options: * fieldList: A whitelist of fields to be assigned to the entity. If not present, the accessible fields list in the entity will be used.
public mergeMany ( array $entities, array $data, array $options = [] ) : array
$entities array An array of Elasticsearch entities
$data array A list of entity data you want converted into objects.
$options array Options
return array An array of merged entities

mergeNested() protected method

Merge an embedded document.
protected mergeNested ( Embedded $embed, Document | array $existing, array $data ) : array | Document
$embed Cake\ElasticSearch\Association\Embedded The embed definition.
$existing Document | array The existing entity or entities.
$data array The data to marshal
return array | Document Either a document or an array of documents.

newNested() protected method

Marshal an embedded document.
protected newNested ( Embedded $embed, array $data ) : array | Document
$embed Cake\ElasticSearch\Association\Embedded The embed definition.
$data array The data to marshal
return array | Document Either a document or an array of documents.

one() public method

### Options: * fieldList: A whitelist of fields to be assigned to the entity. If not present, the accessible fields list in the entity will be used. * accessibleFields: A list of fields to allow or deny in entity accessible fields. * associated: A list of embedded documents you want to marshal.
public one ( array $data, array $options = [] ) : Cake\ElasticSearch\Document;
$data array The data to hydrate.
$options array List of options
return Cake\ElasticSearch\Document;

Property Details

$type protected_oe property

Type instance this marshaller is for.
protected Type,Cake\ElasticSearch $type
return Type