Guest User

Untitled

a guest
Apr 30th, 2018
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. Index: modules/oe_theme_demo/oe_theme_demo.routing.yml
  2. IDEA additional info:
  3. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  4. <+>UTF-8
  5. ===================================================================
  6. --- modules/oe_theme_demo/oe_theme_demo.routing.yml (date 1523027549000)
  7. +++ modules/oe_theme_demo/oe_theme_demo.routing.yml (date 1523027549000)
  8. @@ -0,0 +1,7 @@
  9. +oe_theme_demo.example:
  10. + path: '/oe-theme-demo/example'
  11. + defaults:
  12. + _title: 'Example'
  13. + _controller: '\Drupal\oe_theme_demo\Controller\OpenEuropaThemeDemoController::build'
  14. + requirements:
  15. + _permission: 'access content'
  16. Index: modules/oe_theme_demo/src/Controller/OpenEuropaThemeDemoController.php
  17. IDEA additional info:
  18. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  19. <+>UTF-8
  20. ===================================================================
  21. --- modules/oe_theme_demo/src/Controller/OpenEuropaThemeDemoController.php (date 1524474527000)
  22. +++ modules/oe_theme_demo/src/Controller/OpenEuropaThemeDemoController.php (date 1524474527000)
  23. @@ -0,0 +1,88 @@
  24. +<?php
  25. +
  26. +namespace Drupal\oe_theme_demo\Controller;
  27. +
  28. +use Drupal\Core\Controller\ControllerBase;
  29. +use Drupal\Core\Datetime\DateFormatterInterface;
  30. +use Symfony\Component\DependencyInjection\ContainerInterface;
  31. +
  32. +/**
  33. + * Returns responses for OpenEuropa Theme Demo routes.
  34. + */
  35. +class OpenEuropaThemeDemoController extends ControllerBase {
  36. +
  37. + /**
  38. + * The date formatter service.
  39. + *
  40. + * @var \Drupal\Core\Datetime\DateFormatterInterface
  41. + */
  42. + protected $dateFormatter;
  43. +
  44. + /**
  45. + * Constructs the controller object.
  46. + *
  47. + * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
  48. + * The date formatter service.
  49. + */
  50. + public function __construct(DateFormatterInterface $date_formatter) {
  51. + $this->dateFormatter = $date_formatter;
  52. + }
  53. +
  54. + /**
  55. + * {@inheritdoc}
  56. + */
  57. + public static function create(ContainerInterface $container) {
  58. + return new static(
  59. + $container->get('date.formatter')
  60. + );
  61. + }
  62. +
  63. + /**
  64. + * Builds the response.
  65. + */
  66. + public function build() {
  67. + // Set up a render array.
  68. + $header = [
  69. + [
  70. + 'data' => 'Name',
  71. + 'field' => 'name',
  72. + 'sort' => 'asc',
  73. + ],
  74. + [
  75. + 'data' => 'Registration date',
  76. + 'field' => 'date',
  77. + ],
  78. + [
  79. + 'data' => 'Email',
  80. + 'field' => 'email',
  81. + ],
  82. + ];
  83. + $data = [
  84. + [
  85. + 'name' => 'John Doe',
  86. + 'date' => '01/01/2016',
  87. + 'email' => 'john.doe@mail.com',
  88. + ],
  89. + [
  90. + 'name' => 'Jane Doe',
  91. + 'date' => '06/12/2016',
  92. + 'email' => 'jane.doe@mail.com',
  93. + ],
  94. + [
  95. + 'name' => 'Jack Doe',
  96. + 'date' => '03/05/2017',
  97. + 'email' => 'jack.doe@mail.com',
  98. + ],
  99. + ];
  100. +
  101. + $build[] = [
  102. + '#theme' => 'table',
  103. + '#caption' => 'Default table',
  104. + '#header' => $header,
  105. + '#rows' => $data,
  106. + ];
  107. +
  108. + return $build;
  109. + }
  110. +
  111. +}
Add Comment
Please, Sign In to add comment