Browse Source

make breadcrumbs referenceField an array

pull/873/head
Seth Shaw 3 years ago
parent
commit
ed0979f97c
  1. 3
      modules/islandora_breadcrumbs/config/install/islandora_breadcrumbs.breadcrumbs.yml
  2. 9
      modules/islandora_breadcrumbs/config/schema/islandora_breadcrumbs.schema.yml
  3. 18
      modules/islandora_breadcrumbs/islandora_breadcrumbs.install
  4. 2
      modules/islandora_breadcrumbs/src/IslandoraBreadcrumbBuilder.php

3
modules/islandora_breadcrumbs/config/install/islandora_breadcrumbs.breadcrumbs.yml

@ -1,6 +1,7 @@
maxDepth: -1 maxDepth: -1
includeSelf: FALSE includeSelf: FALSE
referenceField: field_member_of referenceFields:
- field_member_of
dependencies: dependencies:
module: module:
- islandora - islandora

9
modules/islandora_breadcrumbs/config/schema/islandora_breadcrumbs.schema.yml

@ -7,6 +7,9 @@ islandora_breadcrumbs.breadcrumbs:
includeSelf: includeSelf:
type: boolean type: boolean
label: 'Include Self' label: 'Include Self'
referenceField: referenceFields:
type: string type: sequence
label: 'Reference Field' label: 'Reference Fields'
sequence:
type: string
label: 'Reference Field'

18
modules/islandora_breadcrumbs/islandora_breadcrumbs.install

@ -0,0 +1,18 @@
<?php
/**
* @file
* Install/update hook implementations.
*/
/**
* Update referenceField config to referenceFields.
*/
function islandora_breadcrumbs_update_8001() {
$config_factory = \Drupal::configFactory();
$config = $config_factory->getEditable('islandora_breadcrumbs.breadcrumbs');
$config->set('referenceFields', [$config->get('referenceField')]);
$config->clear('referenceField');
$config->save();
return "Updated referenceFields config.";
}

2
modules/islandora_breadcrumbs/src/IslandoraBreadcrumbBuilder.php

@ -78,7 +78,7 @@ class IslandoraBreadcrumbBuilder implements BreadcrumbBuilderInterface {
$breadcrumb = new Breadcrumb(); $breadcrumb = new Breadcrumb();
$breadcrumb->addLink(Link::createFromRoute($this->t('Home'), '<front>')); $breadcrumb->addLink(Link::createFromRoute($this->t('Home'), '<front>'));
$chain = array_reverse($this->utils->findAncestors($node, [$this->config->get('referenceField')], $this->config->get('maxDepth'))); $chain = array_reverse($this->utils->findAncestors($node, $this->config->get('referenceFields'), $this->config->get('maxDepth')));
// XXX: Handle a looping breadcrumb scenario by filtering the present // XXX: Handle a looping breadcrumb scenario by filtering the present
// node out and then optionally re-adding it after if set to do so. // node out and then optionally re-adding it after if set to do so.

Loading…
Cancel
Save