public function CerPresetHandler::update in Corresponding Entity References 7.3
Process an entity update. This could be either a normal update done by a user, or a bulk update.
File
- includes/
CerPresetHandler.inc, line 73 - Contains CerPresetHandler.
Class
- CerPresetHandler
- @class Contains the logic for performing CER operations on a single entity, using a single preset.
Code
public function update() {
// Get the previous set of reference IDs. $entity->cer->original will return either
// $entity->original, if it exists, or the current entity. So, if this is a bulk
// update, $originalIDs will be identical to $this->refIDs.
$originalIDs = $this->left
->getHandler($this->entity->cer->original)
->getIDs();
// If there are any references that were in the previous set but not the current
// set, delete those backreferences. Under normal circumstances, there will be
// nothing to delete during a bulk update, since the previous set and current
// set should be identical.
$deleted = array_diff($originalIDs, $this->refIDs);
if ($deleted) {
$this
->delete($deleted);
}
// If the previous set is identical to the current set, we'll be processing
// all existing references (see the first line of $this->insert()).
$added = array_diff($this->refIDs, $originalIDs);
$this
->insert($added);
}