Browse Source

initial changes for drupal 9

master
ppound 6 years ago
parent
commit
d341fef4c5
  1. 1
      islandora_herbarium_object.info.yml
  2. 8
      islandora_herbarium_object.module
  3. 7
      src/DataParser/GbifParser.php
  4. 7
      src/DataParser/NrcanParser.php

1
islandora_herbarium_object.info.yml

@ -2,6 +2,7 @@ name: 'Islandora Herbarium Object'
description: 'Provides Islandora Herbarium Object content type and related configuration. Islandora Herbarium Object' description: 'Provides Islandora Herbarium Object content type and related configuration. Islandora Herbarium Object'
type: module type: module
core: 8.x core: 8.x
core_version_requirement: ^8 || ^9
dependencies: dependencies:
- datetime - datetime
- field - field

8
islandora_herbarium_object.module

@ -57,8 +57,8 @@ function islandora_herbarium_object_entity_presave(EntityInterface $entity) {
$geo->updateEntity($entity); $geo->updateEntity($entity);
} }
catch (Exception $e) { catch (Exception $e) {
drupal_set_message(t('There was an error retrieving Geo data. %msg.', \Drupal::messenger()->addError(t('There was an error retrieving Geo data. %msg.',
['%msg' => $e->getMessage()]), 'error'); ['%msg' => $e->getMessage()]));
} }
// Get the taxonomy data. // Get the taxonomy data.
try { try {
@ -66,8 +66,8 @@ function islandora_herbarium_object_entity_presave(EntityInterface $entity) {
$taxon->updateEntity($entity); $taxon->updateEntity($entity);
} }
catch (Exception $e) { catch (Exception $e) {
drupal_set_message(t('There was an error retrieving Taxon data. %msg.', \Drupal::messenger()->addError(t('There was an error retrieving Taxon data. %msg.',
['%msg' => $e->getMessage()]), 'error'); ['%msg' => $e->getMessage()]));
} }
$title = $taxon->getValue('canonicalName') . ' - ' . $geo->getValue('name'); $title = $taxon->getValue('canonicalName') . ' - ' . $geo->getValue('name');
if ($title != ' - ') { if ($title != ' - ') {

7
src/DataParser/GbifParser.php

@ -47,12 +47,7 @@ class GbifParser extends DataParser {
} }
catch (Exception $e) { catch (Exception $e) {
watchdog_exception('islandora_herbarium_object', $e, 'Error getting dwciri'); watchdog_exception('islandora_herbarium_object', $e, 'Error getting dwciri');
drupal_set_message(t('There was an error retrieving Taxon data. %msg. Verify the url is correct %url', throw ($e);
[
'%msg' => $e->getMessage(),
'%url' => $taxoniri[0]['value'],
]), 'error');
return;
} }
$entity->set('field_dwc_scientificname', $this->getValue('canonicalName')); $entity->set('field_dwc_scientificname', $this->getValue('canonicalName'));
$name_arr = explode(' ', $this->getValue('canonicalName')); $name_arr = explode(' ', $this->getValue('canonicalName'));

7
src/DataParser/NrcanParser.php

@ -50,9 +50,7 @@ class NrcanParser extends DataParser {
} }
catch (Exception $e) { catch (Exception $e) {
watchdog_exception('islandora_herbarium_object', $e, 'Error getting dwciri'); watchdog_exception('islandora_herbarium_object', $e, 'Error getting dwciri');
drupal_set_message(t('There was an error retrieving Municipality data. %msg. Verify the url is correct %url', throw ($e);
['%msg' => $e->getMessage(), '%url' => $dwciri[0]['value']]), 'error');
return;
} }
$entity->set('field_dwc_municipality', $this->getValue('name')); $entity->set('field_dwc_municipality', $this->getValue('name'));
// This parser assumes we are in canada. // This parser assumes we are in canada.
@ -68,8 +66,7 @@ class NrcanParser extends DataParser {
$province = $p_arr['description']; $province = $p_arr['description'];
} }
catch (Exception $e) { catch (Exception $e) {
drupal_set_message(t('There was an error retrieving Province data. %msg.', watchdog_exception('islandora_herbarium_object', $e, 'There was an error retrieving Province data');
['%msg' => $e->getMessage()]), 'error');
} }
$entity->set('field_dwc_stateprovince', $province); $entity->set('field_dwc_stateprovince', $province);
$point = [ $point = [

Loading…
Cancel
Save