From 8bc98e062ffe662a14e06342129903686adb096d Mon Sep 17 00:00:00 2001 From: Alexander O'Neill Date: Fri, 21 Apr 2023 15:46:01 -0300 Subject: [PATCH 1/3] Issue #973 Add hooks to IIIF manifest Views Style plugin. --- .../src/Plugin/views/style/IIIFManifest.php | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php index c2a2fbc3..e30b1d63 100644 --- a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php +++ b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php @@ -4,6 +4,7 @@ namespace Drupal\islandora_iiif\Plugin\views\style; use Drupal\views\Plugin\views\style\StylePluginBase; use Drupal\Core\Entity\EntityTypeManagerInterface; +use \Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Url; @@ -90,11 +91,16 @@ class IIIFManifest extends StylePluginBase { * @var \Drupal\Core\Messenger\MessengerInterface */ protected $messenger; + + /** + * @var \Drupal\Core\Extention\ModuleHandlerInterface; + */ + protected $moduleHandler; /** * {@inheritdoc} */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, SerializerInterface $serializer, Request $request, ImmutableConfig $iiif_config, EntityTypeManagerInterface $entity_type_manager, FileSystemInterface $file_system, Client $http_client, MessengerInterface $messenger) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, SerializerInterface $serializer, Request $request, ImmutableConfig $iiif_config, EntityTypeManagerInterface $entity_type_manager, FileSystemInterface $file_system, Client $http_client, MessengerInterface $messenger, ModuleHandlerInterface $moduleHandler) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->serializer = $serializer; @@ -104,6 +110,7 @@ class IIIFManifest extends StylePluginBase { $this->fileSystem = $file_system; $this->httpClient = $http_client; $this->messenger = $messenger; + $this->moduleHandler = $moduleHandler; } /** @@ -120,10 +127,21 @@ class IIIFManifest extends StylePluginBase { $container->get('entity_type.manager'), $container->get('file_system'), $container->get('http_client'), - $container->get('messenger') + $container->get('messenger'), + $container->get('module_handler') ); } + /** + * Return the request property. + * + * @return \Symfony\Component\HttpFoundation\Request + * The Symfony request object + */ + public function getRequest() { + return $this->request; + } + /** * {@inheritdoc} */ @@ -170,6 +188,9 @@ class IIIFManifest extends StylePluginBase { $content_type = 'json'; + // Give other modules a chance to alter the manifest. + $this->moduleHandler->alter('islandora_iiif_manifest', $json, $this); + return $this->serializer->serialize($json, $content_type, ['views_style_plugin' => $this]); } @@ -288,11 +309,15 @@ class IIIFManifest extends StylePluginBase { ]; } + // Give other modules a chance to alter the canvas + $alter_options = ['options' => $this->options, 'views_plugin' => $this]; + $this->moduleHandler->alter('islandora_iiif_manifest_canvas', $tmp_canvas, $row, $alter_options); + $canvases[] = $tmp_canvas; } } } - + return $canvases; } From 8286dfe4235b4a18d649154c38eed916c870de23 Mon Sep 17 00:00:00 2001 From: Alexander O'Neill Date: Fri, 21 Apr 2023 16:40:51 -0300 Subject: [PATCH 2/3] Issue #937: Fix PHPCS issues. --- .../src/Plugin/views/style/IIIFManifest.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php index e30b1d63..b31d3e39 100644 --- a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php +++ b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php @@ -4,7 +4,7 @@ namespace Drupal\islandora_iiif\Plugin\views\style; use Drupal\views\Plugin\views\style\StylePluginBase; use Drupal\Core\Entity\EntityTypeManagerInterface; -use \Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Url; @@ -91,9 +91,11 @@ class IIIFManifest extends StylePluginBase { * @var \Drupal\Core\Messenger\MessengerInterface */ protected $messenger; - + /** - * @var \Drupal\Core\Extention\ModuleHandlerInterface; + * Module Handler for running hooks. + * + * @var \Drupal\Core\Extention\ModuleHandlerInterface */ protected $moduleHandler; @@ -134,7 +136,7 @@ class IIIFManifest extends StylePluginBase { /** * Return the request property. - * + * * @return \Symfony\Component\HttpFoundation\Request * The Symfony request object */ @@ -309,15 +311,18 @@ class IIIFManifest extends StylePluginBase { ]; } - // Give other modules a chance to alter the canvas - $alter_options = ['options' => $this->options, 'views_plugin' => $this]; + // Give other modules a chance to alter the canvas. + $alter_options = [ + 'options' => $this->options, + 'views_plugin' => $this + ]; $this->moduleHandler->alter('islandora_iiif_manifest_canvas', $tmp_canvas, $row, $alter_options); $canvases[] = $tmp_canvas; } } } - + return $canvases; } From 994545798b0575cb463c4e4ab31a739a562e42e6 Mon Sep 17 00:00:00 2001 From: Alexander O'Neill Date: Fri, 21 Apr 2023 16:57:50 -0300 Subject: [PATCH 3/3] Issue 937: More PHPCS fixes. --- .../islandora_iiif/src/Plugin/views/style/IIIFManifest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php index b31d3e39..cacb5245 100644 --- a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php +++ b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php @@ -94,7 +94,7 @@ class IIIFManifest extends StylePluginBase { /** * Module Handler for running hooks. - * + * * @var \Drupal\Core\Extention\ModuleHandlerInterface */ protected $moduleHandler; @@ -314,7 +314,7 @@ class IIIFManifest extends StylePluginBase { // Give other modules a chance to alter the canvas. $alter_options = [ 'options' => $this->options, - 'views_plugin' => $this + 'views_plugin' => $this, ]; $this->moduleHandler->alter('islandora_iiif_manifest_canvas', $tmp_canvas, $row, $alter_options);