本文整理汇总了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);
}