You are here

public function CerFieldHandler::delete in Corresponding Entity References 7.3

Deletes all references to $entity.

Parameters

EntityDrupalWrapper $entity: The wrapped entity to dereference.

File

includes/CerFieldHandler.inc, line 68
Contains CerFieldHandler.

Class

CerFieldHandler
@class Handles low-level operations for a single field on a single entity. Exposes methods to add, delete and check for references. This will also iterate over the references, returning each one as an EntityDrupalWrapper object.

Code

public function delete(EntityDrupalWrapper $entity) {
  $entityID = $entity
    ->getIdentifier();
  if ($this->isMultiValue) {
    foreach ($this->value as $delta => $ref) {
      if ($entityID == $ref
        ->getIdentifier()) {
        $this->value[$delta]
          ->set(NULL);
      }
    }
  }
  elseif ($entityID == $this->value
    ->getIdentifier()) {
    $this->value
      ->set(NULL);
  }
  $this
    ->write();
}