updated custom modules codes for d9

This commit is contained in:
2024-09-16 21:48:07 +02:00
parent b357237047
commit cbac2d9946
38 changed files with 375 additions and 158 deletions
@@ -7,5 +7,5 @@
name: Edlp Ajax
type: module
description: Manage ajax entity loading for edlp d8.
core: 8.x
core_version_requirement: ^8 || ^9
package: Edlp
@@ -1,11 +1,3 @@
# @Author: Bachir Soussi Chiadmi <bach>
# @Date: 13-12-2017
# @Email: bachir@figureslibres.io
# @Filename: edlp_corpus.routing.yml
# @Last modified by: bach
# @Last modified time: 20-12-2017
# @License: GPL-V3
edlp_ajax.entityjson:
path: '/edlp/ajax/entity/json/{entity_type}/{id}/{viewmode}'
defaults:
@@ -8,6 +8,7 @@ use Drupal\Core\Url;
use Drupal\Core\Language\LanguageInterface;
use Drupal\menu_link_content\Entity\MenuLinkContent;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
// use Symfony\Component\HttpFoundation\JsonResponse;
use \Drupal\block\Entity\Block;
@@ -22,7 +23,7 @@ class EdlpAjaxController extends ControllerBase {
$this->langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
$entity = entity_load($this->entity_type, $this->id);
$entity = \Drupal::entityTypeManager()->getStorage($this->entity_type)->load($this->id);
if ($entity->hasTranslation($this->langcode)){
$this->entity = $entity->getTranslation($this->langcode);
@@ -51,21 +52,23 @@ class EdlpAjaxController extends ControllerBase {
private function getProductionDatesAside(){
$now = new DrupalDateTime('now');
$now->setTimezone(new \DateTimeZone(DATETIME_STORAGE_TIMEZONE));
$now->setTimezone(new \DateTimeZone(DateTimeItemInterface::STORAGE_TIMEZONE));
$future_dates_query = \Drupal::entityQuery('node')
->accessCheck(TRUE)
->condition('status', 1)
->condition('type', 'evenement')
->condition('field_page_liee.target_id', $this->entity->id(), 'IN')
->condition('field_date', $now->format(DATETIME_DATETIME_STORAGE_FORMAT), '>=')
->condition('field_date', $now->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT), '>=')
->sort('field_date');
$future_nids = $future_dates_query->execute();
$past_dates_query = \Drupal::entityQuery('node')
->accessCheck(TRUE)
->condition('status', 1)
->condition('type', 'evenement')
->condition('field_page_liee.target_id', $this->entity->id(), 'IN')
->condition('field_date', $now->format(DATETIME_DATETIME_STORAGE_FORMAT), '<')
->condition('field_date', $now->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT), '<')
->sort('field_date', 'DESC');
$past_nids = $past_dates_query->execute();
@@ -81,7 +84,7 @@ class EdlpAjaxController extends ControllerBase {
$node_view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
if(count($future_nids)){
$future_nodes = entity_load_multiple('node', $future_nids);
$future_nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($future_nids);
$future_list = array (
'#theme' => 'item_list',
'#items' => [],
@@ -100,7 +103,7 @@ class EdlpAjaxController extends ControllerBase {
}
if(count($past_nids)){
$past_nodes = entity_load_multiple('node', $past_nids);
$past_nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($past_nids);
$past_list = array (
'#theme' => 'item_list',
'#items' => [],