function cms_content_sync_update_8021 in CMS Content Sync 2.1.x
Implements hook_update_N();.
Add the REST interface to access an individual entity.
File
- ./
cms_content_sync.install, line 271 - Install file for cms_content_sync.
Code
function cms_content_sync_update_8021() {
foreach (Flow::getAll(TRUE) as $flow) {
if ($flow->sync_entities) {
// Add properties "variant", "type", "per_bundle_settings" and "simple_settings" to Flows.
$config_factory = \Drupal::configFactory();
$config = $config_factory
->getEditable('cms_content_sync.flow.' . $flow->id);
// Set variant to the old default of per-bundle.
$config
->set('variant', Flow::VARIANT_PER_BUNDLE);
$config
->set('type', $flow
->getController()
->getType());
$config
->set('per_bundle_settings', []);
// Migrate the old "sync_entities" property to the new "per_bundle_settings" property.
foreach ($flow->sync_entities as $key => $settings) {
$parts = explode('-', $key);
if (count($parts) > 2) {
list($type, $bundle, $property) = $parts;
$config
->set('per_bundle_settings' . '.' . $type . '.' . $bundle . '.properties.' . $property, $settings);
}
else {
list($type, $bundle) = $parts;
$config
->set('per_bundle_settings' . '.' . $type . '.' . $bundle . '.settings', $settings);
}
}
// Delete deprecated property as it's no longer used.
$config
->set('sync_entities', NULL);
// Save migrated Flow.
$config
->save(TRUE);
}
}
return 'Added new properties to Flows.';
}