本文整理汇总了PHP中Drupal\Core\Config\Entity\ConfigEntityBase::preDelete方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigEntityBase::preDelete方法的具体用法?PHP ConfigEntityBase::preDelete怎么用?PHP ConfigEntityBase::preDelete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Config\Entity\ConfigEntityBase
的用法示例。
在下文中一共展示了ConfigEntityBase::preDelete方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preDelete
/**
* {@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);
}
}
示例2: preDelete
/**
* {@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);
}
示例3: preDelete
/**
* {@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);
}
示例4: preDelete
/**
* {@inheritdoc}
*/
public static function preDelete(EntityStorageInterface $storage, array $entities)
{
parent::preDelete($storage, $entities);
\Drupal::entityManager()->clearCachedFieldDefinitions();
}
示例5: preDelete
/**
* {@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);
}
}
}
示例6: preDelete
/**
* {@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();
}
}
}
示例7: preDelete
/**
* {@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();
}
}
示例8: preDelete
/**
* {@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);
}
}