<?php

namespace Drupal\materio_home\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\taxonomy\Entity\Term;
use Drupal\workflow\Entity\WorkflowManager;
use Drupal\Core\Url;
use Drupal\Core\Language\LanguageInterface;
// use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\Core\Cache\CacheableJsonResponse;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\core\render\RenderContext;



class HomeController extends ControllerBase {

  /**
   * Display home as a page.
   *
   * @return renderable array
   */
  public function home() {

    // $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');

    $contents = array("#theme"=>'materio_home');

    // presentation
    $query = \Drupal::entityQuery('node')
      ->condition('status', 1)
      ->condition('nid', 19990);
    // TODO: présentation nid should be a setting

    $pres_nid = $query->execute();
    $contents["#frontpage_node"] = entity_load('node', array_pop($pres_nid));

    return $contents;
  }


}
