Loading pathauto.install +23 −0 Original line number Diff line number Diff line Loading @@ -297,3 +297,26 @@ function pathauto_update_8107() { ->set('safe_tokens', $safe_tokens) ->save(); } /** * Update node type conditions from node_type to entity_bundle. */ function pathauto_update_8108() { // Load all pattern configuration entities. foreach (\Drupal::configFactory()->listAll('pathauto.pattern.') as $pattern_config_name) { $pattern_config = \Drupal::configFactory()->getEditable($pattern_config_name); // Loop patterns and swap the node_type plugin by the entity_bundle:node // plugin. if ($pattern_config->get('type') === 'canonical_entities:node') { $selection_criteria = $pattern_config->get('selection_criteria'); foreach ($selection_criteria as $uuid => $condition) { if ($condition['id'] === 'node_type') { $pattern_config->set("selection_criteria.$uuid.id", 'entity_bundle:node'); $pattern_config->save(); break; } } } } } src/Form/PatternEditForm.php +2 −3 Original line number Diff line number Diff line Loading @@ -223,17 +223,16 @@ class PatternEditForm extends EntityForm { $entity_type = $alias_type->getDerivativeId(); // First, remove bundle and language conditions. foreach ($entity->getSelectionConditions() as $condition_id => $condition) { if (in_array($condition->getPluginId(), ['entity_bundle:' . $entity_type, 'node_type', 'language'])) { if (in_array($condition->getPluginId(), ['entity_bundle:' . $entity_type, 'language'])) { $entity->removeSelectionCondition($condition_id); } } if ($bundles = array_filter((array) $form_state->getValue('bundles'))) { $default_weight -= 5; $plugin_id = $entity_type == 'node' ? 'node_type' : 'entity_bundle:' . $entity_type; $entity->addSelectionCondition( [ 'id' => $plugin_id, 'id' => 'entity_bundle:' . $entity_type, 'bundles' => $bundles, 'negate' => FALSE, 'context_mapping' => [ Loading src/Plugin/migrate/source/PathautoPattern.php +1 −1 Original line number Diff line number Diff line Loading @@ -117,7 +117,7 @@ class PathautoPattern extends DrupalSqlBase { $row->setSourceProperty('pattern', unserialize($row->getSourceProperty('value'))); $selection_criteria = [ 'id' => ($entity_type == 'node') ? 'node_type' : 'entity_bundle:' . $entity_type, 'id' => 'entity_bundle:' . $entity_type, 'bundles' => [$bundle => $bundle], 'negate' => FALSE, 'context_mapping' => [$entity_type => $entity_type], Loading tests/src/Functional/PathautoTestHelperTrait.php +1 −3 Original line number Diff line number Diff line Loading @@ -56,11 +56,9 @@ trait PathautoTestHelperTrait { * The bundle. */ protected function addBundleCondition(PathautoPatternInterface $pattern, $entity_type, $bundle) { $plugin_id = $entity_type == 'node' ? 'node_type' : 'entity_bundle:' . $entity_type; $pattern->addSelectionCondition( [ 'id' => $plugin_id, 'id' => 'entity_bundle:' . $entity_type, 'bundles' => [ $bundle => $bundle, ], Loading Loading
pathauto.install +23 −0 Original line number Diff line number Diff line Loading @@ -297,3 +297,26 @@ function pathauto_update_8107() { ->set('safe_tokens', $safe_tokens) ->save(); } /** * Update node type conditions from node_type to entity_bundle. */ function pathauto_update_8108() { // Load all pattern configuration entities. foreach (\Drupal::configFactory()->listAll('pathauto.pattern.') as $pattern_config_name) { $pattern_config = \Drupal::configFactory()->getEditable($pattern_config_name); // Loop patterns and swap the node_type plugin by the entity_bundle:node // plugin. if ($pattern_config->get('type') === 'canonical_entities:node') { $selection_criteria = $pattern_config->get('selection_criteria'); foreach ($selection_criteria as $uuid => $condition) { if ($condition['id'] === 'node_type') { $pattern_config->set("selection_criteria.$uuid.id", 'entity_bundle:node'); $pattern_config->save(); break; } } } } }
src/Form/PatternEditForm.php +2 −3 Original line number Diff line number Diff line Loading @@ -223,17 +223,16 @@ class PatternEditForm extends EntityForm { $entity_type = $alias_type->getDerivativeId(); // First, remove bundle and language conditions. foreach ($entity->getSelectionConditions() as $condition_id => $condition) { if (in_array($condition->getPluginId(), ['entity_bundle:' . $entity_type, 'node_type', 'language'])) { if (in_array($condition->getPluginId(), ['entity_bundle:' . $entity_type, 'language'])) { $entity->removeSelectionCondition($condition_id); } } if ($bundles = array_filter((array) $form_state->getValue('bundles'))) { $default_weight -= 5; $plugin_id = $entity_type == 'node' ? 'node_type' : 'entity_bundle:' . $entity_type; $entity->addSelectionCondition( [ 'id' => $plugin_id, 'id' => 'entity_bundle:' . $entity_type, 'bundles' => $bundles, 'negate' => FALSE, 'context_mapping' => [ Loading
src/Plugin/migrate/source/PathautoPattern.php +1 −1 Original line number Diff line number Diff line Loading @@ -117,7 +117,7 @@ class PathautoPattern extends DrupalSqlBase { $row->setSourceProperty('pattern', unserialize($row->getSourceProperty('value'))); $selection_criteria = [ 'id' => ($entity_type == 'node') ? 'node_type' : 'entity_bundle:' . $entity_type, 'id' => 'entity_bundle:' . $entity_type, 'bundles' => [$bundle => $bundle], 'negate' => FALSE, 'context_mapping' => [$entity_type => $entity_type], Loading
tests/src/Functional/PathautoTestHelperTrait.php +1 −3 Original line number Diff line number Diff line Loading @@ -56,11 +56,9 @@ trait PathautoTestHelperTrait { * The bundle. */ protected function addBundleCondition(PathautoPatternInterface $pattern, $entity_type, $bundle) { $plugin_id = $entity_type == 'node' ? 'node_type' : 'entity_bundle:' . $entity_type; $pattern->addSelectionCondition( [ 'id' => $plugin_id, 'id' => 'entity_bundle:' . $entity_type, 'bundles' => [ $bundle => $bundle, ], Loading