Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setting to disable JSON-LD reverse #2090

Merged
merged 2 commits into from Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -67,6 +67,8 @@ public function getJsonLdType()

public function getJsonLd()
{
$settings = $this->getServiceLocator()->get('Omeka\Settings');

// Set the date time value objects.
$dateTime = [
'o:created' => [
Expand Down Expand Up @@ -109,8 +111,11 @@ public function getJsonLd()
// According to the JSON-LD spec, the value of the @reverse key "MUST be
// a JSON object containing members representing reverse properties."
// Here, we include the key only if the resource has reverse properties.
$reverse = $this->subjectValuesForReverse();
$reverse = $reverse ? ['@reverse' => $reverse] : [];
$reverse = [];
if (!$settings->get('disable_jsonld_reverse')) {
$reverse = $this->subjectValuesForReverse();
$reverse = $reverse ? ['@reverse' => $reverse] : [];
}

return array_merge(
[
Expand Down
14 changes: 14 additions & 0 deletions application/src/Form/SettingForm.php
Expand Up @@ -187,6 +187,20 @@ public function init()
],
]);

$this->add([
'type' => 'checkbox',
'name' => 'disable_jsonld_reverse',
'options' => [
'element_group' => 'general',
'label' => 'Disable JSON-LD @reverse', // @translate
'info' => 'Disable JSON-LD reverse properties in the API output for resources.', // @translate
],
'attributes' => [
'value' => $this->settings->get('disable_jsonld_reverse'),
'id' => 'disable-jsonld-reverse',
],
]);

// Display element group

$this->add([
Expand Down