You are here

public function Simple::register in Organic groups 8

Registers a soon to be deleted group entity, for processing.

During processing its orphaned members or content will be deleted.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The group entity to register.

Overrides OgDeleteOrphansBase::register

File

src/Plugin/OgDeleteOrphans/Simple.php, line 24

Class

Simple
Performs an on-the-fly deletion of orphans.

Namespace

Drupal\og\Plugin\OgDeleteOrphans

Code

public function register(EntityInterface $entity) {
  parent::register($entity);

  // Check if our cleanup process is already registered, so we don't add any
  // duplicates.
  $callbacks = array_filter(drupal_register_shutdown_function(), function ($callback) {
    $callable = $callback['callback'];
    return is_array($callable) && $callable[0] instanceof $this && $callable[1] === 'process';
  });

  // Register a shutdown function that deletes the orphans on the fly.
  if (empty($callbacks)) {
    drupal_register_shutdown_function([
      $this,
      'process',
    ]);
  }
}