Browse Source

Coding standards.

pull/907/head
Rosie Le Faive 2 years ago
parent
commit
21585a02eb
  1. 9
      modules/islandora_fits/islandora_fits.install
  2. 2
      modules/islandora_fits/islandora_fits.module
  3. BIN
      modules/islandora_fits/migrations/.swp
  4. 23
      modules/islandora_fits/src/Services/XMLTransform.php

9
modules/islandora_fits/islandora_fits.install

@ -5,16 +5,15 @@
* Install/update hook implementations.
*/
use Drupal\field\Entity\FieldConfig;
/**
* Implements hook_install().
*/
function islandora_fits_install($is_syncing) {
if (!_islandora_fits_term_exists()) {
$callable = $is_syncing ? [\Drupal::messenger(), 'addStatus'] : [\Drupal::messenger(), 'addWarning'];
$callable = $is_syncing
? [\Drupal::messenger(), 'addStatus']
: [\Drupal::messenger(), 'addWarning'];
$callable(t('A term in the taxonomy @vid with the URI @uri does not appear to exist. The @migration_id migration can be executed to create it.', [
'@vid' => 'islandora_media_use',
'@uri' => 'https://projects.iq.harvard.edu/fits',
@ -36,7 +35,7 @@ function islandora_fits_requirements($phase) : array {
'title' => t('FITS Term Exists'),
'value' => $term_exists ? t('Exists') : t('Does not exist'),
'description' => t('Whether or not a term with the URI targeted by default FITS derivative configuration exists. If derivative configurations were made to target another URI, this can probably be ignored.'),
'severity' => $term_exists ? REQUIREMENT_OK : REQUIREMENT_WARNING
'severity' => $term_exists ? REQUIREMENT_OK : REQUIREMENT_WARNING,
];
}

2
modules/islandora_fits/islandora_fits.module

@ -6,8 +6,6 @@
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\media\MediaInterface;
use Drupal\file\Entity\File;
use Drupal\media\Entity\Media;
use Drupal\node\Entity\NodeType;

BIN
modules/islandora_fits/migrations/.swp

Binary file not shown.

23
modules/islandora_fits/src/Services/XMLTransform.php

@ -4,17 +4,15 @@ namespace Drupal\islandora_fits\Services;
use Drupal\Component\Utility\Xss;
use Drupal\Core\DependencyInjection\ServiceProviderBase;
use Drupal\Core\Entity\EntityFieldManager;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Render\RendererInterface;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\Entity\FieldConfig;
use Drupal\media\MediaInterface;
use DrupalCodeGenerator\Command\Drupal_8\Form\Simple;
/**
* Class XMLTransform.
* Transform FITS XML for display and storage.
*/
class XMLTransform extends ServiceProviderBase {
/**
@ -52,7 +50,7 @@ class XMLTransform extends ServiceProviderBase {
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger.
*/
public function __construct(RendererInterface $renderer, EntityFieldManager $entityManager, MessengerInterface $messenger) {
public function __construct(RendererInterface $renderer, EntityManagerInterface $entityManager, MessengerInterface $messenger) {
$this->renderer = $renderer;
$this->entityManager = $entityManager;
$this->messenger = $messenger;
@ -109,15 +107,24 @@ class XMLTransform extends ServiceProviderBase {
foreach ($vals_array as $field => $val_array) {
if (!array_key_exists($field, $rows) && $field != 'Filepath') {
$rows[$field] = [
['data' => Xss::filter($field), 'class' => 'islandora_fits_table_labels'],
[
'data' => Xss::filter($field),
'class' => 'islandora_fits_table_labels',
],
];
foreach ($val_array as $value) {
if (!isset($rows[$field]['value'])) {
$rows[$field]['value'] = ['data' => Xss::filter($value), 'class' => 'islandora_fits_table_values'];
$rows[$field]['value'] = [
'data' => Xss::filter($value),
'class' => 'islandora_fits_table_values',
];
}
else {
$data = $rows[$field]['value']['data'] .= ' - ' . Xss::filter($value);
$rows[$field]['value'] = ['data' => $data, 'class' => 'islandora_fits_table_values'];
$rows[$field]['value'] = [
'data' => $data,
'class' => 'islandora_fits_table_values',
];
}
}
}
@ -163,7 +170,7 @@ class XMLTransform extends ServiceProviderBase {
*
* Once it has these it passes them off recursively.
*
* @param \SimpleXMLElement
* @param \SimpleXMLElement $xml
* The SimpleXMLElement to parse.
*
* @return array

Loading…
Cancel
Save