CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C Elastic Search 2.x API

  • Project:
    • Elastic Search
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 2.x
      • 4.x
      • 3.x
      • 2.x

Namespaces

  • Cake\ElasticSearch
    • Association
    • Datasource
    • Rule
    • TestSuite
    • View

Class Marshaller

Contains logic to convert array data into document objects.

Useful when converting request data into documents.

Namespace: Cake\ElasticSearch

Property Summary

  • $index protected
    Cake\ElasticSearch\Index

    Index instance this marshaller is for.

Method Summary

  • __construct() public

    Constructor

  • _prepareDataAndOptions() protected

    Returns data and options prepared to validate and marshall.

  • _validate() protected

    Returns the validation errors for a data set based on the passed options

  • createAndHydrate() protected

    Creates and Hydrates Document whilst honouring accessibleFields etc

  • many() public

    Hydrate a collection of entities.

  • merge() public

    Merges $data into $document.

  • mergeMany() public

    Update a collection of entities.

  • mergeNested() protected

    Merge an embedded document.

  • newNested() protected

    Marshal an embedded document.

  • one() public

    Hydrate a single document.

Method Detail

__construct() ¶ public

__construct(Cake\ElasticSearch\Index $index)

Constructor

Parameters
Cake\ElasticSearch\Index $index

The index instance this marshaller is for.

_prepareDataAndOptions() ¶ protected

_prepareDataAndOptions(array $data, array $options): array

Returns data and options prepared to validate and marshall.

Parameters
array $data

The data to prepare.

array $options

The options passed to this marshaller.

Returns
array

_validate() ¶ protected

_validate(array $data, array $options, bool $isNew): array

Returns the validation errors for a data set based on the passed options

Parameters
array $data

The data to validate.

array $options

The options passed to this marshaller.

bool $isNew

Whether it is a new entity or one to be updated.

Returns
array
Throws
RuntimeException
If no validator can be created.

createAndHydrate() ¶ protected

createAndHydrate(string $class, array $data, array $options = [], string $indexClass = null): Document

Creates and Hydrates Document whilst honouring accessibleFields etc

Parameters
string $class

Class name of Document to create

array $data

The data to hydrate with

array $options optional

Options to control the hydration

string $indexClass optional

Index class to get embeds from (for nesting)

Returns
Document

many() ¶ public

many(array $data, array $options = []): array

Hydrate a collection of entities.

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.
Parameters
array $data

A list of entity data you want converted into objects.

array $options optional

Options

Returns
array

merge() ¶ public

merge(Cake\Datasource\EntityInterface $entity, array $data, array $options = []): Cake\Datasource\EntityInterface

Merges $data into $document.

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.
Parameters
Cake\Datasource\EntityInterface $entity

the entity that will get the data merged in

array $data

key value list of fields to be merged into the entity

array $options optional

List of options.

Returns
Cake\Datasource\EntityInterface

mergeMany() ¶ public

mergeMany(array $entities, array $data, array $options = []): array

Update a collection of entities.

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.
Parameters
array $entities

An array of Elasticsearch entities

array $data

A list of entity data you want converted into objects.

array $options optional

Options

Returns
array

mergeNested() ¶ protected

mergeNested(Cake\ElasticSearch\Association\Embedded $embed, Cake\ElasticSearch\Document|array $existing, array $data): array|Cake\ElasticSearch\Document

Merge an embedded document.

Parameters
Cake\ElasticSearch\Association\Embedded $embed

The embed definition.

Cake\ElasticSearch\Document|array $existing

The existing entity or entities.

array $data

The data to marshal

Returns
array|Cake\ElasticSearch\Document

newNested() ¶ protected

newNested(Cake\ElasticSearch\Association\Embedded $embed, array $data, array $options = []): array|Cake\ElasticSearch\Document

Marshal an embedded document.

Parameters
Cake\ElasticSearch\Association\Embedded $embed

The embed definition.

array $data

The data to marshal

array $options optional

The options to pass on

Returns
array|Cake\ElasticSearch\Document

one() ¶ public

one(array $data, array $options = []): Cake\ElasticSearch\Document

Hydrate a single document.

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.
Parameters
array $data

The data to hydrate.

array $options optional

List of options

Returns
Cake\ElasticSearch\Document

Property Detail

$index ¶ protected

Index instance this marshaller is for.

Type
Cake\ElasticSearch\Index
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs