function local_fonts_entity_delete in @font-your-face 8.3
Implements hook_entity_delete().
File
- modules/
local_fonts/ local_fonts.module, line 77 - Local Fonts module file.
Code
function local_fonts_entity_delete(EntityInterface $entity) {
if ($entity instanceof LocalFontConfigEntity) {
$font_id = 'local_fonts://' . $entity
->id();
$fids = \Drupal::entityQuery('font')
->condition('url', $font_id)
->range(0, 50)
->execute();
if (!empty($fids)) {
$storage_handler = \Drupal::entityTypeManager()
->getStorage('font');
$fonts = $storage_handler
->loadMultiple(array_keys($fids));
$storage_handler
->delete($fonts);
}
}
}