heartbeat8.module 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * @file
  4. * Contains heartbeat8.module.
  5. */
  6. namespace Drupal\heartbeat8;
  7. use Drupal\Core\Routing\RouteMatchInterface;
  8. use Drupal\heartbeat8\Entity\Heartbeat;
  9. use Drupal\heartbeat8\Entity\HeartbeatType;
  10. //TODO include Streams (Entities already added with use statements on lines 9-10)
  11. // Always block from display
  12. const HEARTBEAT_NONE = -1;
  13. // Display only activity messages that are mine or addressed to me
  14. const HEARTBEAT_PRIVATE = 0;
  15. // Only the person that is chosen by the actor, can see the message
  16. const HEARTBEAT_PUBLIC_TO_ADDRESSEE = 1;
  17. // Display activity message of all my user relations, described in contributed modules
  18. const HEARTBEAT_PUBLIC_TO_CONNECTED = 2;
  19. // Everyone can see this activity message, unless this type of message is set to private
  20. const HEARTBEAT_PUBLIC_TO_ALL = 4;
  21. //Group Types
  22. const HEARTBEAT_GROUP_NONE = 11;
  23. const HEARTBEAT_GROUP_SINGLE = 12;
  24. const HEARTBEAT_GROUP_SUMMARY = 13;
  25. /**
  26. * Implements hook_help().
  27. */
  28. function heartbeat8_help($route_name, RouteMatchInterface $route_match) {
  29. switch ($route_name) {
  30. // Main module help for the heartbeat8 module.
  31. case 'help.page.heartbeat8':
  32. $output = '';
  33. $output .= '<h3>' . t('About') . '</h3>';
  34. $output .= '<p>' . t('Heartbeat for Drupal 8') . '</p>';
  35. return $output;
  36. default:
  37. }
  38. }
  39. /**
  40. * Implements hook_theme().
  41. */
  42. function heartbeat8_theme() {
  43. $theme = [];
  44. $theme['heartbeat'] = array(
  45. 'render element' => 'elements',
  46. 'file' => 'heartbeat.page.inc',
  47. 'template' => 'heartbeat',
  48. );
  49. $theme['heartbeat_content_add_list'] = [
  50. 'render element' => 'content',
  51. 'variables' => ['content' => NULL],
  52. 'file' => 'heartbeat.page.inc',
  53. ];
  54. return $theme;
  55. }
  56. /**
  57. * Implements hook_theme_suggestions_HOOK().
  58. */
  59. function heartbeat8_theme_suggestions_heartbeat(array $variables) {
  60. $suggestions = array();
  61. $entity = $variables['elements']['#heartbeat'];
  62. $sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
  63. $suggestions[] = 'heartbeat__' . $sanitized_view_mode;
  64. $suggestions[] = 'heartbeat__' . $entity->bundle();
  65. $suggestions[] = 'heartbeat__' . $entity->bundle() . '__' . $sanitized_view_mode;
  66. $suggestions[] = 'heartbeat__' . $entity->id();
  67. $suggestions[] = 'heartbeat__' . $entity->id() . '__' . $sanitized_view_mode;
  68. return $suggestions;
  69. }
  70. //TODO Add heartbeat language to Javascript
  71. //TODO Determine necessity of polling
  72. //Add