You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.5 KiB
60 lines
1.5 KiB
<?php |
|
|
|
/** |
|
* @file |
|
* Contains islandora_herbarium.module. |
|
*/ |
|
|
|
use Drupal\Core\Routing\RouteMatchInterface; |
|
use Drupal\Core\Entity\EntityInterface; |
|
|
|
/** |
|
* Implements hook_help(). |
|
*/ |
|
function islandora_herbarium_object_help($route_name, RouteMatchInterface $route_match) |
|
{ |
|
switch ($route_name) { |
|
// Main module help for the islandora_pdf module. |
|
case 'help.page.islandora_herbarium': |
|
$output = ''; |
|
$output .= '<h3>' . t('About') . '</h3>'; |
|
$output .= '<p>' . t('Islandora Herbarium') . '</p>'; |
|
return $output; |
|
|
|
default: |
|
} |
|
} |
|
|
|
/** |
|
* Implements hook_entity_presave(). |
|
*/ |
|
function islandora_herbarium_object_entity_presave(Drupal\Core\Entity\EntityInterface $entity) |
|
{ |
|
if ($entity->bundle() == 'islandora_herbarium_object') { |
|
// Get the geo data. |
|
try { |
|
$geo = \Drupal::service('islandora_herbarium_object.geoparser'); |
|
$geo->updateEntity($entity); |
|
} catch (Exception $e) { |
|
drupal_set_message(t('There was an error retrieving Geo data. %msg.', |
|
array('%msg'=> $e->getMessage())), 'error'); |
|
} |
|
// Get the taxonomy data. |
|
try { |
|
$taxon = \Drupal::service('islandora_herbarium_object.taxonparser'); |
|
$taxon->updateEntity($entity); |
|
} catch(Exception $e) { |
|
drupal_set_message(t('There was an error retrieving Taxon data. %msg.', |
|
array('%msg'=> $e->getMessage())), 'error'); |
|
} |
|
$title = $taxon->getValue('canonicalName') . ' - ' . $geo->getValue('name'); |
|
if($title != ' - ') { |
|
$entity->setTitle($title); |
|
} |
|
|
|
|
|
} |
|
} |
|
|
|
|
|
|
|
|