public function FlowControllerPerBundle::updateEntityTypeBundleVersion in CMS Content Sync 2.1.x
Update the version of an entity type bundle within a flow configuration.
Parameters
$entity_type:
$bundle:
Return value
bool
Throws
\Exception
1 call to FlowControllerPerBundle::updateEntityTypeBundleVersion()
- FlowControllerPerBundle::updateEntityTypeVersions in src/
Controller/ FlowControllerPerBundle.php - Cache the current version per entity type.
File
- src/
Controller/ FlowControllerPerBundle.php, line 292
Class
Namespace
Drupal\cms_content_sync\ControllerCode
public function updateEntityTypeBundleVersion($entity_type, $bundle) {
// Get active version.
$active_version = Flow::getEntityTypeVersion($entity_type, $bundle);
// Get version from config.
$flow_config = \Drupal::service('config.factory')
->getEditable('cms_content_sync.flow.' . $this->flow
->id());
$config_version = $flow_config
->get('per_bundle_settings.' . $entity_type . '.' . $bundle . '.settings.version');
// Only update if required.
if ($active_version != $config_version) {
$default = Flow::getDefaultFieldConfigForEntityType($entity_type, $bundle, $this);
$flow_config
->set('per_bundle_settings.' . $entity_type . '.' . $bundle . '.properties', $default);
$flow_config
->set('per_bundle_settings.' . $entity_type . '.' . $bundle . '.settings.version', $active_version);
$flow_config
->save();
\Drupal::messenger()
->addMessage('Content Sync - Flow: ' . $this->flow
->label() . ' has been updated.');
return true;
}
}