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
+3
View File
@@ -49,6 +49,9 @@
"drupal/filefield_sources": "^1.0@alpha", "drupal/filefield_sources": "^1.0@alpha",
"drupal/filter_perms": "^1.0@alpha", "drupal/filter_perms": "^1.0@alpha",
"drupal/honeypot": "^2.0", "drupal/honeypot": "^2.0",
"drupal/jquery_ui_draggable": "^1.2",
"drupal/jquery_ui_droppable": "^1.2",
"drupal/jquery_ui_sortable": "^1.1",
"drupal/linkit": "^5.0", "drupal/linkit": "^5.0",
"drupal/login_emailusername": "^2.1", "drupal/login_emailusername": "^2.1",
"drupal/maillog": "^1.0@beta", "drupal/maillog": "^1.0@beta",
Generated
+256
View File
@@ -3646,6 +3646,262 @@
"issues": "https://www.drupal.org/project/issues/honeypot" "issues": "https://www.drupal.org/project/issues/honeypot"
} }
}, },
{
"name": "drupal/jquery_ui",
"version": "1.4.0",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/jquery_ui.git",
"reference": "8.x-1.4"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/jquery_ui-8.x-1.4.zip",
"reference": "8.x-1.4",
"shasum": "64c19ecc8902e2b4b1ab0cc5f5fe28dbc83bfebe"
},
"require": {
"drupal/core": "^8 || ^9"
},
"type": "drupal-module",
"extra": {
"drupal": {
"version": "8.x-1.4",
"datestamp": "1582149957",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0-or-later"
],
"authors": [
{
"name": "bnjmnm",
"homepage": "https://www.drupal.org/user/2369194"
},
{
"name": "jjeff",
"homepage": "https://www.drupal.org/user/17190"
},
{
"name": "lauriii",
"homepage": "https://www.drupal.org/user/1078742"
},
{
"name": "litwol",
"homepage": "https://www.drupal.org/user/78134"
},
{
"name": "mfb",
"homepage": "https://www.drupal.org/user/12302"
},
{
"name": "mfer",
"homepage": "https://www.drupal.org/user/25701"
},
{
"name": "mikelutz",
"homepage": "https://www.drupal.org/user/2972409"
},
{
"name": "nod_",
"homepage": "https://www.drupal.org/user/598310"
},
{
"name": "phenaproxima",
"homepage": "https://www.drupal.org/user/205645"
},
{
"name": "RobLoach",
"homepage": "https://www.drupal.org/user/61114"
},
{
"name": "sun",
"homepage": "https://www.drupal.org/user/54136"
},
{
"name": "webchick",
"homepage": "https://www.drupal.org/user/24967"
},
{
"name": "Wim Leers",
"homepage": "https://www.drupal.org/user/99777"
},
{
"name": "zrpnr",
"homepage": "https://www.drupal.org/user/1448368"
}
],
"description": "Provides jQuery UI library.",
"homepage": "https://www.drupal.org/project/jquery_ui",
"support": {
"source": "https://git.drupalcode.org/project/jquery_ui"
}
},
{
"name": "drupal/jquery_ui_draggable",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/jquery_ui_draggable.git",
"reference": "8.x-1.2"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/jquery_ui_draggable-8.x-1.2.zip",
"reference": "8.x-1.2",
"shasum": "09e17046e38aebf84ed573822b0d5be6de3f0c94"
},
"require": {
"drupal/core": "^8 || ^9",
"drupal/jquery_ui": "*"
},
"type": "drupal-module",
"extra": {
"drupal": {
"version": "8.x-1.2",
"datestamp": "1582150027",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0-or-later"
],
"authors": [
{
"name": "bnjmnm",
"homepage": "https://www.drupal.org/user/2369194"
},
{
"name": "lauriii",
"homepage": "https://www.drupal.org/user/1078742"
},
{
"name": "zrpnr",
"homepage": "https://www.drupal.org/user/1448368"
}
],
"description": "Provides jQuery UI Draggable library.",
"homepage": "https://www.drupal.org/project/jquery_ui_draggable",
"support": {
"source": "https://git.drupalcode.org/project/jquery_ui_draggable"
}
},
{
"name": "drupal/jquery_ui_droppable",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/jquery_ui_droppable.git",
"reference": "8.x-1.2"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/jquery_ui_droppable-8.x-1.2.zip",
"reference": "8.x-1.2",
"shasum": "6e53043f2d3215f211721eea4d4c6ab5d1672b14"
},
"require": {
"drupal/core": "^8 || ^9",
"drupal/jquery_ui": "*",
"drupal/jquery_ui_draggable": "*"
},
"type": "drupal-module",
"extra": {
"drupal": {
"version": "8.x-1.2",
"datestamp": "1582150071",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0-or-later"
],
"authors": [
{
"name": "bnjmnm",
"homepage": "https://www.drupal.org/user/2369194"
},
{
"name": "lauriii",
"homepage": "https://www.drupal.org/user/1078742"
},
{
"name": "zrpnr",
"homepage": "https://www.drupal.org/user/1448368"
}
],
"description": "Provides jQuery UI Droppable library.",
"homepage": "https://www.drupal.org/project/jquery_ui_droppable",
"support": {
"source": "https://git.drupalcode.org/project/jquery_ui_droppable"
}
},
{
"name": "drupal/jquery_ui_sortable",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/jquery_ui_sortable.git",
"reference": "8.x-1.1"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/jquery_ui_sortable-8.x-1.1.zip",
"reference": "8.x-1.1",
"shasum": "dbb64f4e8f57b08a3e0ddd2e5cc3ba8d27d2722f"
},
"require": {
"drupal/core": "^8 || ^9",
"drupal/jquery_ui": "*"
},
"type": "drupal-module",
"extra": {
"drupal": {
"version": "8.x-1.1",
"datestamp": "1583174744",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0-or-later"
],
"authors": [
{
"name": "bnjmnm",
"homepage": "https://www.drupal.org/user/2369194"
},
{
"name": "lauriii",
"homepage": "https://www.drupal.org/user/1078742"
},
{
"name": "zrpnr",
"homepage": "https://www.drupal.org/user/1448368"
}
],
"description": "Provides jQuery UI Sortable library.",
"homepage": "https://www.drupal.org/project/jquery_ui_sortable",
"support": {
"source": "https://git.drupalcode.org/project/jquery_ui_sortable"
}
},
{ {
"name": "drupal/linkit", "name": "drupal/linkit",
"version": "5.0.0-beta11", "version": "5.0.0-beta11",
+4
View File
@@ -56,6 +56,10 @@ module:
help: 0 help: 0
honeypot: 0 honeypot: 0
image: 0 image: 0
jquery_ui: 0
jquery_ui_draggable: 0
jquery_ui_droppable: 0
jquery_ui_sortable: 0
language: 0 language: 0
link: 0 link: 0
linkit: 0 linkit: 0
@@ -10,5 +10,5 @@
name: Edlp Admin name: Edlp Admin
type: module type: module
description: Admin helpers for edlp d8. description: Admin helpers for edlp d8.
core: 8.x core_version_requirement: ^8 || ^9
package: Edlp package: Edlp
@@ -1,16 +1,7 @@
# @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
name: Edlp Agenda name: Edlp Agenda
type: module type: module
description: Manage agenda for edlp d8. description: Manage agenda for edlp d8.
core: 8.x core_version_requirement: ^8 || ^9
package: Edlp package: Edlp
# dependencies: # dependencies:
# - migrate_drupal # - migrate_drupal
@@ -1,13 +1,5 @@
<?php <?php
# @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
/** /**
* Implements hook_theme(). * Implements hook_theme().
*/ */
@@ -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_agenda.agenda: edlp_agenda.agenda:
path: '/agenda' path: '/agenda'
defaults: defaults:
@@ -4,6 +4,7 @@ namespace Drupal\edlp_agenda\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\Core\Url; use Drupal\Core\Url;
use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageInterface;
// use Symfony\Component\HttpFoundation\JsonResponse; // use Symfony\Component\HttpFoundation\JsonResponse;
@@ -18,27 +19,29 @@ class AgendaController extends ControllerBase {
// @see https://www.webomelette.com/query-entities-using-dates-drupal-8 // @see https://www.webomelette.com/query-entities-using-dates-drupal-8
$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), '>=')
->sort('field_date'); ->sort('field_date');
$this->future_nids = $query->execute(); $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); // $this->next_event_node = array_shift($this->future_nodes);
$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), '<')
->sort('field_date', 'DESC'); ->sort('field_date', 'DESC');
$this->past_nids = $query->execute(); $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(){ private function toRenderable(){
@@ -7,5 +7,5 @@
name: Edlp Ajax name: Edlp Ajax
type: module type: module
description: Manage ajax entity loading for edlp d8. description: Manage ajax entity loading for edlp d8.
core: 8.x core_version_requirement: ^8 || ^9
package: Edlp 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: edlp_ajax.entityjson:
path: '/edlp/ajax/entity/json/{entity_type}/{id}/{viewmode}' path: '/edlp/ajax/entity/json/{entity_type}/{id}/{viewmode}'
defaults: defaults:
@@ -8,6 +8,7 @@ use Drupal\Core\Url;
use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageInterface;
use Drupal\menu_link_content\Entity\MenuLinkContent; use Drupal\menu_link_content\Entity\MenuLinkContent;
use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
// use Symfony\Component\HttpFoundation\JsonResponse; // use Symfony\Component\HttpFoundation\JsonResponse;
use \Drupal\block\Entity\Block; use \Drupal\block\Entity\Block;
@@ -22,7 +23,7 @@ class EdlpAjaxController extends ControllerBase {
$this->langcode = \Drupal::languageManager()->getCurrentLanguage()->getId(); $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)){ if ($entity->hasTranslation($this->langcode)){
$this->entity = $entity->getTranslation($this->langcode); $this->entity = $entity->getTranslation($this->langcode);
@@ -51,21 +52,23 @@ class EdlpAjaxController extends ControllerBase {
private function getProductionDatesAside(){ private function getProductionDatesAside(){
$now = new DrupalDateTime('now'); $now = new DrupalDateTime('now');
$now->setTimezone(new \DateTimeZone(DATETIME_STORAGE_TIMEZONE)); $now->setTimezone(new \DateTimeZone(DateTimeItemInterface::STORAGE_TIMEZONE));
$future_dates_query = \Drupal::entityQuery('node') $future_dates_query = \Drupal::entityQuery('node')
->accessCheck(TRUE)
->condition('status', 1) ->condition('status', 1)
->condition('type', 'evenement') ->condition('type', 'evenement')
->condition('field_page_liee.target_id', $this->entity->id(), 'IN') ->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'); ->sort('field_date');
$future_nids = $future_dates_query->execute(); $future_nids = $future_dates_query->execute();
$past_dates_query = \Drupal::entityQuery('node') $past_dates_query = \Drupal::entityQuery('node')
->accessCheck(TRUE)
->condition('status', 1) ->condition('status', 1)
->condition('type', 'evenement') ->condition('type', 'evenement')
->condition('field_page_liee.target_id', $this->entity->id(), 'IN') ->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'); ->sort('field_date', 'DESC');
$past_nids = $past_dates_query->execute(); $past_nids = $past_dates_query->execute();
@@ -81,7 +84,7 @@ class EdlpAjaxController extends ControllerBase {
$node_view_builder = \Drupal::entityTypeManager()->getViewBuilder('node'); $node_view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
if(count($future_nids)){ if(count($future_nids)){
$future_nodes = entity_load_multiple('node', $future_nids); $future_nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($future_nids);
$future_list = array ( $future_list = array (
'#theme' => 'item_list', '#theme' => 'item_list',
'#items' => [], '#items' => [],
@@ -100,7 +103,7 @@ class EdlpAjaxController extends ControllerBase {
} }
if(count($past_nids)){ if(count($past_nids)){
$past_nodes = entity_load_multiple('node', $past_nids); $past_nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($past_nids);
$past_list = array ( $past_list = array (
'#theme' => 'item_list', '#theme' => 'item_list',
'#items' => [], '#items' => [],
@@ -1,17 +1,5 @@
# @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
name: Edlp Corpus name: Edlp Corpus
type: module type: module
description: Creates interactive map of corpus for edlp d8. description: Creates interactive map of corpus for edlp d8.
core: 8.x core_version_requirement: ^8 || ^9
package: Edlp package: Edlp
# dependencies:
# - migrate_drupal
# - migrate_plus
# - migrate_tools
@@ -1,18 +1,8 @@
# @Author: Bachir Soussi Chiadmi <bach>
# @Date: 20-12-2017
# @Email: bachir@figureslibres.io
# @Filename: edlp_corpus.libraries.yml
# @Last modified by: bach
# @Last modified time: 20-12-2017
# @License: GPL-V3
corpus: corpus:
version: VERSION version: 1.x
css: css:
base: base:
assets/dist/styles/corpus.min.css: {} assets/dist/styles/corpus.min.css: {}
version: VERSION
js: js:
assets/dist/scripts/physics.min.js: { scope: footer } assets/dist/scripts/physics.min.js: { scope: footer }
assets/dist/scripts/corpus.min.js: { scope: footer } assets/dist/scripts/corpus.min.js: { scope: footer }
@@ -1,12 +1,4 @@
<?php <?php
# @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
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Url; use Drupal\Core\Url;
@@ -98,13 +90,14 @@ function edlp_corpus_taxonomy_term_view(array &$build, EntityInterface $entity,
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node'); $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
$query = \Drupal::entityQuery('node') $query = \Drupal::entityQuery('node')
->accessCheck(TRUE)
->condition('status', 1) ->condition('status', 1)
->condition('type', 'enregistrement') ->condition('type', 'enregistrement')
->sort('title') ->sort('title')
->condition('field_entrees', $entity->id()); ->condition('field_entrees', $entity->id());
$documents_nids = $query->execute(); $documents_nids = $query->execute();
$documents = entity_load_multiple('node', $documents_nids); $documents = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($documents_nids);
$documents_list = array ( $documents_list = array (
'#theme' => 'item_list', '#theme' => 'item_list',
@@ -149,13 +142,14 @@ function edlp_corpus_node_view(array &$build, EntityInterface $entity, EntityVie
// querying all productions page that have this document in their entity reference "field_documents_liés" // querying all productions page that have this document in their entity reference "field_documents_liés"
$query = \Drupal::entityQuery('node') $query = \Drupal::entityQuery('node')
->accessCheck(TRUE)
->condition('status', 1) ->condition('status', 1)
->condition('type', 'page') // page (production) ->condition('type', 'page') // page (production)
->exists('field_page_type') ->exists('field_page_type')
->condition('field_documents_lies.target_id', $entity->id(), 'IN'); ->condition('field_documents_lies.target_id', $entity->id(), 'IN');
$nids = $query->execute(); $nids = $query->execute();
$nodes = entity_load_multiple('node', $nids); $nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($nids);
// dpm($nodes, '$nodes'); // dpm($nodes, '$nodes');
// build the array of relateds classified by page_type (taxonomy) // build the array of relateds classified by page_type (taxonomy)
@@ -163,7 +157,7 @@ function edlp_corpus_node_view(array &$build, EntityInterface $entity, EntityVie
foreach ($nodes as $nid => $node) { foreach ($nodes as $nid => $node) {
// $page_type = $node->get('field_page_type')->get(0)->getValue(); // $page_type = $node->get('field_page_type')->get(0)->getValue();
// dpm($page_type, 'page_type'); // dpm($page_type, 'page_type');
// $term = entity_load('taxonomy_term', $page_type['target_id']); // $term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load($page_type['target_id']);
// dpm($term, 'term'); // dpm($term, 'term');
// $relateds[$term->getName()][] = $node->getTitle(); // $relateds[$term->getName()][] = $node->getTitle();
$url = Url::fromRoute('entity.node.canonical', ['node'=>$node->id()]); $url = Url::fromRoute('entity.node.canonical', ['node'=>$node->id()]);
@@ -230,10 +224,11 @@ function edlp_corpus_page_attachments(array &$attachments) {
// get all entries // get all entries
$query = \Drupal::entityQuery('taxonomy_term') $query = \Drupal::entityQuery('taxonomy_term')
->accessCheck(TRUE)
->condition('vid', 'entrees'); ->condition('vid', 'entrees');
$tids = $query->execute(); $tids = $query->execute();
$terms = entity_load_multiple('taxonomy_term', $tids); $terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadMultiple($tids);
$js_list = []; $js_list = [];
$css_str = ":root{\n"; $css_str = ":root{\n";
@@ -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_corpus.corpusjson: edlp_corpus.corpusjson:
path: '/edlp/corpus' path: '/edlp/corpus'
defaults: defaults:
@@ -32,18 +32,19 @@ class CorpusController extends ControllerBase {
// @see https://chromatichq.com/blog/dependency-injection-drupal-8-plugins // @see https://chromatichq.com/blog/dependency-injection-drupal-8-plugins
// Get a node storage object. // Get a node storage object.
// $file_storage = \Drupal::entityManager()->getStorage('node'); // $file_storage = \Drupal::entityTypeManager()->getStorage('node');
$current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId(); $current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
$config = \Drupal::config('system.site'); $config = \Drupal::config('system.site');
$query = \Drupal::entityQuery('node') $query = \Drupal::entityQuery('node')
->accessCheck(TRUE)
->condition('status', 1) ->condition('status', 1)
->condition('type', 'enregistrement'); ->condition('type', 'enregistrement');
$nids = $query->execute(); $nids = $query->execute();
$nodes = entity_load_multiple('node', $nids); $nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($nids);
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node'); $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
@@ -112,10 +113,11 @@ class CorpusController extends ControllerBase {
} }
$query = \Drupal::entityQuery('taxonomy_term') $query = \Drupal::entityQuery('taxonomy_term')
->accessCheck(TRUE)
->condition('vid', 'entrees'); ->condition('vid', 'entrees');
$tids = $query->execute(); $tids = $query->execute();
// $nodes = entity_load_multiple('node', $nids); // $nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($nids);
foreach ($tids as $tid) { foreach ($tids as $tid) {
$entrees[] = $tid; $entrees[] = $tid;
} }
@@ -160,13 +162,14 @@ class CorpusController extends ControllerBase {
// $language = \Drupal::languageManager()->getCurrentLanguage()->getId(); // $language = \Drupal::languageManager()->getCurrentLanguage()->getId();
$query = \Drupal::entityQuery('node') $query = \Drupal::entityQuery('node')
->accessCheck(TRUE)
->condition('status', 1) ->condition('status', 1)
->condition('type', 'enregistrement') ->condition('type', 'enregistrement')
->sort('title', 'ASC'); ->sort('title', 'ASC');
// ->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);
// $current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId(); // $current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
@@ -285,13 +288,14 @@ class CorpusController extends ControllerBase {
private function query() { private function query() {
$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);
// $current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId(); // $current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
@@ -398,6 +402,7 @@ class CorpusController extends ControllerBase {
private function articlesQuery() { private function articlesQuery() {
$query = \Drupal::entityQuery('node') $query = \Drupal::entityQuery('node')
->accessCheck(TRUE)
->condition('status', 1) ->condition('status', 1)
->condition('type', 'enregistrement') ->condition('type', 'enregistrement')
->condition('body', '', "<>") ->condition('body', '', "<>")
@@ -405,7 +410,7 @@ class CorpusController extends ControllerBase {
// ->range(0,20); // ->range(0,20);
$nids = $query->execute(); $nids = $query->execute();
$nodes = entity_load_multiple('node', $nids); $nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($nids);
$current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId(); $current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
@@ -512,13 +517,14 @@ class CorpusController extends ControllerBase {
$language = \Drupal::languageManager()->getCurrentLanguage()->getId(); $language = \Drupal::languageManager()->getCurrentLanguage()->getId();
$query = \Drupal::entityQuery('taxonomy_term') $query = \Drupal::entityQuery('taxonomy_term')
->accessCheck(TRUE)
// ->sort('weight', 'DESC') // ->sort('weight', 'DESC')
// ->sort('name', 'DESC') // ->sort('name', 'DESC')
->condition('vid', 'entrees'); ->condition('vid', 'entrees');
$tids = $query->execute(); $tids = $query->execute();
// $terms = entity_load_multiple('taxonomy_term', $tids); // $terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadMultiple($tids);
// $terms = \Drupal::entityManager()->getStorage('taxonomy_term')->loadMultiple($terms); // $terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadMultiple($terms);
$terms = Term::loadMultiple($tids); $terms = Term::loadMultiple($tids);
$ordered_terms = []; $ordered_terms = [];
@@ -28,13 +28,14 @@ class BlockEntrees extends BlockBase {
$language = \Drupal::languageManager()->getCurrentLanguage()->getId(); $language = \Drupal::languageManager()->getCurrentLanguage()->getId();
$query = \Drupal::entityQuery('taxonomy_term') $query = \Drupal::entityQuery('taxonomy_term')
->accessCheck(TRUE)
// ->sort('weight', 'DESC') // ->sort('weight', 'DESC')
// ->sort('name', 'DESC') // ->sort('name', 'DESC')
->condition('vid', 'entrees'); ->condition('vid', 'entrees');
$tids = $query->execute(); $tids = $query->execute();
// $terms = entity_load_multiple('taxonomy_term', $tids); // $terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadMultiple($tids);
// $terms = \Drupal::entityManager()->getStorage('taxonomy_term')->loadMultiple($terms); // $terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadMultiple($terms);
$terms = Term::loadMultiple($tids); $terms = Term::loadMultiple($tids);
$ordered_terms = []; $ordered_terms = [];
@@ -34,7 +34,7 @@ class AudioLinksFilter extends FilterBase {
$href = $link->getAttribute('href'); $href = $link->getAttribute('href');
preg_match('/^\/?node\/(\d+)$/', $href, $matches); preg_match('/^\/?node\/(\d+)$/', $href, $matches);
// dpm($matches[1]); // dpm($matches[1]);
$node = entity_load('node', $matches[1]); $node = \Drupal::entityTypeManager()->getStorage('node')->load($matches[1]);
if(!$node) continue; if(!$node) continue;
if($node->getType() != "enregistrement") continue; if($node->getType() != "enregistrement") continue;
@@ -10,5 +10,5 @@
name: Edlp Fils name: Edlp Fils
type: module type: module
description: Manage fils for edlp d8. description: Manage fils for edlp d8.
core: 8.x core_version_requirement: ^8 || ^9
package: Edlp package: Edlp
@@ -10,7 +10,7 @@
name: Edlp Home name: Edlp Home
type: module type: module
description: Manage home for edlp d8. description: Manage home for edlp d8.
core: 8.x core_version_requirement: ^8 || ^9
package: Edlp package: Edlp
# dependencies: # dependencies:
# - migrate_drupal # - migrate_drupal
@@ -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
@@ -1,7 +1,7 @@
name: Edlp migration name: Edlp migration
type: module type: module
description: Defines custom migration for edlp (from d6 to d8). description: Defines custom migration for edlp (from d6 to d8).
core: 8.x core_version_requirement: ^8 || ^9
package: Edlp package: Edlp
dependencies: dependencies:
- migrate_drupal - migrate_drupal
@@ -1,7 +1,7 @@
name: 'edlp_mobile' name: 'edlp_mobile'
type: module type: module
description: 'Handle some mobile behaviours' description: 'Handle some mobile behaviours'
core: 8.x core_version_requirement: ^8 || ^9
package: 'Edlp' package: 'Edlp'
dependencies: dependencies:
- domain - domain
@@ -10,7 +10,7 @@
name: Edlp Productions name: Edlp Productions
type: module type: module
description: Manage productions for edlp d8. description: Manage productions for edlp d8.
core: 8.x core_version_requirement: ^8 || ^9
package: Edlp package: Edlp
# dependencies: # dependencies:
# - migrate_drupal # - migrate_drupal
@@ -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_productions.productions: edlp_productions.productions:
path: '/productions' path: '/productions'
defaults: defaults:
@@ -21,6 +21,7 @@ class ProductionsController extends ControllerBase {
$menu_name = 'productions'; $menu_name = 'productions';
$query = \Drupal::entityQuery('menu_link_content') $query = \Drupal::entityQuery('menu_link_content')
->accessCheck(TRUE)
->condition('menu_name', $menu_name) ->condition('menu_name', $menu_name)
->condition('enabled', 1) ->condition('enabled', 1)
->sort('weight', 'ASC'); ->sort('weight', 'ASC');
@@ -43,7 +44,7 @@ class ProductionsController extends ControllerBase {
$nids[] = ($m[2]); $nids[] = ($m[2]);
} }
$this->nodes = entity_load_multiple('node', $nids); $this->nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($nids);
} }
@@ -1,7 +1,7 @@
name: 'edlp_search' name: 'edlp_search'
type: module type: module
description: 'Edlp search module' description: 'Edlp search module'
core: 8.x core_version_requirement: ^8 || ^9
package: Edlp package: Edlp
dependencies: dependencies:
- search_api - search_api
@@ -350,7 +350,7 @@ class EdlpSearchController extends ControllerBase {
// entries // entries
$this->entry_names = []; $this->entry_names = [];
if (!empty($this->entries)){ if (!empty($this->entries)){
$terms = entity_load_multiple('taxonomy_term', $this->entries); $terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadMultiple($this->entries);
$entries_condition_group = $query->createConditionGroup(); $entries_condition_group = $query->createConditionGroup();
foreach ($terms as $tid => $term) { foreach ($terms as $tid => $term) {
$entries_condition_group->addCondition('field_entrees', (int)$tid, "="); $entries_condition_group->addCondition('field_entrees', (int)$tid, "=");
@@ -84,10 +84,11 @@ class EdlpSearchForm extends FormBase {
private function getEntries(){ private function getEntries(){
$query = \Drupal::entityQuery('taxonomy_term') $query = \Drupal::entityQuery('taxonomy_term')
->accessCheck(TRUE)
->condition('vid', 'entrees'); ->condition('vid', 'entrees');
$tids = $query->execute(); $tids = $query->execute();
$terms = entity_load_multiple('taxonomy_term', $tids); $terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadMultiple($tids);
// dsm($terms); // dsm($terms);
foreach ($terms as $term) { foreach ($terms as $term) {
// dpm($term->toArray()); // dpm($term->toArray());
@@ -122,7 +123,7 @@ class EdlpSearchForm extends FormBase {
public function submitForm(array &$form, FormStateInterface $form_state) { public function submitForm(array &$form, FormStateInterface $form_state) {
// Display result. // Display result.
foreach ($form_state->getValues() as $key => $value) { foreach ($form_state->getValues() as $key => $value) {
drupal_set_message($key . ': ' . $value); \Drupal::messenger()->addMessage($key . ': ' . $value);
} }
} }
@@ -1,7 +1,7 @@
name: 'Edlp Studio' name: 'Edlp Studio'
type: module type: module
description: 'Edlp module that handle chutier and Compositions entities' description: 'Edlp module that handle chutier and Compositions entities'
core: 8.x core_version_requirement: ^8 || ^9
package: Edlp package: Edlp
dependencies: dependencies:
- entity_reference - entity_reference
@@ -5,6 +5,6 @@ edlp_studio-library:
- core/drupalSettings - core/drupalSettings
- core/jquery - core/jquery
- core/jquery.once - core/jquery.once
- core/jquery.ui.draggable - jquery_ui_draggable/jquery_ui_draggable
- core/jquery.ui.droppable - jquery_ui_droppable/jquery_ui_droppable
- core/jquery.ui.sortable - jquery_ui_sortable/jquery_ui_sortable
@@ -121,7 +121,7 @@ class ChutierController extends ControllerBase {
} }
private function validateNewDoc($id){ private function validateNewDoc($id){
$node = entity_load('node', $id); $node = \Drupal::entityTypeManager()->getStorage('node')->load($id);
if($node){ if($node){
// TODO: get node bundle by settings (@see readme) // TODO: get node bundle by settings (@see readme)
if($node->getType() == 'enregistrement'){ if($node->getType() == 'enregistrement'){
@@ -149,7 +149,7 @@ class ChutierController extends ControllerBase {
private function checkChutier(){ private function checkChutier(){
$default_chutier_id = $this->userdata->get('edlp_studio', $this->user->id(), 'default_chutier'); $default_chutier_id = $this->userdata->get('edlp_studio', $this->user->id(), 'default_chutier');
// dpm($this->default_chutier_id); // dpm($this->default_chutier_id);
$this->chutier = entity_load('chutier', $default_chutier_id); $this->chutier = \Drupal::entityTypeManager()->getStorage('chutier')->load($default_chutier_id);
// if default chutier does not exists, create, save and record it // if default chutier does not exists, create, save and record it
if(!$this->chutier){ if(!$this->chutier){
$this->createDefaultChutier(); $this->createDefaultChutier();
@@ -169,7 +169,7 @@ class ChutierController extends ControllerBase {
'status' => TRUE, 'status' => TRUE,
'name' => t('Default'), 'name' => t('Default'),
); );
$this->chutier = entity_create('chutier', $chutier); $this->chutier = \Drupal::entityTypeManager()->getStorage('chutier')->create($chutier);
$this->chutier->save(); $this->chutier->save();
} }
@@ -170,7 +170,7 @@ class CompositionController extends ControllerBase {
'status' => TRUE, 'status' => TRUE,
'name' => $name, 'name' => $name,
); );
$this->compo = entity_create('composition', $compo); $this->compo = \Drupal::entityTypeManager()->getStorage('composition')->create($compo);
$this->compo->save(); $this->compo->save();
} }
@@ -181,11 +181,11 @@ class CompositionController extends ControllerBase {
} }
private function openComposition($cid){ private function openComposition($cid){
$this->compo = entity_load('composition', $cid); $this->compo = \Drupal::entityTypeManager()->getStorage('composition')->load($cid);
} }
private function saveComposition($cid, $name = "", $new_documents = array()){ private function saveComposition($cid, $name = "", $new_documents = array()){
$this->compo = entity_load('composition', $cid); $this->compo = \Drupal::entityTypeManager()->getStorage('composition')->load($cid);
if($name != ""){ if($name != ""){
$this->compo->setName($name); $this->compo->setName($name);
} }
@@ -201,7 +201,7 @@ class CompositionController extends ControllerBase {
private function deleteComposition($cid){ private function deleteComposition($cid){
$this->compo = entity_load('composition', $cid); $this->compo = \Drupal::entityTypeManager()->getStorage('composition')->load($cid);
$this->compo->delete(); $this->compo->delete();
} }
} }
@@ -115,7 +115,7 @@ class StudioUIController extends ControllerBase {
$documents_nids = Chutier::getUserChutiersContents($this->user->id()); $documents_nids = Chutier::getUserChutiersContents($this->user->id());
// dpm($documents_nids); // dpm($documents_nids);
$documents = entity_load_multiple('node', $documents_nids); $documents = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($documents_nids);
// build content renderable array // build content renderable array
$chutier_ui = array( $chutier_ui = array(
@@ -153,6 +153,7 @@ class StudioUIController extends ControllerBase {
private function buildCompostionsList(){ private function buildCompostionsList(){
// get compositions // get compositions
$query = \Drupal::entityQuery('composition') $query = \Drupal::entityQuery('composition')
->accessCheck(TRUE)
->condition('user_id', $this->user->id()); ->condition('user_id', $this->user->id());
$compos_ids = $query->execute(); $compos_ids = $query->execute();
@@ -160,7 +161,7 @@ class StudioUIController extends ControllerBase {
if(!count($compos_ids)){ if(!count($compos_ids)){
// create default compos // create default compos
$def_compos = \Drupal::entityManager() $def_compos = \Drupal::entityTypeManager()
->getStorage('composition') ->getStorage('composition')
->create(array( ->create(array(
'name' => 'composition', 'name' => 'composition',
@@ -171,7 +172,7 @@ class StudioUIController extends ControllerBase {
$compos_ids = array($def_compos->id()); $compos_ids = array($def_compos->id());
} }
$compos = entity_load_multiple('composition', $compos_ids); $compos = \Drupal::entityTypeManager()->getStorage('composition')->loadMultiple($compos_ids);
$createurl = Url::fromRoute('edlp_studio.composition_controller_action_ajax', ['action' => 'create'], ['absolute' => TRUE]); $createurl = Url::fromRoute('edlp_studio.composition_controller_action_ajax', ['action' => 'create'], ['absolute' => TRUE]);
@@ -185,13 +186,14 @@ class StudioUIController extends ControllerBase {
private function getLastCompo(){ private function getLastCompo(){
// just get the last compositions // just get the last compositions
$query = \Drupal::entityQuery('composition') $query = \Drupal::entityQuery('composition')
->accessCheck(TRUE)
->condition('user_id', $this->user->id()) ->condition('user_id', $this->user->id())
->range(0,1) ->range(0,1)
->sort('created', 'DESC'); ->sort('created', 'DESC');
$compos_id = $query->execute(); $compos_id = $query->execute();
if(count($compos_id)){ if(count($compos_id)){
$lastcompo = entity_load('composition', array_pop($compos_id)); $lastcompo = \Drupal::entityTypeManager()->getStorage('composition')->load(array_pop($compos_id));
}else{ }else{
$lastcompo = null; $lastcompo = null;
} }
@@ -247,10 +247,11 @@ class Chutier extends ContentEntityBase implements ChutierInterface {
public static function getUserChutiersContents($uid){ public static function getUserChutiersContents($uid){
// TODO: use query if we use more than one chutier // TODO: use query if we use more than one chutier
// $query = \Drupal::entityQuery('chutier') // $query = \Drupal::entityQuery('chutier')
// ->accessCheck(TRUE)
// ->condition('user_id', $uid); // ->condition('user_id', $uid);
// //
// $chutiers_nids = $query->execute(); // $chutiers_nids = $query->execute();
// $chutiers = entity_load_multiple('chutier', $chutiers_nids); // $chutiers = \Drupal::entityTypeManager()->getStorage('chutier')->loadMultiple($chutiers_nids);
// //
// $contents = array(); // $contents = array();
// foreach ($chutiers as $id => $chutier) { // foreach ($chutiers as $id => $chutier) {
@@ -260,7 +261,7 @@ class Chutier extends ContentEntityBase implements ChutierInterface {
/** @var UserDataInterface $userData */ /** @var UserDataInterface $userData */
$userData = \Drupal::service('user.data'); $userData = \Drupal::service('user.data');
$default_chutier_id = $userData->get('edlp_studio', $uid, 'default_chutier'); $default_chutier_id = $userData->get('edlp_studio', $uid, 'default_chutier');
if($chutier = entity_load('chutier', $default_chutier_id)){ if($chutier = \Drupal::entityTypeManager()->getStorage('chutier')->load($default_chutier_id)){
return array_column($chutier->documents->getValue(), 'target_id'); return array_column($chutier->documents->getValue(), 'target_id');
}else{ }else{
return array(); return array();
@@ -34,13 +34,13 @@ class ChutierForm extends ContentEntityForm {
switch ($status) { switch ($status) {
case SAVED_NEW: case SAVED_NEW:
drupal_set_message($this->t('Created the %label Chutier.', [ \Drupal::messenger()->addMessage($this->t('Created the %label Chutier.', [
'%label' => $entity->label(), '%label' => $entity->label(),
])); ]));
break; break;
default: default:
drupal_set_message($this->t('Saved the %label Chutier.', [ \Drupal::messenger()->addMessage($this->t('Saved the %label Chutier.', [
'%label' => $entity->label(), '%label' => $entity->label(),
])); ]));
} }
@@ -34,13 +34,13 @@ class CompositionForm extends ContentEntityForm {
switch ($status) { switch ($status) {
case SAVED_NEW: case SAVED_NEW:
drupal_set_message($this->t('Created the %label Composition.', [ \Drupal::messenger()->addMessage($this->t('Created the %label Composition.', [
'%label' => $entity->label(), '%label' => $entity->label(),
])); ]));
break; break;
default: default:
drupal_set_message($this->t('Saved the %label Composition.', [ \Drupal::messenger()->addMessage($this->t('Saved the %label Composition.', [
'%label' => $entity->label(), '%label' => $entity->label(),
])); ]));
} }
@@ -2,7 +2,7 @@ name: edlp
description: 'EDLP Drupal 8 theme with gulp' description: 'EDLP Drupal 8 theme with gulp'
type: theme type: theme
base theme: classy base theme: classy
core: 8.x core_version_requirement: ^8 || ^9
libraries: libraries:
- core/normalize - core/normalize
- edlptheme/redirect-js - edlptheme/redirect-js