Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: modules/oe_theme_demo/oe_theme_demo.routing.yml
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- modules/oe_theme_demo/oe_theme_demo.routing.yml (date 1523027549000)
- +++ modules/oe_theme_demo/oe_theme_demo.routing.yml (date 1523027549000)
- @@ -0,0 +1,7 @@
- +oe_theme_demo.example:
- + path: '/oe-theme-demo/example'
- + defaults:
- + _title: 'Example'
- + _controller: '\Drupal\oe_theme_demo\Controller\OpenEuropaThemeDemoController::build'
- + requirements:
- + _permission: 'access content'
- Index: modules/oe_theme_demo/src/Controller/OpenEuropaThemeDemoController.php
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- modules/oe_theme_demo/src/Controller/OpenEuropaThemeDemoController.php (date 1524474527000)
- +++ modules/oe_theme_demo/src/Controller/OpenEuropaThemeDemoController.php (date 1524474527000)
- @@ -0,0 +1,88 @@
- +<?php
- +
- +namespace Drupal\oe_theme_demo\Controller;
- +
- +use Drupal\Core\Controller\ControllerBase;
- +use Drupal\Core\Datetime\DateFormatterInterface;
- +use Symfony\Component\DependencyInjection\ContainerInterface;
- +
- +/**
- + * Returns responses for OpenEuropa Theme Demo routes.
- + */
- +class OpenEuropaThemeDemoController extends ControllerBase {
- +
- + /**
- + * The date formatter service.
- + *
- + * @var \Drupal\Core\Datetime\DateFormatterInterface
- + */
- + protected $dateFormatter;
- +
- + /**
- + * Constructs the controller object.
- + *
- + * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
- + * The date formatter service.
- + */
- + public function __construct(DateFormatterInterface $date_formatter) {
- + $this->dateFormatter = $date_formatter;
- + }
- +
- + /**
- + * {@inheritdoc}
- + */
- + public static function create(ContainerInterface $container) {
- + return new static(
- + $container->get('date.formatter')
- + );
- + }
- +
- + /**
- + * Builds the response.
- + */
- + public function build() {
- + // Set up a render array.
- + $header = [
- + [
- + 'data' => 'Name',
- + 'field' => 'name',
- + 'sort' => 'asc',
- + ],
- + [
- + 'data' => 'Registration date',
- + 'field' => 'date',
- + ],
- + [
- + 'data' => 'Email',
- + 'field' => 'email',
- + ],
- + ];
- + $data = [
- + [
- + 'name' => 'John Doe',
- + 'date' => '01/01/2016',
- + 'email' => 'john.doe@mail.com',
- + ],
- + [
- + 'name' => 'Jane Doe',
- + 'date' => '06/12/2016',
- + 'email' => 'jane.doe@mail.com',
- + ],
- + [
- + 'name' => 'Jack Doe',
- + 'date' => '03/05/2017',
- + 'email' => 'jack.doe@mail.com',
- + ],
- + ];
- +
- + $build[] = [
- + '#theme' => 'table',
- + '#caption' => 'Default table',
- + '#header' => $header,
- + '#rows' => $data,
- + ];
- +
- + return $build;
- + }
- +
- +}
Add Comment
Please, Sign In to add comment