Skip to content
Snippets Groups Projects
Commit 46a14a83 authored by Alberto Paderno's avatar Alberto Paderno Committed by Pierre Rudloff
Browse files

Issue #3471967: Fix the issues reported by PHP_CodeSniffer

parent 89644377
No related branches found
No related tags found
1 merge request!1Issue #3471967: Fix the issues reported by PHP_CodeSniffer
Pipeline #443573 passed
<?php <?php
/** /**
* @param \Drupal\Core\Template\Attribute $attributes * @file
* Hooks for the iframe_lazy_loading module.
*/
use Drupal\Core\Template\Attribute;
/**
* Add the loading="lazy" attribute.
* *
* @return void * @param \Drupal\Core\Template\Attribute $attributes
* Attributes of the iframe element.
*/ */
function _iframe_lazy_loading_add_loading_attribute(\Drupal\Core\Template\Attribute $attributes): void { function _iframe_lazy_loading_add_loading_attribute(Attribute $attributes): void {
if (!$attributes->hasAttribute('loading')) { if (!$attributes->hasAttribute('loading')) {
$attributes->setAttribute('loading', 'lazy'); $attributes->setAttribute('loading', 'lazy');
} }
...@@ -19,7 +27,7 @@ function _iframe_lazy_loading_add_loading_attribute(\Drupal\Core\Template\Attrib ...@@ -19,7 +27,7 @@ function _iframe_lazy_loading_add_loading_attribute(\Drupal\Core\Template\Attrib
* @phpstan-param mixed[] $variables * @phpstan-param mixed[] $variables
*/ */
function iframe_lazy_loading_preprocess_iframe(array $variables): void { function iframe_lazy_loading_preprocess_iframe(array $variables): void {
if ($variables['attributes'] instanceof \Drupal\Core\Template\Attribute) { if ($variables['attributes'] instanceof Attribute) {
_iframe_lazy_loading_add_loading_attribute($variables['attributes']); _iframe_lazy_loading_add_loading_attribute($variables['attributes']);
} }
} }
...@@ -32,7 +40,7 @@ function iframe_lazy_loading_preprocess_iframe(array $variables): void { ...@@ -32,7 +40,7 @@ function iframe_lazy_loading_preprocess_iframe(array $variables): void {
* @phpstan-param mixed[] $variables * @phpstan-param mixed[] $variables
*/ */
function iframe_lazy_loading_preprocess_video_embed_iframe(array $variables): void { function iframe_lazy_loading_preprocess_video_embed_iframe(array $variables): void {
if ($variables['attributes'] instanceof \Drupal\Core\Template\Attribute) { if ($variables['attributes'] instanceof Attribute) {
_iframe_lazy_loading_add_loading_attribute($variables['attributes']); _iframe_lazy_loading_add_loading_attribute($variables['attributes']);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment