You are here

public function CerHandlerBase::__construct in Corresponding Entity References 7.2

1 call to CerHandlerBase::__construct()
CerHandler::__construct in ./handler.inc
Implements CerHandlerInterface::__construct().
1 method overrides CerHandlerBase::__construct()
CerHandler::__construct in ./handler.inc
Implements CerHandlerInterface::__construct().

File

./handler.inc, line 113
Contains base code for CER handlers, which are objects responsible for creating, updating and deleting corresponding references between entities.

Class

CerHandlerBase
@class Base class for CER handlers. All this does is parse the preset and store instance info about the local and remote fields.

Code

public function __construct($preset) {
  $keys = explode('*', $preset);
  if (sizeof($keys) != 6) {
    throw new CerException(t('Invalid configuration: @preset', array(
      '@preset' => $preset,
    )));
  }
  $this->local = field_info_instance($keys[0], $keys[2], $keys[1]);
  if ($this->local) {
    $this->local['field'] = field_info_field($keys[2]);
  }
  else {
    throw new CerException(t('Local field instance does not exist.'));
  }
  $this->remote = field_info_instance($keys[3], $keys[5], $keys[4]);
  if ($this->remote) {
    $this->remote['field'] = field_info_field($keys[5]);
  }
  else {
    throw new CerException(t('Remote field instance does not exist.'));
  }
}