function weather_weather_display_delete in Weather 8
Same name and namespace in other branches
- 2.0.x weather.module \weather_weather_display_delete()
Removes related entities on Weather Display delete.
Implements hook_ENTITY_TYPE_delete().
File
- ./
weather.module, line 89 - Main module file with hooks implementations.
Code
function weather_weather_display_delete(WeatherDisplayInterface $entity) {
// Remove related Display Places.
$displayPlaces = Drupal::entityTypeManager()
->getStorage('weather_display_place')
->loadByProperties([
'display_type' => $entity->type->value,
'display_number' => $entity->number->value,
]);
foreach ($displayPlaces as $displayPlace) {
$displayPlace
->delete();
}
// Remove related block instances.
$blocks = Drupal::entityTypeManager()
->getStorage('block')
->loadByProperties([
'plugin' => 'weather_system_display_block:' . $entity
->id(),
]);
foreach ($blocks as $block) {
$block
->delete();
}
}