diff --git a/composer.json b/composer.json index b5779e385619ee9523b7af03e56f1b1e0f72622f..bdd5be6d0cbd2db7f0230ed406d2cd35204d2432 100644 --- a/composer.json +++ b/composer.json @@ -87,7 +87,7 @@ "desandro/imagesloaded": "4.1.4", "desandro/masonry": "4.2", "dimsemenov/magnific-popup": "1.1", - "drupal/addtocalendar": "3.2", + "drupal/addtocalendar": "3.3", "drupal/admin_toolbar": "3.4", "drupal/adminimal_theme": "^1.6", "drupal/administerusersbyrole": "3.3", diff --git a/composer.lock b/composer.lock index d2ce6f94d0bc8ffc3c57afddbe2551fefc744d29..083032d5e166d78078f2c87849a09906c1086750 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "12bd67cbe8783bcbbc1e4c2879d4a532", + "content-hash": "35f345cbd85c5532a0b47a9120840ab7", "packages": [ { "name": "alchemy/zippy", @@ -1617,26 +1617,26 @@ }, { "name": "drupal/addtocalendar", - "version": "3.2.0", + "version": "3.3.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/addtocalendar.git", - "reference": "8.x-3.2" + "reference": "8.x-3.3" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/addtocalendar-8.x-3.2.zip", - "reference": "8.x-3.2", - "shasum": "b739326d98008f4091f71e0d5d21b5baa93a5dec" + "url": "https://ftp.drupal.org/files/projects/addtocalendar-8.x-3.3.zip", + "reference": "8.x-3.3", + "shasum": "92ed466bc3f23f20384c7a52ff6ff17361666374" }, "require": { - "drupal/core": "^8 || ^9" + "drupal/core": "^9.3 || ^10" }, "type": "drupal-module", "extra": { "drupal": { - "version": "8.x-3.2", - "datestamp": "1591256432", + "version": "8.x-3.3", + "datestamp": "1684784136", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php index a72151c77c8eb0c43635bfb2ac1ca2d834ac01a7..7824d8f7eafe8db890975f0fa2dfab31435900da 100644 --- a/vendor/composer/ClassLoader.php +++ b/vendor/composer/ClassLoader.php @@ -45,35 +45,34 @@ class ClassLoader /** @var \Closure(string):void */ private static $includeFile; - /** @var ?string */ + /** @var string|null */ private $vendorDir; // PSR-4 /** - * @var array[] - * @psalm-var array<string, array<string, int>> + * @var array<string, array<string, int>> */ private $prefixLengthsPsr4 = array(); /** - * @var array[] - * @psalm-var array<string, array<int, string>> + * @var array<string, list<string>> */ private $prefixDirsPsr4 = array(); /** - * @var array[] - * @psalm-var array<string, string> + * @var list<string> */ private $fallbackDirsPsr4 = array(); // PSR-0 /** - * @var array[] - * @psalm-var array<string, array<string, string[]>> + * List of PSR-0 prefixes + * + * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) + * + * @var array<string, array<string, list<string>>> */ private $prefixesPsr0 = array(); /** - * @var array[] - * @psalm-var array<string, string> + * @var list<string> */ private $fallbackDirsPsr0 = array(); @@ -81,8 +80,7 @@ class ClassLoader private $useIncludePath = false; /** - * @var string[] - * @psalm-var array<string, string> + * @var array<string, string> */ private $classMap = array(); @@ -90,21 +88,20 @@ class ClassLoader private $classMapAuthoritative = false; /** - * @var bool[] - * @psalm-var array<string, bool> + * @var array<string, bool> */ private $missingClasses = array(); - /** @var ?string */ + /** @var string|null */ private $apcuPrefix; /** - * @var self[] + * @var array<string, self> */ private static $registeredLoaders = array(); /** - * @param ?string $vendorDir + * @param string|null $vendorDir */ public function __construct($vendorDir = null) { @@ -113,7 +110,7 @@ public function __construct($vendorDir = null) } /** - * @return string[] + * @return array<string, list<string>> */ public function getPrefixes() { @@ -125,8 +122,7 @@ public function getPrefixes() } /** - * @return array[] - * @psalm-return array<string, array<int, string>> + * @return array<string, list<string>> */ public function getPrefixesPsr4() { @@ -134,8 +130,7 @@ public function getPrefixesPsr4() } /** - * @return array[] - * @psalm-return array<string, string> + * @return list<string> */ public function getFallbackDirs() { @@ -143,8 +138,7 @@ public function getFallbackDirs() } /** - * @return array[] - * @psalm-return array<string, string> + * @return list<string> */ public function getFallbackDirsPsr4() { @@ -152,8 +146,7 @@ public function getFallbackDirsPsr4() } /** - * @return string[] Array of classname => path - * @psalm-return array<string, string> + * @return array<string, string> Array of classname => path */ public function getClassMap() { @@ -161,8 +154,7 @@ public function getClassMap() } /** - * @param string[] $classMap Class to filename map - * @psalm-param array<string, string> $classMap + * @param array<string, string> $classMap Class to filename map * * @return void */ @@ -179,24 +171,25 @@ public function addClassMap(array $classMap) * Registers a set of PSR-0 directories for a given prefix, either * appending or prepending to the ones previously set for this prefix. * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix + * @param list<string>|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories * * @return void */ public function add($prefix, $paths, $prepend = false) { + $paths = (array) $paths; if (!$prefix) { if ($prepend) { $this->fallbackDirsPsr0 = array_merge( - (array) $paths, + $paths, $this->fallbackDirsPsr0 ); } else { $this->fallbackDirsPsr0 = array_merge( $this->fallbackDirsPsr0, - (array) $paths + $paths ); } @@ -205,19 +198,19 @@ public function add($prefix, $paths, $prepend = false) $first = $prefix[0]; if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = (array) $paths; + $this->prefixesPsr0[$first][$prefix] = $paths; return; } if ($prepend) { $this->prefixesPsr0[$first][$prefix] = array_merge( - (array) $paths, + $paths, $this->prefixesPsr0[$first][$prefix] ); } else { $this->prefixesPsr0[$first][$prefix] = array_merge( $this->prefixesPsr0[$first][$prefix], - (array) $paths + $paths ); } } @@ -226,9 +219,9 @@ public function add($prefix, $paths, $prepend = false) * Registers a set of PSR-4 directories for a given namespace, either * appending or prepending to the ones previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list<string>|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories * * @throws \InvalidArgumentException * @@ -236,17 +229,18 @@ public function add($prefix, $paths, $prepend = false) */ public function addPsr4($prefix, $paths, $prepend = false) { + $paths = (array) $paths; if (!$prefix) { // Register directories for the root namespace. if ($prepend) { $this->fallbackDirsPsr4 = array_merge( - (array) $paths, + $paths, $this->fallbackDirsPsr4 ); } else { $this->fallbackDirsPsr4 = array_merge( $this->fallbackDirsPsr4, - (array) $paths + $paths ); } } elseif (!isset($this->prefixDirsPsr4[$prefix])) { @@ -256,18 +250,18 @@ public function addPsr4($prefix, $paths, $prepend = false) throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); } $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; + $this->prefixDirsPsr4[$prefix] = $paths; } elseif ($prepend) { // Prepend directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( - (array) $paths, + $paths, $this->prefixDirsPsr4[$prefix] ); } else { // Append directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( $this->prefixDirsPsr4[$prefix], - (array) $paths + $paths ); } } @@ -276,8 +270,8 @@ public function addPsr4($prefix, $paths, $prepend = false) * Registers a set of PSR-0 directories for a given prefix, * replacing any others previously set for this prefix. * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 base directories + * @param string $prefix The prefix + * @param list<string>|string $paths The PSR-0 base directories * * @return void */ @@ -294,8 +288,8 @@ public function set($prefix, $paths) * Registers a set of PSR-4 directories for a given namespace, * replacing any others previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list<string>|string $paths The PSR-4 base directories * * @throws \InvalidArgumentException * @@ -481,9 +475,9 @@ public function findFile($class) } /** - * Returns the currently registered loaders indexed by their corresponding vendor directories. + * Returns the currently registered loaders keyed by their corresponding vendor directories. * - * @return self[] + * @return array<string, self> */ public static function getRegisteredLoaders() { diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php index c6b54af7ba2e1e3e960134233321efe47aa4528c..51e734a774b3ed9ca110a921cb40a74f8c7905c2 100644 --- a/vendor/composer/InstalledVersions.php +++ b/vendor/composer/InstalledVersions.php @@ -98,7 +98,7 @@ public static function isInstalled($packageName, $includeDevRequirements = true) { foreach (self::getInstalled() as $installed) { if (isset($installed['versions'][$packageName])) { - return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); + return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; } } @@ -119,7 +119,7 @@ public static function isInstalled($packageName, $includeDevRequirements = true) */ public static function satisfies(VersionParser $parser, $packageName, $constraint) { - $constraint = $parser->parseConstraints($constraint); + $constraint = $parser->parseConstraints((string) $constraint); $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); return $provided->matches($constraint); @@ -328,7 +328,9 @@ private static function getInstalled() if (isset(self::$installedByVendor[$vendorDir])) { $installed[] = self::$installedByVendor[$vendorDir]; } elseif (is_file($vendorDir.'/composer/installed.php')) { - $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ + $required = require $vendorDir.'/composer/installed.php'; + $installed[] = self::$installedByVendor[$vendorDir] = $required; if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { self::$installed = $installed[count($installed) - 1]; } @@ -340,12 +342,17 @@ private static function getInstalled() // only require the installed.php file if this file is loaded from its dumped location, // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 if (substr(__DIR__, -8, 1) !== 'C') { - self::$installed = require __DIR__ . '/installed.php'; + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ + $required = require __DIR__ . '/installed.php'; + self::$installed = $required; } else { self::$installed = array(); } } - $installed[] = self::$installed; + + if (self::$installed !== array()) { + $installed[] = self::$installed; + } return $installed; } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 2fcf345706031890568443c3e9832cd2f0981fd7..88ccbbe1c2c6442f9c9890bf3e67f2fa0209116e 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1671,27 +1671,27 @@ }, { "name": "drupal/addtocalendar", - "version": "3.2.0", - "version_normalized": "3.2.0.0", + "version": "3.3.0", + "version_normalized": "3.3.0.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/addtocalendar.git", - "reference": "8.x-3.2" + "reference": "8.x-3.3" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/addtocalendar-8.x-3.2.zip", - "reference": "8.x-3.2", - "shasum": "b739326d98008f4091f71e0d5d21b5baa93a5dec" + "url": "https://ftp.drupal.org/files/projects/addtocalendar-8.x-3.3.zip", + "reference": "8.x-3.3", + "shasum": "92ed466bc3f23f20384c7a52ff6ff17361666374" }, "require": { - "drupal/core": "^8 || ^9" + "drupal/core": "^9.3 || ^10" }, "type": "drupal-module", "extra": { "drupal": { - "version": "8.x-3.2", - "datestamp": "1591246880", + "version": "8.x-3.3", + "datestamp": "1684784136", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" @@ -1711,6 +1711,10 @@ "name": "anand.toshniwal93", "homepage": "https://www.drupal.org/user/3345088" }, + { + "name": "danflanagan8", + "homepage": "https://www.drupal.org/user/3615359" + }, { "name": "gagarine", "homepage": "https://www.drupal.org/user/162439" diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 088738fa4f9f88fb0a0eef9bf580568f0ad8f777..7f1b135a30fb398d5a841d7e45c26d759bb2f85c 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'osu-asc-webservices/d8-upstream', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => 'bbc324b913982bc5f7acfcabab8daa2200f6622b', + 'reference' => '52c5f239f26a10cfa3c2d3933c105ad12c2230cf', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -263,9 +263,9 @@ 'dev_requirement' => false, ), 'drupal/addtocalendar' => array( - 'pretty_version' => '3.2.0', - 'version' => '3.2.0.0', - 'reference' => '8.x-3.2', + 'pretty_version' => '3.3.0', + 'version' => '3.3.0.0', + 'reference' => '8.x-3.3', 'type' => 'drupal-module', 'install_path' => __DIR__ . '/../../web/modules/addtocalendar', 'aliases' => array(), @@ -1549,7 +1549,7 @@ 'osu-asc-webservices/d8-upstream' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => 'bbc324b913982bc5f7acfcabab8daa2200f6622b', + 'reference' => '52c5f239f26a10cfa3c2d3933c105ad12c2230cf', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), diff --git a/web/modules/addtocalendar/addtocalendar.info.yml b/web/modules/addtocalendar/addtocalendar.info.yml index 4e787fcecfef405a729655d9a9d829c93039dcde..505e9e90c2e8ce4f927f0cd97e7f0fbb35708b96 100644 --- a/web/modules/addtocalendar/addtocalendar.info.yml +++ b/web/modules/addtocalendar/addtocalendar.info.yml @@ -2,12 +2,11 @@ name: Add To Calendar type: module description: 'Add to calendar button to be used for event page.' # version: VERSION -core: 8.x -core_version_requirement: ^8 || ^9 +core_version_requirement: ^9.3 || ^10 dependencies: - drupal:datetime -# Information added by Drupal.org packaging script on 2020-06-04 -version: '8.x-3.2' +# Information added by Drupal.org packaging script on 2023-05-22 +version: '8.x-3.3' project: 'addtocalendar' -datestamp: 1591246882 +datestamp: 1684784138 diff --git a/web/modules/addtocalendar/addtocalendar.module b/web/modules/addtocalendar/addtocalendar.module index 39fa980cb2303f26c213116378757dbb330e770c..f95547ebef1940d085f51040a462f127bafc2dcf 100644 --- a/web/modules/addtocalendar/addtocalendar.module +++ b/web/modules/addtocalendar/addtocalendar.module @@ -16,7 +16,7 @@ function addtocalendar_help($route_name, RouteMatchInterface $route_match) { switch ($route_name) { case 'help.page.addtocalendar': - $output = file_get_contents(drupal_get_path('module', 'addtocalendar') . '/README.md'); + $output = file_get_contents(\Drupal::service('extension.list.module')->getPath('addtocalendar') . '/README.md'); return $output; } } diff --git a/web/modules/addtocalendar/addtocalendar.services.yml b/web/modules/addtocalendar/addtocalendar.services.yml index ca410e290b846ff2bbe3b7c5c51873bcdb07f5d7..a6704cbc8ff28f4c4eb3e5316db7dfdab9b4c3fd 100644 --- a/web/modules/addtocalendar/addtocalendar.services.yml +++ b/web/modules/addtocalendar/addtocalendar.services.yml @@ -1,5 +1,5 @@ services: addtocalendar.apiwidget: class: Drupal\addtocalendar\AddToCalendarApiWidget - arguments: ['@config.factory'] + arguments: ['@config.factory', '@renderer'] diff --git a/web/modules/addtocalendar/includes/addtocalendar.build.inc b/web/modules/addtocalendar/includes/addtocalendar.build.inc index 7ff78a5a946216f397bb197704f0388962f48ddc..73df044893a7b798f0b5ac8e406a050b19da5cc8 100644 --- a/web/modules/addtocalendar/includes/addtocalendar.build.inc +++ b/web/modules/addtocalendar/includes/addtocalendar.build.inc @@ -56,6 +56,8 @@ function _addtocalendar_preprocess_field(&$variables) { ], ]; + /** @var \Drupal\Core\Render\RendererInterface $renderer */ + $renderer = \Drupal::service('renderer'); foreach ($values as $index => $date_val) { $daylight_savings = date('I'); $date = new DrupalDateTime(preg_replace('/T/', ' ', $values[$index]['value']), $timeZone); @@ -103,13 +105,13 @@ function _addtocalendar_preprocess_field(&$variables) { default: $field = $settings['addtocalendar_settings'][$value]['field']; if (strip_tags($entity->{$field}->getFieldDefinition() - ->getType()) == 'daterange' + ->getType() ?? '') == 'daterange' ) { - $class_value = strip_tags($entity->{$field}->end_value); + $class_value = strip_tags($entity->{$field}->end_value ?? ''); } else { $view = $entity->get($field)->view(['label' => 'hidden']); - $class_value = strip_tags(render($view)); + $class_value = strip_tags($renderer->render($view) ?? ''); } break; } @@ -156,7 +158,7 @@ function _addtocalendar_preprocess_field(&$variables) { $build['addtocalendar'][$index] = [ '#type' => 'html_tag', '#tag' => 'span', - '#value' => render($build['addtocalendar_button']) . '<var class="atc_event">' .render($build['addtocalendar'][$index]) . '</var>', + '#value' => $renderer->render($build['addtocalendar_button']) . '<var class="atc_event">' . $renderer->render($build['addtocalendar'][$index]) . '</var>', '#attributes' => [ 'class' => [ 'addtocalendar', @@ -199,10 +201,10 @@ function _addtocalendar_preprocess_field(&$variables) { if ($multivalued && $settings['addtocalendar_settings']['multiple_value'] == 2) { foreach ($variables['items'] as $k => $content) { if (isset($variables['items'][$k]['content']['#suffix'])) { - $variables['items'][$k]['content']['#suffix'] .= render($build['addtocalendar'][$k]); + $variables['items'][$k]['content']['#suffix'] .= $renderer->render($build['addtocalendar'][$k]); } else { - $variables['items'][$k]['content']['#suffix'] = render($build['addtocalendar'][$k]); + $variables['items'][$k]['content']['#suffix'] = $renderer->render($build['addtocalendar'][$k]); } $variables['#attached']['library'][] = 'addtocalendar/base'; } @@ -210,10 +212,10 @@ function _addtocalendar_preprocess_field(&$variables) { // Setting #markup for all the date or daterange fields if single value is selected. else { if (isset($variables['items'][$delta]['content']['#suffix'])) { - $variables['items'][$delta]['content']['#suffix'] .= render($build['addtocalendar']); + $variables['items'][$delta]['content']['#suffix'] .= $renderer->render($build['addtocalendar']); } else { - $variables['items'][$delta]['content']['#suffix'] = render($build['addtocalendar']); + $variables['items'][$delta]['content']['#suffix'] = $renderer->render($build['addtocalendar']); } $variables['#attached']['library'][] = 'addtocalendar/base'; } diff --git a/web/modules/addtocalendar/includes/addtocalendar.form.inc b/web/modules/addtocalendar/includes/addtocalendar.form.inc index c4c578896eef2127a84dd62eacc86e247e386632..6060f70a1ff4d2ed39ace544b7c167d2e65352c7 100644 --- a/web/modules/addtocalendar/includes/addtocalendar.form.inc +++ b/web/modules/addtocalendar/includes/addtocalendar.form.inc @@ -1,5 +1,7 @@ <?php +use Drupal\Core\Field\BaseFieldDefinition; + /** * @file * Contains form for addtocalendar module. @@ -8,10 +10,8 @@ /** * Creates Settings form. * - * @param $settings - * Third party Settings array. - * @param $field_definition - * Field Definition of current field. + * @param $settings Third party Settings array. + * @param $field_definition Field Definition of current field. * * @return array */ @@ -87,7 +87,7 @@ function _addtocalendar_build_form($settings, $field_definition) { ], ]; - if ($field_definition instanceof Drupal\Core\Field\BaseFieldDefinition) { + if ($field_definition instanceof BaseFieldDefinition) { $field_definition = $field_definition->getConfig($field_definition->getTargetBundle()); } diff --git a/web/modules/addtocalendar/src/AddToCalendarApiWidget.php b/web/modules/addtocalendar/src/AddToCalendarApiWidget.php index e7b8997315d26da771af5b1fbeb758a4a2468978..16f2e99d945850d72be0c9328785ec75670502b6 100644 --- a/web/modules/addtocalendar/src/AddToCalendarApiWidget.php +++ b/web/modules/addtocalendar/src/AddToCalendarApiWidget.php @@ -4,6 +4,7 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Datetime\DrupalDateTime; +use Drupal\Core\Render\RendererInterface; /** * Class AddToCalendarApiWidget. @@ -23,6 +24,13 @@ class AddToCalendarApiWidget { */ protected $configFactory; + /** + * The renderer service. + * + * @var \Drupal\Core\Render\RendererInterface + */ + protected $renderer; + /** * Style. * @@ -117,7 +125,7 @@ class AddToCalendarApiWidget { /** * Constructs a new AddToCalendarApiWidget object. */ - public function __construct(ConfigFactoryInterface $config_factory) { + public function __construct(ConfigFactoryInterface $config_factory, RendererInterface $renderer = NULL) { $this->atcStyle = 'blue'; $this->atcDisplayText = 'Add to calendar'; @@ -145,6 +153,13 @@ public function __construct(ConfigFactoryInterface $config_factory) { $this->atcDataCalendars = $data_calendars; $this->timeZone = date_default_timezone_get(); + if (is_null($renderer)) { + @trigger_error('Calling AddToCalendarApiWidget::_construct() without the $renderer argument is deprecated and the argument will be required in a future release.', E_USER_DEPRECATED); + $this->renderer = \Drupal::service('renderer'); + } + else { + $this->renderer = $renderer; + } } /** @@ -170,7 +185,7 @@ public function generateWidget() { // Start building the renderable array. $build['addtocalendar'] = []; - $display_text = t('%text', ['%text' => $this->atcDisplayText]); + $display_text = t('@text', ['@text' => $this->atcDisplayText]); $build['addtocalendar_button'] = [ '#type' => 'html_tag', '#tag' => 'a', @@ -211,7 +226,7 @@ public function generateWidget() { $build['addtocalendar'] = [ '#type' => 'html_tag', '#tag' => 'span', - '#value' => render($build['addtocalendar_button']) . '<var class="atc_event">' . render($build['addtocalendar']) . '</var>', + '#value' => $this->renderer->render($build['addtocalendar_button']) . '<var class="atc_event">' . $this->renderer->render($build['addtocalendar']) . '</var>', '#attributes' => [ 'class' => [ 'addtocalendar', diff --git a/web/modules/addtocalendar/src/Plugin/Field/FieldFormatter/AddToCalendar.php b/web/modules/addtocalendar/src/Plugin/Field/FieldFormatter/AddToCalendar.php index bee4325f96858819ac94e13951b76e39679e1e7f..50f1cd5ba3d5969e9c41da5f5255fcbf24f010af 100644 --- a/web/modules/addtocalendar/src/Plugin/Field/FieldFormatter/AddToCalendar.php +++ b/web/modules/addtocalendar/src/Plugin/Field/FieldFormatter/AddToCalendar.php @@ -7,6 +7,7 @@ use Drupal\Core\Field\FormatterBase; use Drupal\Core\Form\FormStateInterface; use Drupal\addtocalendar\AddToCalendarApiWidget; +use Drupal\Core\Render\RendererInterface; use Drupal\Core\Utility\Token; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; @@ -40,6 +41,13 @@ class AddToCalendar extends FormatterBase implements ContainerFactoryPluginInter */ protected $token; + /** + * The renderer service. + * + * @var \Drupal\Core\Render\RendererInterface + */ + protected $renderer; + /** * {@inheritdoc} */ @@ -53,7 +61,8 @@ public static function create(ContainerInterface $container, array $configuratio $configuration['view_mode'], $configuration['third_party_settings'], $container->get('addtocalendar.apiwidget'), - $container->get('token') + $container->get('token'), + $container->get('renderer') ); } @@ -78,11 +87,20 @@ public static function create(ContainerInterface $container, array $configuratio * AddToCalendarApi Widget service. * @param \Drupal\Core\Utility\Token $token * Token service. + * @param \Drupal\Core\Render\RendererInterface|null $renderer + * The renderer service. */ - public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, AddToCalendarApiWidget $add_to_calendar_api_widget, Token $token) { + public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, AddToCalendarApiWidget $add_to_calendar_api_widget, Token $token, RendererInterface $renderer = NULL) { parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings); $this->addToCalendarApiWidget = $add_to_calendar_api_widget; $this->token = $token; + if (is_null($renderer)) { + @trigger_error('Calling AddToCalendar::_construct() without the $renderer argument is deprecated and the argument will be required in a future release.', E_USER_DEPRECATED); + $this->renderer = \Drupal::service('renderer'); + } + else { + $this->renderer = $renderer; + } } /** @@ -168,7 +186,7 @@ protected function viewValue(FieldItemInterface $item) { $service->setWidgetValues($config_values); $build = $service->generateWidget(); - $return = render($build); + $return = $this->renderer->render($build); } else { $return = $this->fieldDefinition->getSetting('off_label'); @@ -214,14 +232,14 @@ public function getProperValue(array $field_setting, $entity, array $options = [ default: $field = $field_setting['field']; if (isset($options['use_raw_value']) && $options['use_raw_value']) { - $value = strip_tags($entity->{$field}->value); - if (isset($options['end_date']) && strip_tags($entity->{$field}->getFieldDefinition()->getType()) == 'daterange') { - $value = strip_tags($entity->{$field}->end_value); + $value = strip_tags($entity->{$field}->value ?? ''); + if (isset($options['end_date']) && strip_tags($entity->{$field}->getFieldDefinition()->getType() ?? '') == 'daterange') { + $value = strip_tags($entity->{$field}->end_value ?? ''); } } else { $value = $entity->get($field)->view(['label' => 'hidden']); - $value = strip_tags(render($value)); + $value = strip_tags($this->renderer->render($value) ?? ''); } break; }