diff --git a/apps/silverback-drupal/config/sync/entity_usage.settings.yml b/apps/silverback-drupal/config/sync/entity_usage.settings.yml index 8379d36d1..c0b05500a 100644 --- a/apps/silverback-drupal/config/sync/entity_usage.settings.yml +++ b/apps/silverback-drupal/config/sync/entity_usage.settings.yml @@ -3,6 +3,7 @@ _core: local_task_enabled_entity_types: - media - node + - taxonomy_term track_enabled_source_entity_types: - node - block_content diff --git a/packages/composer/amazeelabs/silverback_gatsby/silverback_gatsby.module b/packages/composer/amazeelabs/silverback_gatsby/silverback_gatsby.module index 48e6e6bc5..3b3edf16f 100644 --- a/packages/composer/amazeelabs/silverback_gatsby/silverback_gatsby.module +++ b/packages/composer/amazeelabs/silverback_gatsby/silverback_gatsby.module @@ -6,7 +6,22 @@ use Drupal\user\UserInterface; function _silverback_gatsby_entity_event(EntityInterface $entity) { - \Drupal::service('silverback_gatsby.update_handler')->handle(EntityFeed::class, $entity); + /** @var \Drupal\silverback_gatsby\GatsbyUpdateHandler $updateHandler */ + $updateHandler = \Drupal::service('silverback_gatsby.update_handler'); + $updateHandler->handle(EntityFeed::class, $entity); + + if (\Drupal::hasService('entity_usage.usage')) { + /** @var \Drupal\entity_usage\EntityUsage $entityUsage */ + $entityUsage = \Drupal::service('entity_usage.usage'); + foreach ($entityUsage->listSources($entity) as $sourceEntityType => $sources) { + $entities = \Drupal::entityTypeManager() + ->getStorage($sourceEntityType) + ->loadMultiple(array_keys($sources)); + foreach ($entities as $source) { + $updateHandler->handle(EntityFeed::class, $source); + } + } + } } /** @@ -42,6 +57,18 @@ function silverback_gatsby_entity_predelete(EntityInterface $entity) { _silverback_gatsby_entity_event($entity); } +/** + * Implements hook_module_implements_alter(). + */ +function silverback_gatsby_module_implements_alter(&$implementations, $hook) { + // Act before entity_usage module. + if (in_array($hook, ['entity_insert', 'entity_update', 'entity_predelete'], TRUE)) { + $implementations = [ + 'silverback_gatsby' => $implementations['silverback_gatsby'], + ] + $implementations; + } +} + /** * Implements hook_entity_type_alter(). */