Skip to content

Commit

Permalink
Added description (#56)
Browse files Browse the repository at this point in the history
* Added description
* list existing immutable namespaces from other modules

Co-authored-by: ajstanley <alanjarlathstanle@gmail.com>
  • Loading branch information
ajstanley and ajstanley authored Apr 30, 2021
1 parent d7a8fee commit a3cfb1f
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Form/JsonLdSettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class JsonLdSettingsForm extends ConfigFormBase {
const CONFIG_NAME = 'jsonld.settings';

const REMOVE_JSONLD_FORMAT = 'remove_jsonld_format';

const RDF_NAMESPACES = 'rdf_namespaces';

/**
Expand All @@ -38,6 +39,7 @@ public function getFormId() {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config(self::CONFIG_NAME);
$mappings_from_hook = rdf_get_namespaces();
$form = [
self::REMOVE_JSONLD_FORMAT => [
'#type' => 'checkbox',
Expand All @@ -49,13 +51,28 @@ public function buildForm(array $form, FormStateInterface $form_state) {

$rdf_namespaces = '';
foreach ($config->get('rdf_namespaces') as $namespace) {
if (isset($mappings_from_hook[$namespace['prefix']])) {
unset($mappings_from_hook[$namespace['prefix']]);
}
$rdf_namespaces .= $namespace['prefix'] . '|' . $namespace['namespace'] . "\n";
}
$mapping_string = '';
foreach ($mappings_from_hook as $pref => $nspace) {
$mapping_string .= "$pref|$nspace \n";
}
$form[self::RDF_NAMESPACES] = [
'#type' => 'textarea',
'#title' => $this->t('RDF Namespaces'),
'#title' => $this->t('Additional RDF Namespaces'),
'#rows' => 10,
'#default_value' => $rdf_namespaces,
'#description' => $this->t("Enter pipe-separated prefixes and namespaces e.g.<br /><strong>dcterms|http://purl.org/dc/terms/</strong>"),
];
$form['existing'] = [
'#type' => 'textarea',
'#title' => $this->t('Existing RDF Namespaces from modules'),
'#rows' => count($mappings_from_hook),
'#value' => $mapping_string,
'#attributes' => ['readonly' => 'readonly'],
];

return parent::buildForm($form, $form_state);
Expand Down

0 comments on commit a3cfb1f

Please sign in to comment.