<?php

// use Drupal\Core\Url;

function template_preprocess_edlp_agenda(&$vars){
  // dpm($vars);
/*
  @see https://www.drupal8.ovh/index.php/en/tutoriels/339/render-a-node-or-an-entity
  */
  $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');

  $vars['next_event'] = array(
    "#markup"=>"<h3>Prochaine Date</h3>",
    "event"=>$view_builder->view($vars['next_event_node'], 'default')
  );

  $future_list = array (
    '#theme' => 'item_list',
    '#items' => [],
  );
  foreach($vars['coming_events_nodes'] as $node){
    $future_list['#items'][] = $view_builder->view($node, 'teaser');
  }

  $vars['coming_events'] = array(
    "#type"=>"container",
    "#attributes"=>array(
      "class"=>['future-events']
    ),
    "#markup"=>"<h3>Dates à venir</h3>",
    "future_events"=>$future_list
  );


  $past_list = array (
    '#theme' => 'item_list',
    '#items' => [],
  );
  foreach($vars['past_events_nodes'] as $node){
    $past_list['#items'][] = $view_builder->view($node, 'teaser');
  }

  $vars['past_events'] = array(
    "#type"=>"container",
    "#attributes"=>array(
      "class"=>['past-events']
    ),
    "#markup"=>"<h3>Dates passées</h3>",
    "past_events"=>$past_list
  );

  // return array(
  //   "#type" => "container",
  //   "#attributes"=>array(
  //     "id"=>['agenda']
  //   ),
  //   "future_past"=>array(
  //     "#type"=>"container",
  //     "#attributes"=>array(
  //       "class"=>['future-past-events', 'column', 'os-scroll']
  //     ),
  //     "future"=>,
  //     "past"=>
  //   )
  // );

}
