Skip to content
Snippets Groups Projects
Commit c51dbcdb authored by Jürgen Haas's avatar Jürgen Haas Committed by Adam G-H
Browse files

Issue #3494070 by jurgenhaas, phenaproxima, prabha1997, thejimbirch, riyas_nr,...

Issue #3494070 by jurgenhaas, phenaproxima, prabha1997, thejimbirch, riyas_nr, poker10, diwakar07: Add Simple XML Sitemap defaults for content types, menu and vocabulary
parent e1a9bf6f
No related branches found
No related tags found
1 merge request!502Issue #3494070 Build ECA model
Pipeline #430651 passed
Showing
with 289 additions and 15 deletions
......@@ -6,7 +6,7 @@
"require": {
"drupal/bpmn_io": "^2.0.6",
"drupal/core": ">=10.3",
"drupal/eca": "^2.1",
"drupal/eca": "^2.1.4",
"drupal/login_emailusername": "^3",
"drupal/token": "^1"
},
......
......@@ -8,7 +8,7 @@
"drupal/bpmn_io": "^2.0.6",
"drupal/core": ">=10.4",
"drupal/drupal_cms_image": "^1.0.1",
"drupal/eca": "^2.1",
"drupal/eca": "^2.1.4",
"drupal/linkit": "^7",
"drupal/pathauto": "^1.13",
"drupal/token": "^1",
......
......@@ -6,7 +6,7 @@
"require": {
"drupal/bpmn_io": "^2.0.6",
"drupal/core": ">=10.4",
"drupal/eca": "^2.1",
"drupal/eca": "^2.1.4",
"drupal/drupal_cms_page": "^1",
"drupal/klaro": "^3",
"drupal/menu_link_attributes": "^1.5"
......
......@@ -15,7 +15,10 @@ events:
Event_save_config:
plugin: 'config:save'
label: 'Save config'
configuration: { }
configuration:
config_name: ''
sync_mode: ''
write_mode: ''
successors:
-
id: Activity_and_1
......
......@@ -26,7 +26,10 @@ events:
Event_save_config:
plugin: 'config:save'
label: 'Save config'
configuration: { }
configuration:
config_name: ''
sync_mode: ''
write_mode: ''
successors:
-
id: Activity_and_1
......
......@@ -4,7 +4,9 @@
"type": "drupal-recipe",
"license": ["GPL-2.0-or-later"],
"require": {
"drupal/bpmn_io": "^2.0.6",
"drupal/core": ">=10.4",
"drupal/eca": "^2.1.4",
"drupal/field_group": "^3.6",
"drupal/focal_point": "^2.1",
"drupal/metatag": "^2",
......
langcode: en
status: true
dependencies:
module:
- eca_base
- eca_config
- eca_content
- eca_misc
- eca_user
id: node_sitemap_settings
modeller: bpmn_io
label: 'Automatically configure sitemap settings for content types'
version: 1.0.0
weight: 0
events:
Event_save_config:
plugin: 'config:save'
label: 'Create node bundle'
configuration:
config_name: node.type.
sync_mode: 'no'
write_mode: new
successors:
-
id: Activity_switch_user
condition: Flow_path_is_not_add_bundle
Event_applied_seo_tools:
plugin: 'drupal:recipe_applied'
label: 'SEO Tools applied'
configuration:
recipe_base_path: drupal_cms_seo_tools
successors:
-
id: Activity_1ghfkn0
condition: ''
conditions:
Flow_number_of_bundles:
plugin: eca_count
configuration:
negate: false
case: false
left: bundles
right: '0'
operator: greaterthan
type: numeric
Flow_path_is_not_add_bundle:
plugin: eca_scalar
configuration:
case: false
left: '[current-page:url:path]'
right: /admin/structure/types/add
operator: equal
type: value
negate: true
Flow_config_is_empty:
plugin: eca_scalar
configuration:
negate: false
case: false
left: '[priority]'
right: priority
operator: contains
type: value
Flow_config_exists:
plugin: eca_scalar
configuration:
case: false
left: '[priority]'
right: priority
operator: contains
type: value
negate: true
gateways:
Gateway_AND_1:
type: 0
successors:
-
id: Activity_get_bundle_id
condition: Flow_number_of_bundles
actions:
Activity_set_bundle_id_to_token:
plugin: eca_token_set_value
label: 'Remember bundle id'
configuration:
token_name: bundle
token_value: '[config:type]'
use_yaml: false
successors:
-
id: Activity_read_sitemap_config_for_bundle
condition: ''
Activity_set_index:
plugin: eca_config_write
label: 'Set index'
configuration:
config_value: '1'
use_yaml: false
save_config: true
config_name: 'simple_sitemap.bundle_settings.default.node.[bundle]'
config_key: index
successors:
-
id: Activity_set_priority
condition: ''
Activity_set_priority:
plugin: eca_config_write
label: 'Set priority'
configuration:
config_value: '0.9'
use_yaml: false
save_config: true
config_name: 'simple_sitemap.bundle_settings.default.node.[bundle]'
config_key: priority
successors:
-
id: Activity_set_changefreq
condition: ''
Activity_set_changefreq:
plugin: eca_config_write
label: 'Set changefreq'
configuration:
config_value: daily
use_yaml: false
save_config: true
config_name: 'simple_sitemap.bundle_settings.default.node.[bundle]'
config_key: changefreq
successors:
-
id: Activity_set_include_images
condition: ''
Activity_set_include_images:
plugin: eca_config_write
label: 'Set include_images'
configuration:
config_value: '0'
use_yaml: false
save_config: true
config_name: 'simple_sitemap.bundle_settings.default.node.[bundle]'
config_key: include_images
successors:
-
id: Gateway_AND_1
condition: ''
Activity_get_list_of_bundles:
plugin: eca_get_bundle_list
label: 'Get bundles'
configuration:
token_name: bundles
type: node
mode: ids
successors:
-
id: Gateway_AND_1
condition: ''
Activity_get_bundle_id:
plugin: eca_list_remove
label: 'Get next bundle ID'
configuration:
value: ''
token_name: bundle
method: first
index: ''
list_token: bundles
successors:
-
id: Activity_read_sitemap_config_for_bundle
condition: ''
Activity_read_sitemap_config_for_bundle:
plugin: eca_config_read
label: 'Read sitemap setting'
configuration:
token_name: priority
include_overridden: true
config_name: 'simple_sitemap.bundle_settings.default.node.[bundle]'
config_key: priority
successors:
-
id: Activity_set_index
condition: Flow_config_is_empty
-
id: Gateway_AND_1
condition: Flow_config_exists
Activity_switch_user:
plugin: eca_switch_account
label: 'Switch user'
configuration:
user_id: '1'
successors:
-
id: Activity_set_bundle_id_to_token
condition: ''
Activity_1ghfkn0:
plugin: eca_switch_account
label: 'Switch user'
configuration:
user_id: '1'
successors:
-
id: Activity_get_list_of_bundles
condition: ''
......@@ -4,6 +4,11 @@ type: Drupal CMS
recipes:
- core/recipes/image_media_type
install:
- eca_base
- eca_config
- eca_content
- eca_misc
- eca_user
- field_group
- focal_point
- layout_builder
......
......@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Drupal\Tests\drupal_cms_seo_tools\Functional;
use Drupal\Core\Config\Config;
use Drupal\Core\Config\ConfigInstallerInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\FunctionalTests\Core\Recipe\RecipeTestTrait;
use Drupal\menu_link_content\Entity\MenuLinkContent;
......@@ -14,7 +16,9 @@ use Drupal\Tests\BrowserTestBase;
*/
class ComponentValidationTest extends BrowserTestBase {
use RecipeTestTrait;
use RecipeTestTrait {
applyRecipe as traitApplyRecipe;
}
/**
* {@inheritdoc}
......@@ -26,20 +30,29 @@ class ComponentValidationTest extends BrowserTestBase {
*/
protected static $modules = ['node'];
public function test(): void {
$dir = realpath(__DIR__ . '/../../..');
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
// Create a content type so we can test the changes made by the recipe.
$node_type = $this->drupalCreateContentType(['type' => 'test'])->id();
$this->drupalCreateContentType(['type' => 'test'])->id();
}
private function applyRecipe(mixed ...$arguments): void {
$dir = realpath(__DIR__ . '/../../..');
$this->traitApplyRecipe($dir, ...$arguments);
}
public function test(): void {
// The recipe should apply cleanly.
$this->applyRecipe($dir);
$this->applyRecipe();
// Apply it again to prove that it is idempotent.
$this->applyRecipe($dir);
$this->applyRecipe();
// There should be an SEO image field on our test content type, referencing
// image media.
$field_settings = FieldConfig::loadByName('node', $node_type, 'field_seo_image')?->getSettings();
$field_settings = FieldConfig::loadByName('node', 'test', 'field_seo_image')?->getSettings();
$this->assertIsArray($field_settings);
$this->assertSame('default:media', $field_settings['handler']);
$this->assertContains('image', $field_settings['handler_settings']['target_bundles']);
......@@ -53,6 +66,51 @@ class ComponentValidationTest extends BrowserTestBase {
$this->checkSitemap();
}
public function testAutomaticSitemapSettings(): void {
$this->applyRecipe();
// We should have Simple Sitemap settings for the extant content type.
$settings = $this->container->get('config.storage')
->listAll('simple_sitemap.bundle_settings');
$this->assertSame(['simple_sitemap.bundle_settings.default.node.test'], $settings);
$get_settings = function (string $node_type): Config {
return $this->config("simple_sitemap.bundle_settings.default.node.$node_type");
};
// If we create a new content type programmatically, Simple Sitemap settings
// should be generated for it automatically.
$node_type = $this->drupalCreateContentType()->id();
$this->assertFalse($get_settings($node_type)->isNew());
// If we create a new content type in the UI, Simple Sitemap settings should
// NOT be automatically generated.
$account = $this->createUser([
'administer content types',
'administer sitemap settings',
]);
$this->drupalLogin($account);
$this->drupalGet('/admin/structure/types/add');
$node_type = $this->randomMachineName();
$this->submitForm([
'name' => $node_type,
'type' => $node_type,
'simple_sitemap[default][index]' => 0,
], 'Save');
$this->assertTrue($get_settings($node_type)->isNew());
// Extant settings should not be changed...
$get_settings('test')->set('priority', '0.3')->save();
$this->assertSame('0.3', $get_settings('test')->get('priority'));
// ...even if we reapply the recipe...
$this->applyRecipe();
$this->assertSame('0.3', $get_settings('test')->get('priority'));
// ...or sync config (here, we are simulating that the priority was changed
// by a config sync).
$this->container->get(ConfigInstallerInterface::class)->setSyncing(TRUE);
$get_settings('test')->set('priority', '0.2')->save();
$this->assertSame('0.2', $get_settings('test')->get('priority'));
}
/**
* Checks that the sitemap is accessible and contains the expected links.
*/
......
......@@ -7,7 +7,7 @@
"drupal/automatic_updates": "^3.1.7",
"drupal/bpmn_io": "^2.0.6",
"drupal/core": ">=10.4",
"drupal/eca": "^2.1.3",
"drupal/eca": "^2.1.4",
"drupal/dashboard": "^2",
"drupal/drupal_cms_admin_ui": "^1",
"drupal/drupal_cms_anti_spam": "^1",
......
......@@ -18,7 +18,10 @@ events:
Event_write_config:
plugin: 'config:save'
label: 'Write config'
configuration: { }
configuration:
config_name: ''
sync_mode: ''
write_mode: ''
successors:
-
id: Gateway_and_1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment