heartbeat8.module 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * @file
  4. * Contains heartbeat8.module.
  5. */
  6. use Drupal\Core\Routing\RouteMatchInterface;
  7. /**
  8. * Implements hook_help().
  9. */
  10. function heartbeat8_help($route_name, RouteMatchInterface $route_match) {
  11. switch ($route_name) {
  12. // Main module help for the heartbeat8 module.
  13. case 'help.page.heartbeat8':
  14. $output = '';
  15. $output .= '<h3>' . t('About') . '</h3>';
  16. $output .= '<p>' . t('Heartbeat for Drupal 8') . '</p>';
  17. return $output;
  18. default:
  19. }
  20. }
  21. /**
  22. * Implements hook_theme().
  23. */
  24. function heartbeat8_theme() {
  25. $theme = [];
  26. $theme['heartbeat'] = array(
  27. 'render element' => 'elements',
  28. 'file' => 'heartbeat.page.inc',
  29. 'template' => 'heartbeat',
  30. );
  31. $theme['heartbeat_content_add_list'] = [
  32. 'render element' => 'content',
  33. 'variables' => ['content' => NULL],
  34. 'file' => 'heartbeat.page.inc',
  35. ];
  36. return $theme;
  37. }
  38. /**
  39. * Implements hook_theme_suggestions_HOOK().
  40. */
  41. function heartbeat8_theme_suggestions_heartbeat(array $variables) {
  42. $suggestions = array();
  43. $entity = $variables['elements']['#heartbeat'];
  44. $sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
  45. $suggestions[] = 'heartbeat__' . $sanitized_view_mode;
  46. $suggestions[] = 'heartbeat__' . $entity->bundle();
  47. $suggestions[] = 'heartbeat__' . $entity->bundle() . '__' . $sanitized_view_mode;
  48. $suggestions[] = 'heartbeat__' . $entity->id();
  49. $suggestions[] = 'heartbeat__' . $entity->id() . '__' . $sanitized_view_mode;
  50. return $suggestions;
  51. }