HomeController.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace Drupal\materio_home\Controller;
  3. use Drupal\Core\Controller\ControllerBase;
  4. // use Drupal\Core\Datetime\DrupalDateTime;
  5. // use Drupal\taxonomy\Entity\Term;
  6. // use Drupal\workflow\Entity\WorkflowManager;
  7. // use Drupal\Core\Url;
  8. // use Drupal\Core\Language\LanguageInterface;
  9. // use Symfony\Component\HttpFoundation\JsonResponse;
  10. // use Drupal\Core\Cache\CacheableJsonResponse;
  11. // use Drupal\Core\Cache\CacheableMetadata;
  12. // use Drupal\core\render\RenderContext;
  13. class HomeController extends ControllerBase {
  14. /**
  15. * Display home as a page.
  16. *
  17. * @return renderable array
  18. */
  19. public function home() {
  20. // return "Hello";
  21. // $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
  22. $contents = array("#theme"=>'materio_home');
  23. // // presentation
  24. // $query = \Drupal::entityQuery('node')
  25. // // ->condition('status', 1)
  26. // ->condition('nid', 1);
  27. // $nids = $query->execute();
  28. $nid = 1;
  29. // TODO: home nid should be a setting
  30. $node_storage = \Drupal::entityTypeManager()->getStorage('node');
  31. $node = $node_storage->load($nid);
  32. $contents["#frontpage_node"] = $node;
  33. $contents["#view_mode"] = "home_light";
  34. return $contents;
  35. }
  36. }