Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public static function preDelete(EntityStorageInterface $storage, array $entities)
 {
     parent::preDelete($storage, $entities);
     foreach ($entities as $entity) {
         $storage->deleteAssignedShortcutSets($entity);
         // Next, delete the shortcuts for this set.
         $shortcut_ids = \Drupal::entityQuery('shortcut')->condition('shortcut_set', $entity->id(), '=')->execute();
         $controller = \Drupal::entityManager()->getStorage('shortcut');
         $entities = $controller->loadMultiple($shortcut_ids);
         $controller->delete($entities);
     }
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 public static function preDelete(EntityStorageInterface $storage, array $field_storages)
 {
     $state = \Drupal::state();
     // Set the static flag so that we don't delete field storages whilst
     // deleting fields.
     static::$inDeletion = TRUE;
     // Delete or fix any configuration that is dependent, for example, fields.
     parent::preDelete($storage, $field_storages);
     // Keep the field definitions in the state storage so we can use them later
     // during field_purge_batch().
     $deleted_storages = $state->get('field.storage.deleted') ?: array();
     foreach ($field_storages as $field_storage) {
         if (!$field_storage->deleted) {
             $config = $field_storage->toArray();
             $config['deleted'] = TRUE;
             $config['bundles'] = $field_storage->getBundles();
             $deleted_storages[$field_storage->uuid()] = $config;
         }
     }
     $state->set('field.storage.deleted', $deleted_storages);
 }
Exemple #3
0
 /**
  * {@inheritdoc}
  */
 public static function preDelete(EntityStorageInterface $storage, array $entities)
 {
     // We are never going to have many entities here, so we can risk a loop.
     foreach ($entities as $key => $name) {
         // Find active jobs associated with the translator that is being deleted.
         $job_ids = \Drupal::entityQuery('tmgmt_job')->condition('state', [Job::STATE_ACTIVE, Job::STATE_CONTINUOUS, Job::STATE_UNPROCESSED], 'IN')->condition('translator', $key)->execute();
         $jobs = Job::loadMultiple($job_ids);
         /** @var \Drupal\tmgmt\JobInterface $job */
         foreach ($jobs as $job) {
             $job->aborted('Job has been aborted because the translation provider %provider was deleted.', ['%provider' => $job->getTranslatorLabel()]);
         }
     }
     parent::preDelete($storage, $entities);
 }
 /**
  * {@inheritdoc}
  */
 public static function preDelete(EntityStorageInterface $storage, array $entities)
 {
     parent::preDelete($storage, $entities);
     \Drupal::entityManager()->clearCachedFieldDefinitions();
 }
Exemple #5
0
 /**
  * {@inheritdoc}
  */
 public static function preDelete(EntityStorageInterface $storage, array $entities)
 {
     parent::preDelete($storage, $entities);
     /** @var \Drupal\search_api\IndexInterface[] $entities */
     foreach ($entities as $index) {
         if ($index->hasValidTracker()) {
             $index->getTrackerInstance()->trackAllItemsDeleted();
         }
         if ($index->hasValidServer()) {
             $index->getServerInstance()->removeIndex($index);
         }
     }
 }
Exemple #6
0
 /**
  * {@inheritdoc}
  */
 public static function preDelete(EntityStorageInterface $storage, array $entities)
 {
     parent::preDelete($storage, $entities);
     // Call the remove() hook on the individual displays.
     /** @var \Drupal\views\ViewEntityInterface $entity */
     foreach ($entities as $entity) {
         $executable = Views::executableFactory()->get($entity);
         foreach ($entity->get('display') as $display_id => $display) {
             $executable->setDisplay($display_id);
             $executable->getDisplay()->remove();
         }
     }
 }
Exemple #7
0
 /**
  * {@inheritdoc}
  */
 public static function preDelete(EntityStorageInterface $storage, array $entities) {
   parent::preDelete($storage, $entities);
   /** @var \Drupal\search_api\IndexInterface[] $entities */
   foreach ($entities as $index) {
     if ($index->hasValidTracker()) {
       $index->getTracker()->trackAllItemsDeleted();
     }
     if ($index->hasValidServer()) {
       $index->getServer()->removeIndex($index);
     }
   }
   if (\Drupal::moduleHandler()->moduleExists('views')) {
     views_invalidate_cache();
   }
 }
Exemple #8
0
 /**
  * {@inheritdoc}
  */
 public static function preDelete(EntityStorageInterface $storage, array $entities)
 {
     // @todo This will, via Index::onDependencyRemoval(), remove all indexes
     //   from this server, triggering the server's removeIndex() method. This
     //   is, at best, wasted performance and could at worst lead to a bug if
     //   removeIndex() saves the server. We should try what happens when this is
     //   the case, whether there really is a bug, and try to fix it somehow
     //   (maybe clever detection of this case in removeIndex() or
     //   Index::postSave(). $server->isUninstalling() might help?
     parent::preDelete($storage, $entities);
     // Iterate through the servers, executing the backends' preDelete() methods
     // and removing all their pending server tasks.
     foreach ($entities as $server) {
         /** @var \Drupal\search_api\ServerInterface $server */
         if ($server->hasValidBackend()) {
             $server->getBackend()->preDelete();
         }
         \Drupal::getContainer()->get('search_api.server_task_manager')->delete(NULL, $server);
     }
 }