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
@@ -4,6 +4,7 @@ namespace Drupal\edlp_agenda\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
use Drupal\Core\Url;
use Drupal\Core\Language\LanguageInterface;
// use Symfony\Component\HttpFoundation\JsonResponse;
@@ -18,27 +19,29 @@ class AgendaController extends ControllerBase {
// @see https://www.webomelette.com/query-entities-using-dates-drupal-8
$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), '>=')
->sort('field_date');
$this->future_nids = $query->execute();
$this->future_nodes = entity_load_multiple('node', $this->future_nids);
$this->future_nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($this->future_nids);
// $this->next_event_node = array_shift($this->future_nodes);
$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), '<')
->sort('field_date', 'DESC');
$this->past_nids = $query->execute();
$this->past_nodes = entity_load_multiple('node', $this->past_nids);
$this->past_nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($this->past_nids);
}
private function toRenderable(){