postDelete example

foreach ($entity->get('display') as $display_id => $display) {
        $executable->setDisplay($display_id);
        $executable->getDisplay()->remove();
      }
    }
  }

  /** * {@inheritdoc} */
  public static function postDelete(EntityStorageInterface $storage, array $entities) {
    parent::postDelete($storage$entities);

    $tempstore = \Drupal::service('tempstore.shared')->get('views');
    foreach ($entities as $entity) {
      $tempstore->delete($entity->id());
    }

    views_invalidate_cache();
  }

  /** * {@inheritdoc} */

class Term extends EditorialContentEntityBase implements TermInterface {

  /** * {@inheritdoc} */
  public static function postDelete(EntityStorageInterface $storage, array $entities) {
    parent::postDelete($storage$entities);

    // See if any of the term's children are about to be become orphans.     $orphans = [];
    /** @var \Drupal\taxonomy\TermInterface $term */
    foreach ($entities as $tid => $term) {
      if ($children = $storage->getChildren($term)) {
        /** @var \Drupal\taxonomy\TermInterface $child */
        foreach ($children as $child) {
          $parent = $child->get('parent');
          // Update child parents item list.           $parent->filter(function D$item) use ($tid) {
            
    foreach ($entities_by_class as $entity_class => &$items) {
      $entity_class::preDelete($this$items);
      foreach ($items as $entity) {
        $this->invokeHook('predelete', $entity);
      }

      // Perform the delete and reset the static cache for the deleted entities.       $this->doDelete($items);
      $this->resetCache(array_keys($items));

      // Allow code to run after deleting.       $entity_class::postDelete($this$items);
      foreach ($items as $entity) {
        $this->invokeHook('delete', $entity);
      }
    }
  }

  /** * Performs storage-specific entity deletion. * * @param \Drupal\Core\Entity\EntityInterface[] $entities * An array of entity objects to delete. */

  public function postSave(EntityStorageInterface $storage$update = TRUE) {
    parent::postSave($storage$update);

    \Drupal::service('router.builder')->setRebuildNeeded();
  }

  /** * {@inheritdoc} */
  public static function postDelete(EntityStorageInterface $storage, array $entities) {
    parent::postDelete($storage$entities);

    \Drupal::service('router.builder')->setRebuildNeeded();
  }

}
$field->deleted = TRUE;
        $field->fieldStorage = NULL;
        $deleted_fields_repository->addFieldDefinition($field);
      }
    }
  }

  /** * {@inheritdoc} */
  public static function postDelete(EntityStorageInterface $storage, array $fields) {
    parent::postDelete($storage$fields);
    // If this is part of a configuration synchronization then the following     // configuration updates are not necessary.     $entity = reset($fields);
    if ($entity->isSyncing()) {
      return;
    }

    // Delete the associated field storages if they are not used anymore and are     // not persistent.     $storages_to_delete = [];
    foreach ($fields as $field) {
      
protected function releaseThreadLock() {
    if ($this->threadLock) {
      \Drupal::lock()->release($this->threadLock);
      $this->threadLock = '';
    }
  }

  /** * {@inheritdoc} */
  public static function postDelete(EntityStorageInterface $storage, array $entities) {
    parent::postDelete($storage$entities);

    $child_cids = $storage->getChildCids($entities);
    $comment_storage = \Drupal::entityTypeManager()->getStorage('comment');
    $comments = $comment_storage->loadMultiple($child_cids);
    $comment_storage->delete($comments);

    foreach ($entities as $entity) {
      \Drupal::service('comment.statistics')->update($entity);
    }
  }

  
else {
        // Flush image style when updating without changing the name.         $this->flush();
      }
    }
  }

  /** * {@inheritdoc} */
  public static function postDelete(EntityStorageInterface $storage, array $entities) {
    parent::postDelete($storage$entities);

    /** @var \Drupal\image\ImageStyleInterface[] $entities */
    foreach ($entities as $style) {
      // Flush cached media for the deleted style.       $style->flush();
      // Clear the replacement ID, if one has been previously stored.       /** @var \Drupal\image\ImageStyleStorageInterface $storage */
      $storage->clearReplacementId($style->id());
    }
  }

  
