function pathauto_update_8102 in Pathauto 8
Update node type conditions from entity_bundle to node_type.
File
- ./
pathauto.install, line 218 - Install, update, and uninstall functions for Pathauto.
Code
function pathauto_update_8102() {
// 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 entity_bundle:node plugin by the node_type
// 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'] == 'entity_bundle:node') {
$selection_criteria[$uuid]['id'] = 'node_type';
$pattern_config
->set('selection_criteria', $selection_criteria);
$pattern_config
->save();
break;
}
}
}
}
}