diff --git a/CHANGELOG.md b/CHANGELOG.md index 09f94a5d0b3629cd73b657f4a7fd7092ac6e5b66..b98b6a1e33050ef5fe191018851093cd7b9cf1a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.7.13] - 8/02/2021 +- Remove deprecated functions of D9 (module passes d9-readiness scan) + ## [2.7.12] - 8/02/2021 - Add core: 8.x to fix enabling issue diff --git a/cern_components.info.yml b/cern_components.info.yml index 6c7f2600170bbe814dda7008b5ee3881566954dc..199899d9f1cb10786d8e4be3c37823243ef2d06b 100755 --- a/cern_components.info.yml +++ b/cern_components.info.yml @@ -3,7 +3,7 @@ type: module description: "Provides all the necessary modules regarding CERN Web Components." core: 8.x core_version_requirement: ^8 || ^9 -version: 2.7.12 +version: 2.7.13 package: CERN Components dependencies: - components:components (>=8.x-1.1-alpha1) diff --git a/cern_components.module b/cern_components.module index fa3f6c16319aee2a008c04d5662ce3aa3ef6805a..d043d6be49c0de6cf3f310327cc677f3ade3f8c9 100755 --- a/cern_components.module +++ b/cern_components.module @@ -2,7 +2,7 @@ use Drupal\ui_patterns\UiPatterns; use Drupal\Component\Utility\Html; - +use Drupal\node\Entity\Node; /** @@ -18,7 +18,7 @@ function cern_components_preprocess(&$variables, $hook) { $variables['cern_node_type'] = \Drupal::routeMatch()->getParameter('node')->getType(); // if $node is string (for revisions) } else if (is_string($object)) { - $variables['cern_node_type'] = node_load($object)->getType(); + $variables['cern_node_type'] = Node::load($object)->getType(); } } diff --git a/composer.json b/composer.json index a6a529c885e2b56a61ef985d4fda6e0c868fa082..e9a52fa4aee312e05f98f2d19b6d9d2dbad84b04 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "drupal/cern-components", "description": "Defines a set of re-usable patterns for the CERN Drupal infrastructure", - "version": "2.7.12", + "version": "2.7.13", "type": "drupal-custom-module", "license": "GPL-2.0-or-later", "authors": [ diff --git a/src/TwigExtension/CernComponentsTwigExtension.php b/src/TwigExtension/CernComponentsTwigExtension.php index 9e37b61f1d6c26cb595d0aca5389e90f89aa1fe2..a3fb486164545c49e49afd271a7e51220d1afb15 100755 --- a/src/TwigExtension/CernComponentsTwigExtension.php +++ b/src/TwigExtension/CernComponentsTwigExtension.php @@ -10,15 +10,15 @@ use Drupal\Core\Menu\MenuLinkTree; use Drupal\Core\Menu\MenuTreeParameters; use Drupal\Core\Url; use Drupal\Component\Utility\Xss; +use Drupal\datetime\Plugin\Field\FieldType\DateTimeFieldItemList; use Drupal\menu_link_content\Entity\MenuLinkContent; use Drupal\paragraphs\Entity\Paragraph; use Drupal\views\Entity\View; use Drupal\views\Views; use Drupal\viewsreference\Plugin\Field\FieldType\ViewsReferenceItem; use Symfony\Component\HttpFoundation\RequestStack; -use Drupal\file\Entity\File; -use Drupal\image\Entity\ImageStyle; use Drupal\node\Entity\Node; +use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface; /** * Class CernComponentsTwigExtension. @@ -176,11 +176,11 @@ class CernComponentsTwigExtension extends \Twig_Extension { public function formatFieldDate($field, $type, $format = '') { $field = reset($field); if (isset($field['#items'])) { - /** @var $items \Drupal\datetime\Plugin\Field\FieldType\DateTimeFieldItemList */ + /** @var $items DateTimeFieldItemList */ $items = $field['#items']; $value = $items->get(0)->getValue(); if (isset($value['value']) && !empty($value['value'])) { - $initial_format = mb_strlen($value['value']) > 10 ? DATETIME_DATETIME_STORAGE_FORMAT : 'Y-m-d'; + $initial_format = mb_strlen($value['value']) > 10 ? DateTimeItemInterface::DATETIME_STORAGE_FORMAT : 'Y-m-d'; $value = \DateTime::createFromFormat($initial_format, $value['value'], new \DateTimeZone('UTC'))->format('U'); return ['#markup' => \Drupal::service('date.formatter')->format($value, $type, $format)]; } @@ -672,7 +672,7 @@ class CernComponentsTwigExtension extends \Twig_Extension { // if $node is string (for revisions) } else if (is_string($node)) { // Get node nid - $node = node_load($node); + $node = Node::load($node); } if (isset($node)) { if ($language == 'en' && $node->hasTranslation('fr') && $node->hasTranslation('en') && $node->getTranslation('fr')->isPublished()) { @@ -704,7 +704,7 @@ class CernComponentsTwigExtension extends \Twig_Extension { // Current language Code $language = \Drupal::languageManager()->getCurrentLanguage()->getId(); - + // Get paragraph object $paragraph_object = Paragraph::load($paragraph_id); @@ -718,7 +718,7 @@ class CernComponentsTwigExtension extends \Twig_Extension { // More info from CDS $info = $paragraph_object->getFields()['field_p_gallery_cds_image']->getValue(); - + return($info); }