updated custom modules codes for d9
This commit is contained in:
@@ -4,6 +4,7 @@ namespace Drupal\edlp_home\Controller;
|
||||
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
use Drupal\Core\Datetime\DrupalDateTime;
|
||||
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
use Drupal\workflow\Entity\WorkflowManager;
|
||||
use Drupal\Core\Url;
|
||||
@@ -30,45 +31,50 @@ class HomeController extends ControllerBase {
|
||||
|
||||
// first get static pages
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->accessCheck(TRUE)
|
||||
->condition('status', 1)
|
||||
->condition('field_afficher_en_page_d_acceuil', 1)
|
||||
->condition('type', 'static');
|
||||
|
||||
$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
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->accessCheck(TRUE)
|
||||
->condition('status', 1)
|
||||
->condition('field_afficher_en_page_d_acceuil', 1)
|
||||
->condition('type', 'page');
|
||||
|
||||
$promoted_nids = $query->execute();
|
||||
$contents["#promoted_prods"] = entity_load_multiple('node', $promoted_nids);
|
||||
$contents["#promoted_prods"] = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($promoted_nids);
|
||||
|
||||
// presentation
|
||||
// $query = \Drupal::entityQuery('node')
|
||||
// ->accessCheck(TRUE)
|
||||
// ->condition('status', 1)
|
||||
// ->condition('nid', 12242);
|
||||
// // TODO: présentation nid should be a setting
|
||||
//
|
||||
// $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
|
||||
// $query = \Drupal::entityQuery('node')
|
||||
// ->accessCheck(TRUE)
|
||||
// ->condition('status', 1)
|
||||
// ->condition('type', 'fil')
|
||||
// ->sort('created', 'DESC')
|
||||
// ->range(0,1);
|
||||
//
|
||||
// $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.');
|
||||
|
||||
|
||||
// last production
|
||||
// $query = \Drupal::entityQuery('node')
|
||||
// ->accessCheck(TRUE)
|
||||
// ->condition('status', 1)
|
||||
// ->condition('type', 'page')
|
||||
// ->condition('field_page_type', array('1168'), 'NOT IN')
|
||||
@@ -76,17 +82,18 @@ class HomeController extends ControllerBase {
|
||||
// ->range(0,1);
|
||||
//
|
||||
// $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
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->accessCheck(TRUE)
|
||||
->condition('status', 1)
|
||||
->condition('type', 'enregistrement')
|
||||
->sort('created', 'DESC')
|
||||
->range(0,50);
|
||||
|
||||
$nids = $query->execute();
|
||||
$nodes = entity_load_multiple('node', $nids);
|
||||
$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($nids);
|
||||
|
||||
$lastdocs = [];
|
||||
$i = 0;
|
||||
@@ -98,23 +105,24 @@ class HomeController extends ControllerBase {
|
||||
$i++;
|
||||
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;
|
||||
// dsm($contents["#lastdocs_items"], "#lastdocs_items");
|
||||
|
||||
// agenda
|
||||
$now = new DrupalDateTime('now');
|
||||
$now->setTimezone(new \DateTimeZone(DATETIME_STORAGE_TIMEZONE));
|
||||
$now->setTimezone(new \DateTimeZone(DateTimeItemInterface::STORAGE_TIMEZONE));
|
||||
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->accessCheck(TRUE)
|
||||
->condition('status', 1)
|
||||
->condition('type', 'evenement')
|
||||
->condition('field_date', $now->format(DATETIME_DATETIME_STORAGE_FORMAT), '>=')
|
||||
->condition('field_date', $now->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT), '>=')
|
||||
->range(0,5)
|
||||
->sort('field_date');
|
||||
|
||||
$events = $query->execute();
|
||||
$contents['#agenda_items'] = entity_load_multiple('node', $events);
|
||||
$contents['#agenda_items'] = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($events);
|
||||
|
||||
return $contents;
|
||||
}
|
||||
@@ -132,46 +140,50 @@ class HomeController extends ControllerBase {
|
||||
|
||||
// first get static pages
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->accessCheck(TRUE)
|
||||
->condition('status', 1)
|
||||
->condition('field_afficher_en_page_d_acceuil', 1)
|
||||
->condition('type', 'static');
|
||||
|
||||
$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
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->accessCheck(TRUE)
|
||||
->condition('status', 1)
|
||||
->condition('field_afficher_en_page_d_acceuil', 1)
|
||||
->condition('type', 'page');
|
||||
|
||||
$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
|
||||
// $query = \Drupal::entityQuery('node')
|
||||
// ->accessCheck(TRUE)
|
||||
// ->condition('status', 1)
|
||||
// ->condition('type', 'fil')
|
||||
// ->sort('created', 'DESC')
|
||||
// ->range(0,1);
|
||||
//
|
||||
// $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.');
|
||||
|
||||
// agenda
|
||||
/*
|
||||
$now = new DrupalDateTime('now');
|
||||
$now->setTimezone(new \DateTimeZone(DATETIME_STORAGE_TIMEZONE));
|
||||
$now->setTimezone(new \DateTimeZone(DateTimeItemInterface::STORAGE_TIMEZONE));
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->accessCheck(TRUE)
|
||||
->condition('status', 1)
|
||||
->condition('type', 'evenement')
|
||||
->condition('field_date', $now->format(DATETIME_DATETIME_STORAGE_FORMAT), '>=')
|
||||
->condition('field_date', $now->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT), '>=')
|
||||
->range(0,5)
|
||||
->sort('field_date');
|
||||
|
||||
$events = $query->execute();
|
||||
$renderable['#agenda_items'] = entity_load_multiple('node', $events);
|
||||
$renderable['#agenda_items'] = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($events);
|
||||
*/
|
||||
|
||||
// Collection
|
||||
|
||||
Reference in New Issue
Block a user