<?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() {
    // return "Hello";
    // $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');

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

    // // presentation
    // $query = \Drupal::entityQuery('node')
    //   // ->condition('status', 1)
    //   ->condition('nid', 1);
    // $nids = $query->execute();

    $nid = 1;
    // TODO: home nid should be a setting
    $node_storage = \Drupal::entityTypeManager()->getStorage('node');
    $node = $node_storage->load($nid);

    $contents["#frontpage_node"] = $node;
    $contents["#view_mode"] = "home_light";
    return $contents;
  }


}
