Browse Source

Resolving merge conflicts from @whikloj's branch

pull/731/head
dannylamb 6 years ago
parent
commit
56e781ab40
  1. 25
      islandora.install
  2. 52
      islandora.module

25
islandora.install

@ -5,6 +5,8 @@
* Install/update hook implementations. * Install/update hook implementations.
*/ */
use Drupal\islandora\Form\IslandoraSettingsForm;
/** /**
* Implements hook_schema(). * Implements hook_schema().
*/ */
@ -52,3 +54,26 @@ function islandora_update_8001(&$sandbox) {
$action->delete(); $action->delete();
} }
} }
/**
* Add in default Gemini URI and Pseudo bundle setting values.
*/
function islandora_update_8002(&$sandbox) {
$config_factory = \Drupal::service('config.factory')->getEditable(IslandoraSettingsForm::CONFIG_NAME);
$changed = FALSE;
$gemini_url = $config_factory->get(IslandoraSettingsForm::GEMINI_URL);
$pseudo_bundles = $config_factory->get(IslandoraSettingsForm::GEMINI_PSEUDO);
if (!isset($gemini_url)) {
$config_factory->set(IslandoraSettingsForm::GEMINI_URL, '');
$changed = TRUE;
}
if (!isset($pseudo_bundles)) {
$config_factory->set(IslandoraSettingsForm::GEMINI_PSEUDO, []);
$changed = TRUE;
}
if ($changed) {
$config_factory->save();
}
}

52
islandora.module

@ -381,29 +381,37 @@ function islandora_entity_extra_field_info() {
* Implements hook_entity_view(). * Implements hook_entity_view().
*/ */
function islandora_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) { function islandora_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
$route_match_item = \Drupal::routeMatch()->getParameters()->get($entity->getEntityTypeId()); $config_factory = \Drupal::service('config.factory')->get(IslandoraSettingsForm::CONFIG_NAME);
// Ensure the entity matches the route. $gemini_url = $config_factory->get(IslandoraSettingsForm::GEMINI_URL);
if ($entity === $route_match_item) { $pseudo_fields = $config_factory->get(IslandoraSettingsForm::GEMINI_PSEUDO);
if ($display->getComponent('field_gemini_uri')) { // If we aren't configured then don't display.
$gemini = \Drupal::service('islandora.gemini.lookup'); if (!empty($gemini_url) && count($pseudo_fields) > 0) {
if ($gemini instanceof GeminiLookup) { $route_match_item = \Drupal::routeMatch()->getParameters()->all();
$fedora_uri = $gemini->lookup($entity); // Get the parameter, which might be node, media or taxonomy term.
if (!is_null($fedora_uri)) { $current_entity = reset($route_match_item);
$build['field_gemini_uri'] = [ // Match exactly to ensure they are the same entity type too.
'#type' => 'container', if ($entity === $current_entity) {
'#attributes' => [ if ($display->getComponent('field_gemini_uri')) {
'id' => 'field-gemini-uri', $gemini = \Drupal::service('islandora.gemini.lookup');
], if ($gemini instanceof GeminiLookup) {
'internal_label' => [ $fedora_uri = $gemini->lookup($entity);
'#type' => 'item', if (!is_null($fedora_uri)) {
'#title' => t('Fedora URI'), $build['field_gemini_uri'] = [
'internal_uri' => [ '#type' => 'container',
'#type' => 'link', '#attributes' => [
'#title' => t("@url", ['@url' => $fedora_uri]), 'id' => 'field-gemini-uri',
'#url' => Url::fromUri($fedora_uri), ],
'internal_label' => [
'#type' => 'item',
'#title' => t('Fedora URI'),
'internal_uri' => [
'#type' => 'link',
'#title' => t("@url", ['@url' => $fedora_uri]),
'#url' => Url::fromUri($fedora_uri),
],
], ],
], ];
]; }
} }
} }
} }

Loading…
Cancel
Save