You are here

public static function ConfigPagesType::postDelete in Config Pages 8.2

Same name and namespace in other branches
  1. 8.3 src/Entity/ConfigPagesType.php \Drupal\config_pages\Entity\ConfigPagesType::postDelete()
  2. 8 src/Entity/ConfigPagesType.php \Drupal\config_pages\Entity\ConfigPagesType::postDelete()

Provides the list of config_pages types.

Parameters

\Drupal\Core\Entity\EntityStorageInterface $storage: Storage interface.

array $entities: Array of entities.

Overrides ConfigEntityBundleBase::postDelete

File

src/Entity/ConfigPagesType.php, line 80

Class

ConfigPagesType
Defines the config page type entity.

Namespace

Drupal\config_pages\Entity

Code

public static function postDelete(EntityStorageInterface $storage, array $entities) {
  $query = \Drupal::entityQuery('config_pages');
  $type = array_shift($entities);
  $config_page_ids = $query
    ->condition('type', $type
    ->id())
    ->execute();
  $cp_storage = \Drupal::service('entity_type.manager')
    ->getStorage('config_pages');
  if ($cp_storage && $config_page_ids) {

    // ConfigPage could possibly never submitted,
    // so no entities exists for this CP type.
    // Delete them only if we have some ID's for that.
    $cp_entities = $cp_storage
      ->loadMultiple($config_page_ids);
    $cp_storage
      ->delete($cp_entities);
  }
}