|
@@ -4,6 +4,7 @@ namespace Drupal\edlp_home\Controller;
|
|
|
|
|
|
use Drupal\Core\Controller\ControllerBase;
|
|
use Drupal\Core\Controller\ControllerBase;
|
|
use Drupal\Core\Datetime\DrupalDateTime;
|
|
use Drupal\Core\Datetime\DrupalDateTime;
|
|
|
|
+use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
|
|
use Drupal\taxonomy\Entity\Term;
|
|
use Drupal\taxonomy\Entity\Term;
|
|
use Drupal\workflow\Entity\WorkflowManager;
|
|
use Drupal\workflow\Entity\WorkflowManager;
|
|
use Drupal\Core\Url;
|
|
use Drupal\Core\Url;
|
|
@@ -30,45 +31,50 @@ class HomeController extends ControllerBase {
|
|
|
|
|
|
// first get static pages
|
|
// first get static pages
|
|
$query = \Drupal::entityQuery('node')
|
|
$query = \Drupal::entityQuery('node')
|
|
|
|
+ ->accessCheck(TRUE)
|
|
->condition('status', 1)
|
|
->condition('status', 1)
|
|
->condition('field_afficher_en_page_d_acceuil', 1)
|
|
->condition('field_afficher_en_page_d_acceuil', 1)
|
|
->condition('type', 'static');
|
|
->condition('type', 'static');
|
|
|
|
|
|
$promoted_nids = $query->execute();
|
|
$promoted_nids = $query->execute();
|
|
- $contents["#promoted_statics"] = entity_load_multiple('node', $promoted_nids);
|
|
|
|
|
|
+ $contents["#promoted_statics"] = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($promoted_nids);
|
|
|
|
|
|
// then get production pages
|
|
// then get production pages
|
|
$query = \Drupal::entityQuery('node')
|
|
$query = \Drupal::entityQuery('node')
|
|
|
|
+ ->accessCheck(TRUE)
|
|
->condition('status', 1)
|
|
->condition('status', 1)
|
|
->condition('field_afficher_en_page_d_acceuil', 1)
|
|
->condition('field_afficher_en_page_d_acceuil', 1)
|
|
->condition('type', 'page');
|
|
->condition('type', 'page');
|
|
|
|
|
|
$promoted_nids = $query->execute();
|
|
$promoted_nids = $query->execute();
|
|
- $contents["#promoted_prods"] = entity_load_multiple('node', $promoted_nids);
|
|
|
|
|
|
+ $contents["#promoted_prods"] = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($promoted_nids);
|
|
|
|
|
|
// presentation
|
|
// presentation
|
|
// $query = \Drupal::entityQuery('node')
|
|
// $query = \Drupal::entityQuery('node')
|
|
|
|
+ // ->accessCheck(TRUE)
|
|
// ->condition('status', 1)
|
|
// ->condition('status', 1)
|
|
// ->condition('nid', 12242);
|
|
// ->condition('nid', 12242);
|
|
// // TODO: présentation nid should be a setting
|
|
// // TODO: présentation nid should be a setting
|
|
//
|
|
//
|
|
// $pres_nid = $query->execute();
|
|
// $pres_nid = $query->execute();
|
|
- // $contents["#presentation_node"] = entity_load('node', array_pop($pres_nid));
|
|
|
|
|
|
+ // $contents["#presentation_node"] = \Drupal::entityTypeManager()->getStorage('node')->load(array_pop($pres_nid));
|
|
|
|
|
|
// last fil
|
|
// last fil
|
|
// $query = \Drupal::entityQuery('node')
|
|
// $query = \Drupal::entityQuery('node')
|
|
|
|
+ // ->accessCheck(TRUE)
|
|
// ->condition('status', 1)
|
|
// ->condition('status', 1)
|
|
// ->condition('type', 'fil')
|
|
// ->condition('type', 'fil')
|
|
// ->sort('created', 'DESC')
|
|
// ->sort('created', 'DESC')
|
|
// ->range(0,1);
|
|
// ->range(0,1);
|
|
//
|
|
//
|
|
// $fil = $query->execute();
|
|
// $fil = $query->execute();
|
|
- // $contents["#last_fil_node"] = entity_load('node', array_pop($fil));
|
|
|
|
|
|
+ // $contents["#last_fil_node"] = \Drupal::entityTypeManager()->getStorage('node')->load(array_pop($fil));
|
|
// $contents["#last_fil_node"] = array('#markup'=>'En développement.');
|
|
// $contents["#last_fil_node"] = array('#markup'=>'En développement.');
|
|
|
|
|
|
|
|
|
|
// last production
|
|
// last production
|
|
// $query = \Drupal::entityQuery('node')
|
|
// $query = \Drupal::entityQuery('node')
|
|
|
|
+ // ->accessCheck(TRUE)
|
|
// ->condition('status', 1)
|
|
// ->condition('status', 1)
|
|
// ->condition('type', 'page')
|
|
// ->condition('type', 'page')
|
|
// ->condition('field_page_type', array('1168'), 'NOT IN')
|
|
// ->condition('field_page_type', array('1168'), 'NOT IN')
|
|
@@ -76,17 +82,18 @@ class HomeController extends ControllerBase {
|
|
// ->range(0,1);
|
|
// ->range(0,1);
|
|
//
|
|
//
|
|
// $prod = $query->execute();
|
|
// $prod = $query->execute();
|
|
- // $contents["#last_production_node"] = entity_load('node', array_pop($prod));
|
|
|
|
|
|
+ // $contents["#last_production_node"] = \Drupal::entityTypeManager()->getStorage('node')->load(array_pop($prod));
|
|
|
|
|
|
// last documents
|
|
// last documents
|
|
$query = \Drupal::entityQuery('node')
|
|
$query = \Drupal::entityQuery('node')
|
|
|
|
+ ->accessCheck(TRUE)
|
|
->condition('status', 1)
|
|
->condition('status', 1)
|
|
->condition('type', 'enregistrement')
|
|
->condition('type', 'enregistrement')
|
|
->sort('created', 'DESC')
|
|
->sort('created', 'DESC')
|
|
->range(0,50);
|
|
->range(0,50);
|
|
|
|
|
|
$nids = $query->execute();
|
|
$nids = $query->execute();
|
|
- $nodes = entity_load_multiple('node', $nids);
|
|
|
|
|
|
+ $nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($nids);
|
|
|
|
|
|
$lastdocs = [];
|
|
$lastdocs = [];
|
|
$i = 0;
|
|
$i = 0;
|
|
@@ -98,23 +105,24 @@ class HomeController extends ControllerBase {
|
|
$i++;
|
|
$i++;
|
|
if($i>9) break;
|
|
if($i>9) break;
|
|
}
|
|
}
|
|
- // $contents["#lastdocs_items"] = entity_load_multiple('node', $lastdocs);
|
|
|
|
|
|
+ // $contents["#lastdocs_items"] = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($lastdocs);
|
|
$contents["#lastdocs_items"] = $lastdocs;
|
|
$contents["#lastdocs_items"] = $lastdocs;
|
|
// dsm($contents["#lastdocs_items"], "#lastdocs_items");
|
|
// dsm($contents["#lastdocs_items"], "#lastdocs_items");
|
|
|
|
|
|
// agenda
|
|
// agenda
|
|
$now = new DrupalDateTime('now');
|
|
$now = new DrupalDateTime('now');
|
|
- $now->setTimezone(new \DateTimeZone(DATETIME_STORAGE_TIMEZONE));
|
|
|
|
|
|
+ $now->setTimezone(new \DateTimeZone(DateTimeItemInterface::STORAGE_TIMEZONE));
|
|
|
|
|
|
$query = \Drupal::entityQuery('node')
|
|
$query = \Drupal::entityQuery('node')
|
|
|
|
+ ->accessCheck(TRUE)
|
|
->condition('status', 1)
|
|
->condition('status', 1)
|
|
->condition('type', 'evenement')
|
|
->condition('type', 'evenement')
|
|
- ->condition('field_date', $now->format(DATETIME_DATETIME_STORAGE_FORMAT), '>=')
|
|
|
|
|
|
+ ->condition('field_date', $now->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT), '>=')
|
|
->range(0,5)
|
|
->range(0,5)
|
|
->sort('field_date');
|
|
->sort('field_date');
|
|
|
|
|
|
$events = $query->execute();
|
|
$events = $query->execute();
|
|
- $contents['#agenda_items'] = entity_load_multiple('node', $events);
|
|
|
|
|
|
+ $contents['#agenda_items'] = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($events);
|
|
|
|
|
|
return $contents;
|
|
return $contents;
|
|
}
|
|
}
|
|
@@ -132,46 +140,50 @@ class HomeController extends ControllerBase {
|
|
|
|
|
|
// first get static pages
|
|
// first get static pages
|
|
$query = \Drupal::entityQuery('node')
|
|
$query = \Drupal::entityQuery('node')
|
|
|
|
+ ->accessCheck(TRUE)
|
|
->condition('status', 1)
|
|
->condition('status', 1)
|
|
->condition('field_afficher_en_page_d_acceuil', 1)
|
|
->condition('field_afficher_en_page_d_acceuil', 1)
|
|
->condition('type', 'static');
|
|
->condition('type', 'static');
|
|
|
|
|
|
$promoted_nids = $query->execute();
|
|
$promoted_nids = $query->execute();
|
|
- $renderable["#promoted_statics"] = entity_load_multiple('node', $promoted_nids);
|
|
|
|
|
|
+ $renderable["#promoted_statics"] = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($promoted_nids);
|
|
|
|
|
|
// then get production pages
|
|
// then get production pages
|
|
$query = \Drupal::entityQuery('node')
|
|
$query = \Drupal::entityQuery('node')
|
|
|
|
+ ->accessCheck(TRUE)
|
|
->condition('status', 1)
|
|
->condition('status', 1)
|
|
->condition('field_afficher_en_page_d_acceuil', 1)
|
|
->condition('field_afficher_en_page_d_acceuil', 1)
|
|
->condition('type', 'page');
|
|
->condition('type', 'page');
|
|
|
|
|
|
$promoted_nids = $query->execute();
|
|
$promoted_nids = $query->execute();
|
|
- $renderable["#promoted_prods"] = entity_load_multiple('node', $promoted_nids);
|
|
|
|
|
|
+ $renderable["#promoted_prods"] = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($promoted_nids);
|
|
|
|
|
|
// last fil
|
|
// last fil
|
|
// $query = \Drupal::entityQuery('node')
|
|
// $query = \Drupal::entityQuery('node')
|
|
|
|
+ // ->accessCheck(TRUE)
|
|
// ->condition('status', 1)
|
|
// ->condition('status', 1)
|
|
// ->condition('type', 'fil')
|
|
// ->condition('type', 'fil')
|
|
// ->sort('created', 'DESC')
|
|
// ->sort('created', 'DESC')
|
|
// ->range(0,1);
|
|
// ->range(0,1);
|
|
//
|
|
//
|
|
// $fil = $query->execute();
|
|
// $fil = $query->execute();
|
|
- // $renderable["#last_fil_node"] = entity_load('node', array_pop($fil));
|
|
|
|
|
|
+ // $renderable["#last_fil_node"] = \Drupal::entityTypeManager()->getStorage('node')->load(array_pop($fil));
|
|
// $renderable["#last_fil_node"] = array('#markup'=>'En développement.');
|
|
// $renderable["#last_fil_node"] = array('#markup'=>'En développement.');
|
|
|
|
|
|
// agenda
|
|
// agenda
|
|
/*
|
|
/*
|
|
$now = new DrupalDateTime('now');
|
|
$now = new DrupalDateTime('now');
|
|
- $now->setTimezone(new \DateTimeZone(DATETIME_STORAGE_TIMEZONE));
|
|
|
|
|
|
+ $now->setTimezone(new \DateTimeZone(DateTimeItemInterface::STORAGE_TIMEZONE));
|
|
$query = \Drupal::entityQuery('node')
|
|
$query = \Drupal::entityQuery('node')
|
|
|
|
+ ->accessCheck(TRUE)
|
|
->condition('status', 1)
|
|
->condition('status', 1)
|
|
->condition('type', 'evenement')
|
|
->condition('type', 'evenement')
|
|
- ->condition('field_date', $now->format(DATETIME_DATETIME_STORAGE_FORMAT), '>=')
|
|
|
|
|
|
+ ->condition('field_date', $now->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT), '>=')
|
|
->range(0,5)
|
|
->range(0,5)
|
|
->sort('field_date');
|
|
->sort('field_date');
|
|
|
|
|
|
$events = $query->execute();
|
|
$events = $query->execute();
|
|
- $renderable['#agenda_items'] = entity_load_multiple('node', $events);
|
|
|
|
|
|
+ $renderable['#agenda_items'] = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($events);
|
|
*/
|
|
*/
|
|
|
|
|
|
// Collection
|
|
// Collection
|