TestController.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace Drupal\heartbeat8\Controller;
  3. use Drupal\Core\Controller\ControllerBase;
  4. use Symfony\Component\DependencyInjection\ContainerInterface;
  5. use Drupal\heartbeat8\HeartbeatTypeServices;
  6. use Drupal\heartbeat8\HeartbeatStreamServices;
  7. /**
  8. * Class TestController.
  9. *
  10. * @package Drupal\heartbeat8\Controller
  11. */
  12. class TestController extends ControllerBase {
  13. /**
  14. * Drupal\heartbeat8\HeartbeatTypeServices definition.
  15. *
  16. * @var Drupal\heartbeat8\HeartbeatTypeServices
  17. */
  18. protected $heartbeat8_heartbeattype;
  19. /**
  20. * Drupal\heartbeat8\HeartbeatStreamServices definition.
  21. *
  22. * @var Drupal\heartbeat8\HeartbeatStreamServices
  23. */
  24. protected $heartbeatstream;
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function __construct(HeartbeatTypeServices $heartbeat8_heartbeattype, HeartbeatStreamServices $heartbeatstream) {
  29. $this->heartbeat8_heartbeattype = $heartbeat8_heartbeattype;
  30. $this->heartbeatstream = $heartbeatstream;
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public static function create(ContainerInterface $container) {
  36. return new static(
  37. $container->get('heartbeat8.heartbeattype'),
  38. $container->get('heartbeatstream')
  39. );
  40. }
  41. /**
  42. * Start.
  43. *
  44. * @return string
  45. * Return Hello string.
  46. */
  47. public function start($arg) {
  48. $streamEntity = $this->heartbeatstream->getEntityById(1);
  49. $types = $streamEntity->get('types');
  50. $i = 1;
  51. foreach($types->getValue() as $heartbeatType) {
  52. $arg .= ' ' . $i . '. ' . $heartbeatType['target_id'];
  53. $i++;
  54. }
  55. $emptyVariable = 'not empty';
  56. return [
  57. '#type' => 'markup',
  58. '#markup' => $this->t('Implement method: start with parameter(s): ' . $arg),
  59. ];
  60. }
  61. }