3 namespace Drupal\{{ machine_name }}\Controller;
5 use Drupal\Core\Controller\ControllerBase;
6 use Drupal\Core\Datetime\DateFormatterInterface;
7 use Symfony\Component\DependencyInjection\ContainerInterface;
10 * Returns responses for {{ name }} routes.
12 class {{ class }} extends ControllerBase {
15 * The date formatter service.
17 * @var \Drupal\Core\Datetime\DateFormatterInterface
19 protected $dateFormatter;
22 * Constructs the controller object.
24 * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
25 * The date formatter service.
27 public function __construct(DateFormatterInterface $date_formatter) {
28 $this->dateFormatter = $date_formatter;
34 public static function create(ContainerInterface $container) {
36 $container->get('date.formatter')
41 * Builds the response.
43 public function build() {
47 '#title' => $this->t('Content'),
48 '#markup' => $this->t('Hello world!'),
53 '#title' => $this->t('Date'),
54 '#markup' => $this->dateFormatter->format(REQUEST_TIME),