public function CerHandler::reference in Corresponding Entity References 7.2
Implements CerHandlerInterface::reference().
Overrides CerHandlerInterface::reference
1 call to CerHandler::reference()
- CerHandler::insert in ./
handler.inc - Implements CerHandlerInterface::insert().
File
- ./
handler.inc, line 262 - Contains base code for CER handlers, which are objects responsible for creating, updating and deleting corresponding references between entities.
Class
- CerHandler
- @class Generic CER handler with rudimentary language handling.
Code
public function reference($entity) {
if ($this
->referenceable($entity)) {
try {
$this
->addReferenceTo($entity);
} catch (CerException $e) {
// Fail silently
}
try {
$this
->addReferenceFrom($entity);
} catch (CerException $e) {
// Fail silently
}
}
else {
$variables = array(
'!local_field' => $this->local['field_name'],
'!local_type' => $this->local['entity_type'],
'!local_id' => $this->id,
'!remote_field' => $this->remote['field_name'],
'!remote_type' => $this->remote['entity_type'],
'!remote_id' => $this
->getRemoteEntityID($entity),
);
watchdog('cer', 'Failed to reference !remote_field on !remote_type !remote_id from !local_field on !local_type !local_id.', $variables, WATCHDOG_ERROR);
}
}