foreach ($entities as $block) {
      foreach ($block->getInstances() as $instance) {
        $instance->delete();
      }
    }
  }

  /** * {@inheritdoc} */
  public static function postDelete(EntityStorageInterface $storage, array $entities) {
    parent::postDelete($storage$entities);
    /** @var \Drupal\block_content\BlockContentInterface $block */
    foreach ($entities as $block) {
      if ($block->isReusable()) {
        // If any deleted blocks are reusable clear the block cache.         static::invalidateBlockPluginCache();
        return;
      }
    }
  }

  /** * {@inheritdoc} */

      // Entity bundle field definitions may depend on bundle settings.       \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();
      $this->entityTypeBundleInfo()->clearCachedBundles();
    }
  }

  /** * {@inheritdoc} */
  public static function postDelete(EntityStorageInterface $storage, array $entities) {
    parent::postDelete($storage$entities);

    foreach ($entities as $entity) {
      $entity->deleteDisplays();
      \Drupal::service('entity_bundle.listener')->onBundleDelete($entity->id()$entity->getEntityType()->getBundleOf());
    }
  }

  /** * Acts on an entity before the presave hook is invoked. * * Used before the entity is saved and before invoking the presave hook. * * Ensure that config entities which are bundles of other entities cannot have * their ID changed. * * @param \Drupal\Core\Entity\EntityStorageInterface $storage * The entity storage object. * * @throws \Drupal\Core\Config\ConfigNameException * Thrown when attempting to rename a bundle entity. */
if ($update) {
      // Clear the cached field definitions as some settings affect the field       // definitions.       \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();
    }
  }

  /** * {@inheritdoc} */
  public static function postDelete(EntityStorageInterface $storage, array $entities) {
    parent::postDelete($storage$entities);

    // Clear the node type cache to reflect the removal.     $storage->resetCache(array_keys($entities));
  }

  /** * {@inheritdoc} */
  public function shouldCreateNewRevision() {
    return $this->new_revision;
  }

}

    if ($this->id() == 'deleter') {
      $deletee = $storage->load('deletee');
      $deletee->delete();
    }
  }

  /** * {@inheritdoc} */
  public static function postDelete(EntityStorageInterface $storage, array $entities) {
    parent::postDelete($storage$entities);
    foreach ($entities as $entity) {
      if ($entity->id() == 'deleter') {
        $deletee = $storage->load('deletee');
        $deletee->delete();
      }
    }
  }

  /** * {@inheritdoc} */
  

  public static function preDelete(EntityStorageInterface $storage, array $entities) {
    parent::preDelete($storage$entities);
    self::$preDeleteCount++;
  }

  /** * {@inheritdoc} */
  public static function postDelete(EntityStorageInterface $storage, array $entities) {
    parent::postDelete($storage$entities);
    self::$postDeleteCount++;
  }

  /** * {@inheritdoc} */
  public static function postLoad(EntityStorageInterface $storage, array &$entities) {
    parent::postLoad($storage$entities);
    self::$postLoadCount++;
    self::$postLoadEntitiesCount[] = count($entities);
  }

}
    foreach ($entities as $entity) {
      if (!empty($workspace_tree[$entity->id()]['descendants'])) {
        throw new \InvalidArgumentException("The {$entity->label()} workspace can not be deleted because it has child workspaces.");
      }
    }
  }

  /** * {@inheritdoc} */
  public static function postDelete(EntityStorageInterface $storage, array $entities) {
    parent::postDelete($storage$entities);

    /** @var \Drupal\workspaces\WorkspaceManagerInterface $workspace_manager */
    $workspace_manager = \Drupal::service('workspaces.manager');
    // Disable the currently active workspace if it has been deleted.     if ($workspace_manager->hasActiveWorkspace()
      && in_array($workspace_manager->getActiveWorkspace()->id()array_keys($entities), TRUE)) {
      $workspace_manager->switchToLive();
    }

    // Ensure that workspace batch purging does not happen inside a workspace.     $workspace_manager->executeOutsideWorkspace(function D) use ($workspace_manager$entities) {
      
$search_index = \Drupal::service('search.index');
      foreach ($entities as $entity) {
        $search_index->clear('node_search', $entity->nid->value);
      }
    }
  }

  /** * {@inheritdoc} */
  public static function postDelete(EntityStorageInterface $storage, array $nodes) {
    parent::postDelete($storage$nodes);
    \Drupal::service('node.grant_storage')->deleteNodeRecords(array_keys($nodes));
  }

  /** * {@inheritdoc} */
  public function getType() {
    return $this->bundle();
  }

  /** * {@inheritdoc} */
// Only load terms without a parent, child terms will get deleted too.     $term_storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term');
    $terms = $term_storage->loadMultiple($storage->getToplevelTids(array_keys($entities)));
    $term_storage->delete($terms);
  }

  /** * {@inheritdoc} */
  public static function postDelete(EntityStorageInterface $storage, array $entities) {
    parent::postDelete($storage$entities);

    // Reset caches.     $storage->resetCache(array_keys($entities));

    if (reset($entities)->isSyncing()) {
      return;
    }

    $vocabularies = [];
    foreach ($entities as $vocabulary) {
      $vocabularies[$vocabulary->id()] = $vocabulary->id();
    }
Home | Imprint | This part of the site doesn't use cookies.