You are here

class CerFieldCollectionField in Corresponding Entity References 7.3

@file Contains the CER plugin for Field Collection fields.

Hierarchy

Expanded class hierarchy of CerFieldCollectionField

2 string references to 'CerFieldCollectionField'
cer_cer_fields in ./cer.cer.inc
Implements hook_cer_fields().
hook_cer_fields in ./cer.api.php
In order to create relationships between reference fields, CER needs to know about what reference fields are available, and how to handle them, which is what this hook is for. It should always return an array, even if there are no fields to expose.…

File

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

View source
class CerFieldCollectionField extends CerField implements CerEntityContainerInterface {

  /**
   * Implements CerField::getTargetType().
   */
  public function getTargetType() {
    return 'field_collection_item';
  }

  /**
   * @override CerField::getTargetBundles().
   */
  public function getTargetBundles() {
    return array(
      $this->name,
    );
  }

  /**
   * Implements CerEntityContainerInterface::createInnerEntity().
   */
  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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CerField::$fieldTypeLabel public property
CerField::$plugin protected property The plugin definition.
CerField::$settings protected property
CerField::getHandler public function Returns a CerFieldHandler subclass instance for the given entity.
CerField::getParents public function Overridden. Overrides FieldInstance::getParents
CerField::getPlugin public static function Returns a single field plugin instance, by its identifier. All plugin instances are statically cached.
CerField::getPluginInfo public static function Returns information about a particular field plugin by its identifier, or all available plugins (i.e., defined by hook_cer_fields()) if no identifier is given. The aggregated result of hook_cer_fields() is statically cached.
CerField::requireParent public function Overridden. Overrides FieldInstance::requireParent
CerField::__construct public function Constructor. Pretty self-explanatory! Overrides FieldInstance::__construct 1
CerFieldCollectionField::createInnerEntity public function Implements CerEntityContainerInterface::createInnerEntity(). Overrides CerEntityContainerInterface::createInnerEntity
CerFieldCollectionField::getTargetBundles public function @override CerField::getTargetBundles(). Overrides CerField::getTargetBundles
CerFieldCollectionField::getTargetType public function Implements CerField::getTargetType(). Overrides CerField::getTargetType
FieldInstance::$bundle public property The instance bundle.
FieldInstance::$bundleLabel public property The human-readable label of the instance's bundle.
FieldInstance::$cardinality public property The cardinality (maximum values) the field supports, or FIELD_CARDINALITY_UNLIMITED.
FieldInstance::$child protected property The child of this instance, if any.
FieldInstance::$entityType public property The instance's entity type.
FieldInstance::$entityTypeLabel public property The human-readable label of the instance's entity type.
FieldInstance::$isBundleable public property Whether or not this instance's entity type supports bundles.
FieldInstance::$label public property The instance's label.
FieldInstance::$name public property The field's machine name.
FieldInstance::$parent protected property The parent of this instance, if any.
FieldInstance::child public function Get or set the child of this field instance.
FieldInstance::parent public function Get or set the parent of this field instance.
FieldInstance::__toString public function