本文整理匯總了PHP中Drupal\Core\Entity\ContentEntityBase::preDelete方法的典型用法代碼示例。如果您正苦於以下問題:PHP ContentEntityBase::preDelete方法的具體用法?PHP ContentEntityBase::preDelete怎麽用?PHP ContentEntityBase::preDelete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Drupal\Core\Entity\ContentEntityBase
的用法示例。
在下文中一共展示了ContentEntityBase::preDelete方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: preDelete
/**
* {@inheritdoc}
*/
public static function preDelete(EntityStorageInterface $storage, array $entities)
{
parent::preDelete($storage, $entities);
/** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
$menu_link_manager = \Drupal::service('plugin.manager.menu.link');
foreach ($entities as $menu_link) {
/** @var \Drupal\menu_link_content\Entity\MenuLinkContent $menu_link */
$menu_link_manager->removeDefinition($menu_link->getPluginId(), FALSE);
}
}
示例2: preDelete
/**
* {@inheritdoc}
*/
public static function preDelete(EntityStorageInterface $storage, array $entities)
{
parent::preDelete($storage, $entities);
// Ensure that all nodes deleted are removed from the search index.
if (\Drupal::moduleHandler()->moduleExists('search')) {
foreach ($entities as $entity) {
search_index_clear('node_search', $entity->nid->value);
}
}
}
示例3: preDelete
/**
* {@inheritdoc}
*/
public static function preDelete(EntityStorageInterface $storage, array $entities)
{
parent::preDelete($storage, $entities);
foreach ($entities as $entity) {
// Delete all remaining references to this file.
$file_usage = \Drupal::service('file.usage')->listUsage($entity);
if (!empty($file_usage)) {
foreach ($file_usage as $module => $usage) {
\Drupal::service('file.usage')->delete($entity, $module);
}
}
// Delete the actual file. Failures due to invalid files and files that
// were already deleted are logged to watchdog but ignored, the
// corresponding file entity will be deleted.
file_unmanaged_delete($entity->getFileUri());
}
}
示例4: preDelete
/**
* {@inheritdoc}
*/
public static function preDelete(EntityStorageInterface $storage, array $entities)
{
$registrant_storage = \Drupal::entityManager()->getStorage('registrant');
/** @var \Drupal\rng\RegistrationInterface $registration */
foreach ($entities as $registration) {
// Delete associated registrants.
$ids = $registrant_storage->getQuery()->condition('registration', $registration->id(), '=')->execute();
$registrants = $registrant_storage->loadMultiple($ids);
$registrant_storage->delete($registrants);
}
parent::preDelete($storage, $entities);
}
示例5: preDelete
/**
* {@inheritdoc}
*/
public static function preDelete(EntityStorageInterface $storage, array $entities)
{
// We need to check whether the state of the job is affected by this
// deletion.
foreach ($entities as $entity) {
if ($job = $entity->getJob()) {
// We only care for active jobs.
if ($job->isActive() && tmgmt_job_check_finished($job->id())) {
// Mark the job as finished.
$job->finished();
}
}
}
parent::preDelete($storage, $entities);
}
示例6: preDelete
/**
* {@inheritdoc}
*/
public static function preDelete(EntityStorageInterface $storage, array $entities)
{
$component_storage = \Drupal::entityManager()->getStorage('rng_rule_component');
/** @var \Drupal\rng\RuleInterface $rule */
foreach ($entities as $rule) {
// Delete associated rule components.
$ids = $component_storage->getQuery()->condition('rule', $rule->id())->execute();
$components = $component_storage->loadMultiple($ids);
$component_storage->delete($components);
}
parent::preDelete($storage, $entities);
}