You are here

function _civicrm_entity_stash in CiviCRM Entity 8.3

For stashing deleted entities until we need them later.

@todo Convert hooks to a service and keep this in a member variable

Parameters

string $objectName: The CiviCRM entity type.

int $id: The id.

\Drupal\Core\Entity\EntityInterface|null|string $entity: The entity.

Return value

void|\Drupal\Core\Entity\EntityInterface

2 calls to _civicrm_entity_stash()
civicrm_entity_civicrm_post in ./civicrm_entity.module
Implements hook_civicrm_post().
civicrm_entity_civicrm_pre in ./civicrm_entity.module
Implements hook_civicrm_pre().

File

./civicrm_entity.module, line 321
Module file for the CiviCRM Entity module.

Code

function _civicrm_entity_stash($objectName, $id, $entity = NULL) {
  $cache =& drupal_static(__FUNCTION__, []);
  if (empty($entity)) {
    return isset($cache[$objectName][$id]) ? $cache[$objectName][$id] : NULL;
  }
  elseif ($entity === 'clear') {
    unset($cache[$objectName][$id]);
  }
  else {
    $cache[$objectName][$id] = $entity;
  }
}