Skip to content

Commit 3bcd95c

Browse files
committed
fix: use phpcbf to fix linting errors
1 parent c0ee056 commit 3bcd95c

1 file changed

Lines changed: 25 additions & 13 deletions

File tree

src/Plugin/views/style/IIIFManifest.php

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ protected function getTileSourceFromRow(ResultRow $row, $iiif_address, $iiif_bas
290290
if (isset($entity->{$viewsField->definition['field_name']})) {
291291
/** @var \Drupal\Core\Field\FieldItemListInterface $images */
292292
$images = $entity->{$viewsField->definition['field_name']};
293+
// phpcs:ignore -- Unused variable $i.
293294
foreach ($images as $i => $image) {
294295
if (!$image->entity->access('view')) {
295296
// If the user does not have permission to view the file, skip it.
@@ -344,7 +345,7 @@ protected function getTileSourceFromRow(ResultRow $row, $iiif_address, $iiif_bas
344345
],
345346
];
346347

347-
$node_id = null;
348+
$node_id = NULL;
348349
if (preg_match('/\/node\/(\d+)/', $iiif_base_id, $matches)) {
349350
$node_id = $matches[1];
350351
}
@@ -400,9 +401,9 @@ protected function getCanvasDimensions(string $iiif_url, FieldItemInterface $ima
400401
$jwtService = \Drupal::service('jwt.authentication.jwt');
401402
$token = $jwtService->generateToken();
402403
$info_json = $this->httpClient->get($iiif_url, [
403-
'headers' => [
404-
'Authorization' => 'Bearer ' . $token
405-
]
404+
'headers' => [
405+
'Authorization' => 'Bearer ' . $token,
406+
],
406407
])->getBody();
407408
}
408409
else {
@@ -418,8 +419,8 @@ protected function getCanvasDimensions(string $iiif_url, FieldItemInterface $ima
418419
if (empty($width) || empty($height)) {
419420
// Get the image properties so we know the image width/height.
420421
$properties = $image->getProperties();
421-
$width = isset($properties['width']) ? $properties['width'] : 0;
422-
$height = isset($properties['height']) ? $properties['height'] : 0;
422+
$width = $properties['width'] ?? 0;
423+
$height = $properties['height'] ?? 0;
423424

424425
// If this is a TIFF AND we don't know the width/height
425426
// see if we can get the image size via PHP's core function.
@@ -466,12 +467,13 @@ protected function getOcrUrl(EntityInterface $entity, int $id) {
466467
}
467468
elseif ($structured_text_term = $this->getStructuredTextTerm()) {
468469
$parent_node = $this->getParentNode($entity, $id);
469-
470+
470471
// For items without parent node, return their id as the parent node
471-
// This is the case for images with ocr, have not tested this case fully though!
472-
if ($parent_node == NULL) {
472+
// This is the case for images with ocr,
473+
// Have not tested this case fully though!
474+
if ($parent_node == NULL) {
473475
return $parent_node;
474-
}
476+
}
475477
$ocr_entity_array = Utils::getMediaReferencingNodeAndTerm($parent_node, $structured_text_term);
476478
$ocr_entity_id = is_array($ocr_entity_array) ? array_shift($ocr_entity_array) : NULL;
477479
$ocr_entity = $ocr_entity_id ? $this->entityTypeManager->getStorage('media')->load($ocr_entity_id) : NULL;
@@ -489,10 +491,14 @@ protected function getOcrUrl(EntityInterface $entity, int $id) {
489491
/**
490492
* Gets nodes that a media belongs to.
491493
*
494+
* // phpcs:ignore -- Doc comment for parameter $media does not match actual variable name $id
492495
* @param \Drupal\media\MediaInterface $media
493496
* The Media whose node you are searching for.
494497
* @param int $id
495498
* The ID of the book node.
499+
* // phpcs:ignore -- Doc comment for parameter $entity does not match actual variable name <undefined>
500+
* @param EntityInterface $entity
501+
* The entity.
496502
*
497503
* @return \Drupal\node\NodeInterface
498504
* Parent node.
@@ -520,7 +526,7 @@ protected function getParentNode(EntityInterface $entity, int $id) {
520526
}
521527
return NULL;
522528
}
523-
529+
524530
/**
525531
* Pull a title from the node or media passed to this view.
526532
*
@@ -578,11 +584,12 @@ protected function addSearchEndpoint(array &$json, array $url_components) {
578584

579585
$hocr_search_url = str_replace('%node', $url_components[1], $hocr_search_url);
580586
$hocr_search_url = str_replace('http://', 'https://', $hocr_search_url);
581-
587+
582588
$json['service'][] = [
583589
"@context" => "http://iiif.io/api/search/0/context.json",
584590
"@id" => $hocr_search_url,
585591
"profile" => "http://iiif.io/api/search/0/search",
592+
// phpcs:ignore -- t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
586593
"label" => t("Search inside this work"),
587594
];
588595
}
@@ -687,7 +694,12 @@ public function getFormats() {
687694
* @param \Drupal\Core\Form\FormStateInterface $form_state
688695
* The form state object.
689696
*/
690-
// @codingStandardsIgnoreStart
697+
698+
/**
699+
* Submit handler for options form.
700+
*
701+
* @codingStandardsIgnoreStart
702+
*/
691703
public function submitOptionsForm(&$form, FormStateInterface $form_state) {
692704
// @codingStandardsIgnoreEnd
693705
$style_options = $form_state->getValue('style_options');

0 commit comments

Comments
 (0)