HomeController.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. // $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
  21. $contents = array("#theme"=>'materio_home');
  22. // presentation
  23. $query = \Drupal::entityQuery('node')
  24. ->condition('status', 1)
  25. ->condition('nid', 19990);
  26. // TODO: présentation nid should be a setting
  27. $pres_nid = $query->execute();
  28. $contents["#frontpage_node"] = entity_load('node', array_pop($pres_nid));
  29. return $contents;
  30. }
  31. }