You are here

public function CerFieldCollectionField::createInnerEntity in Corresponding Entity References 7.3

Implements CerEntityContainerInterface::createInnerEntity().

Overrides CerEntityContainerInterface::createInnerEntity

File

includes/fields/field_collection.inc, line 27
Contains the CER plugin for Field Collection fields.

Class

CerFieldCollectionField
@file Contains the CER plugin for Field Collection fields.

Code

public function createInnerEntity(EntityDrupalWrapper $owner) {

  // Create an empty field collection item.
  $collection = new EntityDrupalWrapper('field_collection_item', entity_create('field_collection_item', array(
    'field_name' => $this->name,
  )));
  $collection->host_entity
    ->set($owner);
  $collection
    ->save(TRUE);

  // 'Reference' the newly created field collection item.
  $this
    ->getHandler($owner)
    ->add($collection);
  return $collection;
}