protected function FlowForm::renderEntityType in CMS Content Sync 8
Same name and namespace in other branches
- 2.1.x src/Form/FlowForm.php \Drupal\cms_content_sync\Form\FlowForm::renderEntityType()
- 2.0.x src/Form/FlowForm.php \Drupal\cms_content_sync\Form\FlowForm::renderEntityType()
Render all bundles for the given entity type. Displayed in vertical tabs from the parent form.
Parameters
$type_key:
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
1 call to FlowForm::renderEntityType()
- FlowForm::form in src/
Form/ FlowForm.php - Gets the actual form array to be built.
File
- src/
Form/ FlowForm.php, line 797
Class
- FlowForm
- Form handler for the Flow add and edit forms.
Namespace
Drupal\cms_content_sync\FormCode
protected function renderEntityType(array &$entity_type_list, FormStateInterface $form_state, $type_key) {
$entity_types = $this->bundleInfoService
->getAllBundleInfo();
$entity_type = $entity_types[$type_key];
ksort($entity_type);
$current_values = $this
->getCurrentValues($form_state);
$bundles_rendered = [];
$open_all = $this
->shouldOpenAll($form_state);
foreach ($entity_type as $entity_bundle_name => $entity_bundle) {
$info = EntityHandlerPluginManager::getEntityTypeInfo($type_key, $entity_bundle_name);
if (!empty($info['no_entity_type_handler']) || !empty($info['required_field_not_supported'])) {
continue;
}
$bundle_id = $type_key . '-' . $entity_bundle_name;
$edit = $form_state
->getValue([
$type_key,
$entity_bundle_name,
'edit',
]);
if ('fields' === $this->triggeredAction && $this->triggeringType === $type_key && $this->triggeringBundle === $entity_bundle_name) {
$edit = '1';
}
if ($open_all && isset($current_values['sync_entities'][$bundle_id]['handler']) && 'ignore' !== $current_values['sync_entities'][$bundle_id]['handler']) {
$edit = '1';
}
// If the version changed, we need to expand this so the new field is added.
if (isset($current_values['sync_entities'][$bundle_id]['version']) && 'ignore' !== $current_values['sync_entities'][$bundle_id]['handler']) {
$version = Flow::getEntityTypeVersion($type_key, $entity_bundle_name);
if ($current_values['sync_entities'][$bundle_id]['version'] !== $version) {
$edit = '1';
}
}
if ('1' == $edit) {
$bundle_info = $this
->renderEnabledBundle($form_state, $type_key, $entity_bundle_name);
}
elseif (!isset($current_values['sync_entities'][$bundle_id]['handler']) || 'ignore' === $current_values['sync_entities'][$bundle_id]['handler']) {
$bundle_info = $this
->renderDisabledBundle($form_state, $type_key, $entity_bundle_name);
}
else {
$bundle_info = $this
->renderBundleSummary($form_state, $type_key, $entity_bundle_name);
}
$bundles_rendered[$entity_bundle_name] = $bundle_info;
}
if (empty($bundles_rendered)) {
return;
}
$bundles_rendered = array_merge($bundles_rendered, [
'#type' => 'details',
'#title' => str_replace('_', ' ', ucfirst($type_key)),
'#group' => 'entity_type_list',
]);
// Add information text for paragraphs that a specific commit is required.
if ('paragraph' == $type_key) {
$bundles_rendered['#description'] = 'If you want to select the pool per paragraph (Push to Pools set to "Allow"), Paragraphs version >= <strong>8.x-1.3</strong> is required.<br><br>';
}
$entity_type_list[$type_key] = $bundles_rendered;
}