Browse Source

Config page for Islandora, plus some basic menu path entries to integrate with the Drupal admi n UI (#7)

pull/756/head
dannylamb 8 years ago committed by Nick Ruest
parent
commit
a1d42b0db1
  1. 2
      config/install/islandora.settings.yml
  2. 13
      islandora.links.menu.yml
  3. 20
      islandora.routing.yml
  4. 72
      src/Form/IslandoraSettingsForm.php

2
config/install/islandora.settings.yml

@ -0,0 +1,2 @@
broker_url: 'http://localhost:61613'
triplestore_index_queue: '/islandora/triplestore/index'

13
islandora.links.menu.yml

@ -6,3 +6,16 @@ entity.fedora_resource_type.collection:
parent: system.admin_structure parent: system.admin_structure
weight: 99 weight: 99
# Menu list of Islandora configuration forms
system.admin_config_islandora:
title: Islandora
parent: system.admin_config
route_name: system.admin_config_islandora
weight: 100
# Core Islandora configuration form
system.islandora_settings:
title: 'Core Settings'
parent: system.admin_config_islandora
route_name: system.islandora_settings
description: 'Confgure core Islandora settings'

20
islandora.routing.yml

@ -9,4 +9,22 @@ entity.fedora_resource_type.rdftest:
options: options:
parameters: parameters:
node_preview: node_preview:
type: 'node_preview' type: 'node_preview'
# Menu list of Islandora configuration forms
system.admin_config_islandora:
path: '/admin/config/islandora'
defaults:
_controller: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage'
_title: 'Islandora'
requirements:
_permission: 'access administration pages'
# Core Islandora configuration form
system.islandora_settings:
path: '/admin/config/islandora/core'
defaults:
_form: '\Drupal\islandora\Form\IslandoraSettingsForm'
_title: 'Islandora Settings'
requirements:
_permission: 'administer site configuration'

72
src/Form/IslandoraSettingsForm.php

@ -0,0 +1,72 @@
<?php
/**
* @file
* Settings form for Islandora.
*/
namespace Drupal\islandora\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Config form for Islandora settings.
*/
class IslandoraSettingsForm extends ConfigFormBase {
const CONFIG_NAME = 'islandora.settings';
const BROKER_URL = 'broker_url';
const TRIPLESTORE_INDEX_QUEUE = 'triplestore_index_queue';
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'islandora_admin_settings';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
self::CONFIG_NAME,
];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config(self::CONFIG_NAME);
$form[self::BROKER_URL] = array(
'#type' => 'textfield',
'#title' => $this->t('Broker URL'),
'#default_value' => $config->get(self::BROKER_URL),
);
$form[self::TRIPLESTORE_INDEX_QUEUE] = array(
'#type' => 'textfield',
'#title' => $this->t('Triplestore Index Queue'),
'#default_value' => $config->get(self::TRIPLESTORE_INDEX_QUEUE),
);
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = \Drupal::service('config.factory')->getEditable(self::CONFIG_NAME);
$config
->set(self::BROKER_URL, $form_state->getValue(self::BROKER_URL))
->set(self::TRIPLESTORE_INDEX_QUEUE, $form_state->getValue(self::TRIPLESTORE_INDEX_QUEUE))
->save();
parent::submitForm($form, $form_state);
}
}
Loading…
Cancel
Save