You are here

function acquia_contenthub_theme_suggestions_block_alter in Acquia Content Hub 8

Implements hook_theme_suggestions_HOOK_alter().

Provides block_content templates:

  • block__block_content__acquia_contenthub
  • block__block_content__BLOCK_UUID__acquia_contenthub.

See also

block_theme_suggestions_block()

File

./acquia_contenthub.module, line 245
Contains acquia_contenthub.module.

Code

function acquia_contenthub_theme_suggestions_block_alter(array &$suggestions, array $variables) {
  if ($variables['elements']['#configuration']['provider'] === 'block_content' && \Drupal::routeMatch()
    ->getRouteName() === 'acquia_contenthub.content_entity_display.entity') {

    // We can safely explode on : because we know the Block plugin type manager
    // enforces that delimiter for all derivatives.
    // Example value: block_content:12345678-9abc-0123-4567-000000000000.
    $parts = explode(':', $variables['elements']['#plugin_id']);
    $suggestion = 'block';
    foreach ($parts as $part) {
      $suggestion .= '__' . strtr($part, '-', '_');
      $suggestions[] = $suggestion . '__acquia_contenthub';
    }
  }
}