You are here

public static function CerField::getPlugin in Corresponding Entity References 7.3

Returns a single field plugin instance, by its identifier. All plugin instances are statically cached.

Parameters

string $identifier: The plugin's identifier, in the format entity_type:bundle:field_name.

Return value

CerField

Throws

Exception if there's no plugin for the given identifier. Why so harsh, you ask? Because CerFieldChain::unpack() utterly depends on being able to get plugin instances for every field in the chain, and if it can't, it could result in myriad weird and serious problems. Throwing an exception will head that off at the pass.

2 calls to CerField::getPlugin()
CerFieldChain::collect in includes/CerFieldChain.inc
Returns an array of every possible field chain for a single field, identified by its key in hook_cer_fields().
CerFieldChain::unpack in includes/CerFieldChain.inc
Constructs and returns a CerFieldChain object from an encoded string of field plugin identifiers glued together with ::.

File

includes/CerField.inc, line 143
Contains the base class for CER field plugins.

Class

CerField
@class Represents a single field instance.

Code

public static function getPlugin($identifier) {
  $instances =& drupal_static(__METHOD__);
  if (!isset($instances[$identifier])) {
    $info = self::getPluginInfo($identifier);
    if ($info) {
      $instances[$identifier] = new $info['class']($info);
    }
    else {
      throw new Exception("Cannot get instance of invalid plugin {$identifier}.");
    }
  }
  return $instances[$identifier];
}