Skip to content
Snippets Groups Projects
Commit 8dbfeca4 authored by Jacob Rockowitz's avatar Jacob Rockowitz
Browse files

Merge branch '3521147-allow-settings-negate' into '1.0.x'

Resolve #3521147 "Allow settings negate"

See merge request !232
parents 427b660a d04ae48b
Branches
Tags
No related merge requests found
Pipeline #482117 failed
......@@ -123,12 +123,16 @@ function schemadotorg_content_model_documentation_form_schemadotorg_types_settin
'#type' => 'schemadotorg_settings',
'#title' => t('Entity type'),
'#description' => t('Enter the entity and Schema.org types that should automatically generate corresponding content model documentation.'),
'#example' => '
'#example' => "
- entity_type_id--SchemaType
- entity_type_id--bundle
- entity_type_id
- SchemaType
',
- '-entity_type_id--SchemaType
- '-entity_type_id--bundle'
- '-entity_type_id'
- '-SchemaType'
",
];
$form['schemadotorg_content_model_documentation']['default_notes'] = [
'#type' => 'textarea',
......
......@@ -96,12 +96,12 @@ function schemadotorg_layout_paragraphs_form_schemadotorg_types_settings_form_al
'#title' => t('Default Schema.org types/content types'),
'#description' => t('Enter Schema.org types or content types (a.k.a bundles) that default to using layout paragraphs.'),
'#description_link' => 'types',
'#example' => '
- SchemaType01
- SchemaType02
- SchemaType03
- advanced_page
',
'#example' => "
- SchemaType
- bundle
- '-SchemaType'
- '-bundle'
",
];
$form['schemadotorg_layout_paragraphs']['default_paragraph_types'] = [
'#type' => 'schemadotorg_settings',
......
......@@ -65,11 +65,14 @@ function schemadotorg_metatag_form_schemadotorg_types_settings_form_alter(array
'#type' => 'schemadotorg_settings',
'#title' => t('Schema.org type'),
'#description' => t('Enter the Schema.org types that should have a meta tags field added when the Schema.org mapping is created.'),
'#example' => '
'#example' => "
- entity_type_id--SchemaType
- entity_type_id--bundle
- entity_type_id--bundle--SchemaType
',
- '-entity_type_id--SchemaType'
- '-entity_type_id--bundle'
- '-entity_type_id--bundle--SchemaType'
",
];
$form['schemadotorg_metatag']['default_groups'] = [
'#type' => 'checkboxes',
......
......@@ -726,11 +726,16 @@ class SchemaDotOrgSchemaTypeManager implements SchemaDotOrgSchemaTypeManagerInte
* {@inheritdoc}
*/
public function getSetting(array $settings, SchemaDotOrgMappingInterface|array $parts, array $options = [], ?array $patterns = NULL): mixed {
// Check for empty settings and immediately return NULL.
if (empty($settings)) {
return NULL;
}
// Set options defaults.
$options += [
'multiple' => FALSE,
'parents' => TRUE,
'negate' => FALSE,
'negate' => TRUE,
];
// Get the parts from a Schema.org mapping.
......
......@@ -497,7 +497,7 @@ interface SchemaDotOrgSchemaTypeManagerInterface {
* - parents (bool)
* Checks parent Schema.org types. Defaults to TRUE.
* - negate (bool)
* Checks for settings that should not being applied.
* Checks for settings that should not being applied. Defaults to TRUE.
* (i.e., starts with a minus (-))
* @param array|null $patterns
* Optional. The patterns to match against the settings array.
......
......@@ -440,7 +440,7 @@ class SchemaDotOrgSchemaTypeManagerKernelTest extends SchemaDotOrgKernelTestBase
'Place' => 'This is a place.',
'Thing' => 'This is thing',
'name' => 'A name',
'-Recipe' => 'Negated recipe (not returned)',
'-recipe' => 'Negated recipe (not returned)',
];
$parts = [
......@@ -463,9 +463,6 @@ class SchemaDotOrgSchemaTypeManagerKernelTest extends SchemaDotOrgKernelTestBase
$this->assertNull(
$this->schemaTypeManager->getSetting($settings, $parts, ['parents' => FALSE])
);
$this->assertNull(
$this->schemaTypeManager->getSetting($settings, $parts, ['negate' => TRUE])
);
$parts = [
'schema_type' => 'Recipe',
......@@ -507,6 +504,15 @@ class SchemaDotOrgSchemaTypeManagerKernelTest extends SchemaDotOrgKernelTestBase
$this->schemaTypeManager->getSetting($settings, $parts, ['multiple' => TRUE])
);
$parts = [
'schema_type' => 'Recipe',
'schema_property' => 'name',
'bundle' => 'recipe',
];
$this->assertNull(
$this->schemaTypeManager->getSetting($settings, $parts)
);
// Check getting setting from an indexed array by type and property.
$settings = ['name'];
$this->assertTrue(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment