class CerFieldChain in Corresponding Entity References 7.3
@file Contains the CerFieldChain class.
Hierarchy
- class \FieldChain implements \SeekableIterator
- class \CerFieldChain
 
 
Expanded class hierarchy of CerFieldChain
File
- includes/
CerFieldChain.inc, line 8  - Contains the CerFieldChain class.
 
View source
class CerFieldChain extends FieldChain {
  /**
   * Convenience method. Returns a handler for this chain in the context of
   * the given entity.
   *
   * @return CerFieldChainHandler
   */
  public function getHandler(EntityDrupalWrapper $entity) {
    return new CerFieldChainHandler($this, $entity);
  }
  /**
   * Gets a regular expression to match field chain identifiers that this chain
   * can reference, e.g. /^node:(page|article):/
   */
  public function regex() {
    $end = $this
      ->end();
    return '/^' . $end
      ->getTargetType() . ':(' . implode('|', $end
      ->getTargetBundles()) . '):/';
  }
  /**
   * Returns a Features export pipe for this chain, including every field and
   * field instance in it.
   */
  public function export() {
    $pipe = array();
    foreach ($this->chain as $field) {
      $pipe['field_instance'][] = "{$field->entityType}-{$field->bundle}-{$field->name}";
    }
    return $pipe;
  }
  /**
   * Returns an array of every possible field chain for every field defined in
   * hook_cer_fields().
   *
   * @return array
   */
  public static function collectAll() {
    $chains = array();
    foreach (array_keys(CerField::getPluginInfo()) as $identifier) {
      $chains = array_merge($chains, self::collect($identifier));
    }
    return $chains;
  }
  /**
   * Returns an array of every possible field chain for a single field,
   * identified by its key in hook_cer_fields().
   *
   * @return array
   */
  public static function collect($identifier) {
    $chains = array();
    $chain = new CerFieldChain();
    $chain
      ->addField(CerField::getPlugin($identifier), $chains);
    return $chains;
  }
  /**
   * Constructs and returns a CerFieldChain object from an encoded string
   * of field plugin identifiers glued together with ::.
   *
   * @return CerFieldChain
   */
  public static function unpack($identifier) {
    $chain = new CerFieldChain();
    foreach (array_reverse(explode('::', $identifier)) as $field) {
      $chain
        ->addField(CerField::getPlugin($field));
    }
    return $chain;
  }
}Members
| 
            Name | 
                  Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| 
            CerFieldChain:: | 
                  public static | function | Returns an array of every possible field chain for a single field, identified by its key in hook_cer_fields(). | |
| 
            CerFieldChain:: | 
                  public static | function | Returns an array of every possible field chain for every field defined in hook_cer_fields(). | |
| 
            CerFieldChain:: | 
                  public | function | Returns a Features export pipe for this chain, including every field and field instance in it. | |
| 
            CerFieldChain:: | 
                  public | function | Convenience method. Returns a handler for this chain in the context of the given entity. | |
| 
            CerFieldChain:: | 
                  public | function | Gets a regular expression to match field chain identifiers that this chain can reference, e.g. /^node:(page|article):/ | |
| 
            CerFieldChain:: | 
                  public static | function | Constructs and returns a CerFieldChain object from an encoded string of field plugin identifiers glued together with ::. | |
| 
            FieldChain:: | 
                  protected | property | ||
| 
            FieldChain:: | 
                  protected | property | ||
| 
            FieldChain:: | 
                  public | function | Prepends a field instance to this chain. If $completed is passed, we'll try to find the parents of the instance and recurse upwards, building a tree of "routes" to the instance. | |
| 
            FieldChain:: | 
                  public | function | Implements Iterator::current(). | |
| 
            FieldChain:: | 
                  public | function | Returns the last field in the chain. | |
| 
            FieldChain:: | 
                  public | function | Implements Iterator::key(). | |
| 
            FieldChain:: | 
                  public | function | Implements Iterator::next(). | |
| 
            FieldChain:: | 
                  public | function | Implements Iterator::rewind(). | |
| 
            FieldChain:: | 
                  public | function | Implements SeekableIterator::seek(). | |
| 
            FieldChain:: | 
                  public | function | Implements Iterator::valid(). | |
| 
            FieldChain:: | 
                  public | function | Represents this chain as a machine-readable string, separating the fields with a T_PAAMAYIM_NEKUDOTAYIM (or, as we call it on planet Earth, a double colon). | |
| 
            FieldChain:: | 
                  public | function | Magic post-unserialization callback. Provides every field in the chain with a reference to its parent (if any) and child (if any), effectively turning the chain into a doubly linked list. |