Loading README.txt +2 −2 Original line number Diff line number Diff line Loading @@ -34,8 +34,8 @@ This module requires the following module: INSTALLATION ------------ * Install as you would normally install a contributed drupal module. See: https://drupal.org/documentation/install/modules-themes/modules-8 * Install as you would normally install a contributed Drupal module. See: https://www.drupal.org/docs/extending-drupal/installing-modules for further information. Loading image_styles_mapping.info.yml +2 −2 Original line number Diff line number Diff line name: 'Image Styles Mapping' type: module description: 'Provides a report containing where image styles are used.' core: 8.x core_version_requirement: ^8 || ^9 core_version_requirement: ^9.2 || ^10 package: 'Administration' php: 7.4 dependencies: - drupal:image src/Controller/ImageStylesMappingController.php +12 −12 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ declare(strict_types = 1); namespace Drupal\image_styles_mapping\Controller; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\Utility\TableSort; use Drupal\image_styles_mapping\Service\ImageStylesMappingServiceInterface; use Symfony\Component\DependencyInjection\ContainerInterface; Loading @@ -13,8 +14,6 @@ use Symfony\Component\HttpFoundation\RequestStack; /** * Provides methods which allows to render reports listing the image styles. * * @package Drupal\image_styles_mapping\Controller */ class ImageStylesMappingController extends ControllerBase { Loading @@ -23,42 +22,42 @@ class ImageStylesMappingController extends ControllerBase { * * @var \Drupal\Core\StringTranslation\TranslatableMarkup */ protected $fieldsReportTitle; protected TranslatableMarkup $fieldsReportTitle; /** * Fields report empty value. * * @var \Drupal\Core\StringTranslation\TranslatableMarkup */ protected $fieldsReportEmptyValue; protected TranslatableMarkup $fieldsReportEmptyValue; /** * Views fields report title. * * @var \Drupal\Core\StringTranslation\TranslatableMarkup */ protected $viewsFieldsReportTitle; protected TranslatableMarkup $viewsFieldsReportTitle; /** * Views fields report empty value. * * @var \Drupal\Core\StringTranslation\TranslatableMarkup */ protected $viewsFieldsReportEmptyValue; protected TranslatableMarkup $viewsFieldsReportEmptyValue; /** * Image styles mapping service Interface. * * @var \Drupal\image_styles_mapping\Service\ImageStylesMappingServiceInterface */ protected $imageStylesMappingService; protected ImageStylesMappingServiceInterface $imageStylesMappingService; /** * The request stack service. * * @var \Symfony\Component\HttpFoundation\Request */ protected $currentRequest; protected Request $currentRequest; /** * {@inheritdoc} Loading Loading @@ -145,7 +144,8 @@ class ImageStylesMappingController extends ControllerBase { $this->{$report_name . 'Title'}, $field_report['header'], $field_report['rows'], $this->{$report_name . 'EmptyValue'}); $this->{$report_name . 'EmptyValue'} ); } /** Loading Loading @@ -196,10 +196,10 @@ class ImageStylesMappingController extends ControllerBase { } // Sort data. if ($sort == 'asc') { array_multisort($order_column, SORT_ASC, $rows); \array_multisort($order_column, \SORT_ASC, $rows); } elseif ($sort == 'desc') { array_multisort($order_column, SORT_DESC, $rows); \array_multisort($order_column, \SORT_DESC, $rows); } } return $rows; Loading src/Plugin/ImageStylesMapping/Image.php +10 −12 Original line number Diff line number Diff line Loading @@ -5,10 +5,10 @@ declare(strict_types = 1); namespace Drupal\image_styles_mapping\Plugin\ImageStylesMapping; use Drupal\Component\Render\FormattableMarkup; use Drupal\Core\Link; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Url; use Drupal\image_styles_mapping\Plugin\ImageStylesMappingPluginBase; use Drupal\Core\Link; /** * Class which allows to add image styles support. Loading Loading @@ -56,10 +56,9 @@ class Image extends ImageStylesMappingPluginBase implements ContainerFactoryPlug $image_styles[] = $this->t('No image style used'); } $image_styles = implode(', ', $image_styles); $image_styles = \implode(', ', $image_styles); // Use FormattableMarkup object to avoid link in plain text. $image_styles = new FormattableMarkup($image_styles, []); return $image_styles; return new FormattableMarkup($image_styles, []); } /** Loading @@ -70,7 +69,7 @@ class Image extends ImageStylesMappingPluginBase implements ContainerFactoryPlug */ protected function getImageStyles() { /** @var array|null $image_styles */ $image_styles = &drupal_static(__FUNCTION__); $image_styles = &\drupal_static(__FUNCTION__); if (!isset($image_styles)) { /** @var \Drupal\image\Entity\ImageStyle[] $image_styles_entities */ Loading Loading @@ -116,9 +115,8 @@ class Image extends ImageStylesMappingPluginBase implements ContainerFactoryPlug $link = Link::fromTextAndUrl($link_text, $url)->toRenderable(); return $this->renderer->render($link); } else { return $image_style_label; } } } src/Plugin/ImageStylesMapping/ResponsiveImageStyles.php +10 −12 Original line number Diff line number Diff line Loading @@ -5,10 +5,10 @@ declare(strict_types = 1); namespace Drupal\image_styles_mapping\Plugin\ImageStylesMapping; use Drupal\Component\Render\FormattableMarkup; use Drupal\Core\Link; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Url; use Drupal\image_styles_mapping\Plugin\ImageStylesMappingPluginBase; use Drupal\Core\Link; /** * Class which allows to add responsive image styles support. Loading Loading @@ -56,10 +56,9 @@ class ResponsiveImageStyles extends ImageStylesMappingPluginBase implements Cont $responsive_image_styles[] = $this->t('No responsive image style used'); } $responsive_image_styles = implode(', ', $responsive_image_styles); $responsive_image_styles = \implode(', ', $responsive_image_styles); // Use FormattableMarkup object to avoid link in plain text. $responsive_image_styles = new FormattableMarkup($responsive_image_styles, []); return $responsive_image_styles; return new FormattableMarkup($responsive_image_styles, []); } /** Loading @@ -70,7 +69,7 @@ class ResponsiveImageStyles extends ImageStylesMappingPluginBase implements Cont */ protected function getResponsiveImageStyles() { /** @var array|null $responsive_image_styles */ $responsive_image_styles = &drupal_static(__FUNCTION__); $responsive_image_styles = &\drupal_static(__FUNCTION__); if (!isset($responsive_image_styles)) { /** @var \Drupal\responsive_image\Entity\ResponsiveImageStyle[] $responsive_image_style_entities */ Loading Loading @@ -120,9 +119,8 @@ class ResponsiveImageStyles extends ImageStylesMappingPluginBase implements Cont $link = Link::fromTextAndUrl($link_text, $url)->toRenderable(); return $this->renderer->render($link); } else { return $responsive_image_style_label; } } } Loading
README.txt +2 −2 Original line number Diff line number Diff line Loading @@ -34,8 +34,8 @@ This module requires the following module: INSTALLATION ------------ * Install as you would normally install a contributed drupal module. See: https://drupal.org/documentation/install/modules-themes/modules-8 * Install as you would normally install a contributed Drupal module. See: https://www.drupal.org/docs/extending-drupal/installing-modules for further information. Loading
image_styles_mapping.info.yml +2 −2 Original line number Diff line number Diff line name: 'Image Styles Mapping' type: module description: 'Provides a report containing where image styles are used.' core: 8.x core_version_requirement: ^8 || ^9 core_version_requirement: ^9.2 || ^10 package: 'Administration' php: 7.4 dependencies: - drupal:image
src/Controller/ImageStylesMappingController.php +12 −12 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ declare(strict_types = 1); namespace Drupal\image_styles_mapping\Controller; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\Utility\TableSort; use Drupal\image_styles_mapping\Service\ImageStylesMappingServiceInterface; use Symfony\Component\DependencyInjection\ContainerInterface; Loading @@ -13,8 +14,6 @@ use Symfony\Component\HttpFoundation\RequestStack; /** * Provides methods which allows to render reports listing the image styles. * * @package Drupal\image_styles_mapping\Controller */ class ImageStylesMappingController extends ControllerBase { Loading @@ -23,42 +22,42 @@ class ImageStylesMappingController extends ControllerBase { * * @var \Drupal\Core\StringTranslation\TranslatableMarkup */ protected $fieldsReportTitle; protected TranslatableMarkup $fieldsReportTitle; /** * Fields report empty value. * * @var \Drupal\Core\StringTranslation\TranslatableMarkup */ protected $fieldsReportEmptyValue; protected TranslatableMarkup $fieldsReportEmptyValue; /** * Views fields report title. * * @var \Drupal\Core\StringTranslation\TranslatableMarkup */ protected $viewsFieldsReportTitle; protected TranslatableMarkup $viewsFieldsReportTitle; /** * Views fields report empty value. * * @var \Drupal\Core\StringTranslation\TranslatableMarkup */ protected $viewsFieldsReportEmptyValue; protected TranslatableMarkup $viewsFieldsReportEmptyValue; /** * Image styles mapping service Interface. * * @var \Drupal\image_styles_mapping\Service\ImageStylesMappingServiceInterface */ protected $imageStylesMappingService; protected ImageStylesMappingServiceInterface $imageStylesMappingService; /** * The request stack service. * * @var \Symfony\Component\HttpFoundation\Request */ protected $currentRequest; protected Request $currentRequest; /** * {@inheritdoc} Loading Loading @@ -145,7 +144,8 @@ class ImageStylesMappingController extends ControllerBase { $this->{$report_name . 'Title'}, $field_report['header'], $field_report['rows'], $this->{$report_name . 'EmptyValue'}); $this->{$report_name . 'EmptyValue'} ); } /** Loading Loading @@ -196,10 +196,10 @@ class ImageStylesMappingController extends ControllerBase { } // Sort data. if ($sort == 'asc') { array_multisort($order_column, SORT_ASC, $rows); \array_multisort($order_column, \SORT_ASC, $rows); } elseif ($sort == 'desc') { array_multisort($order_column, SORT_DESC, $rows); \array_multisort($order_column, \SORT_DESC, $rows); } } return $rows; Loading
src/Plugin/ImageStylesMapping/Image.php +10 −12 Original line number Diff line number Diff line Loading @@ -5,10 +5,10 @@ declare(strict_types = 1); namespace Drupal\image_styles_mapping\Plugin\ImageStylesMapping; use Drupal\Component\Render\FormattableMarkup; use Drupal\Core\Link; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Url; use Drupal\image_styles_mapping\Plugin\ImageStylesMappingPluginBase; use Drupal\Core\Link; /** * Class which allows to add image styles support. Loading Loading @@ -56,10 +56,9 @@ class Image extends ImageStylesMappingPluginBase implements ContainerFactoryPlug $image_styles[] = $this->t('No image style used'); } $image_styles = implode(', ', $image_styles); $image_styles = \implode(', ', $image_styles); // Use FormattableMarkup object to avoid link in plain text. $image_styles = new FormattableMarkup($image_styles, []); return $image_styles; return new FormattableMarkup($image_styles, []); } /** Loading @@ -70,7 +69,7 @@ class Image extends ImageStylesMappingPluginBase implements ContainerFactoryPlug */ protected function getImageStyles() { /** @var array|null $image_styles */ $image_styles = &drupal_static(__FUNCTION__); $image_styles = &\drupal_static(__FUNCTION__); if (!isset($image_styles)) { /** @var \Drupal\image\Entity\ImageStyle[] $image_styles_entities */ Loading Loading @@ -116,9 +115,8 @@ class Image extends ImageStylesMappingPluginBase implements ContainerFactoryPlug $link = Link::fromTextAndUrl($link_text, $url)->toRenderable(); return $this->renderer->render($link); } else { return $image_style_label; } } }
src/Plugin/ImageStylesMapping/ResponsiveImageStyles.php +10 −12 Original line number Diff line number Diff line Loading @@ -5,10 +5,10 @@ declare(strict_types = 1); namespace Drupal\image_styles_mapping\Plugin\ImageStylesMapping; use Drupal\Component\Render\FormattableMarkup; use Drupal\Core\Link; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Url; use Drupal\image_styles_mapping\Plugin\ImageStylesMappingPluginBase; use Drupal\Core\Link; /** * Class which allows to add responsive image styles support. Loading Loading @@ -56,10 +56,9 @@ class ResponsiveImageStyles extends ImageStylesMappingPluginBase implements Cont $responsive_image_styles[] = $this->t('No responsive image style used'); } $responsive_image_styles = implode(', ', $responsive_image_styles); $responsive_image_styles = \implode(', ', $responsive_image_styles); // Use FormattableMarkup object to avoid link in plain text. $responsive_image_styles = new FormattableMarkup($responsive_image_styles, []); return $responsive_image_styles; return new FormattableMarkup($responsive_image_styles, []); } /** Loading @@ -70,7 +69,7 @@ class ResponsiveImageStyles extends ImageStylesMappingPluginBase implements Cont */ protected function getResponsiveImageStyles() { /** @var array|null $responsive_image_styles */ $responsive_image_styles = &drupal_static(__FUNCTION__); $responsive_image_styles = &\drupal_static(__FUNCTION__); if (!isset($responsive_image_styles)) { /** @var \Drupal\responsive_image\Entity\ResponsiveImageStyle[] $responsive_image_style_entities */ Loading Loading @@ -120,9 +119,8 @@ class ResponsiveImageStyles extends ImageStylesMappingPluginBase implements Cont $link = Link::fromTextAndUrl($link_text, $url)->toRenderable(); return $this->renderer->render($link); } else { return $responsive_image_style_label; } } }