<?php

// use Drupal\Core\Url;

function template_preprocess_edlp_productions(&$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');

  foreach($vars['nodes_entities'] as $node){
    switch($node->get('field_view_mode')->value){
      case "1":
        $vm = "image_2_columns";
        break;
      case "2":
        $vm = "image_1_columns";
        break;
      case "3":
        $vm = "text_1_column";
        break;
    };
    $vars['nodes'][] = array(
      'vm'=>$vm,
      'build'=>$view_builder->view($node, $vm)
    );
  }


}
