protected function FlowForm::renderBundleSummary 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::renderBundleSummary()
- 2.0.x src/Form/FlowForm.php \Drupal\cms_content_sync\Form\FlowForm::renderBundleSummary()
Bundle has settings already, but the user is editing the Flow so by default we don't show all bundle edit forms as open but hide them all to save space and make the form faster. The user can then click Edit to change settings.
Parameters
$type_key:
$entity_bundle_name:
Return value
array
1 call to FlowForm::renderBundleSummary()
- FlowForm::renderEntityType in src/
Form/ FlowForm.php - Render all bundles for the given entity type. Displayed in vertical tabs from the parent form.
File
- src/
Form/ FlowForm.php, line 1961
Class
- FlowForm
- Form handler for the Flow add and edit forms.
Namespace
Drupal\cms_content_sync\FormCode
protected function renderBundleSummary(FormStateInterface $form_state, $type_key, $entity_bundle_name) {
$entity_types = $this->bundleInfoService
->getAllBundleInfo();
$entity_bundle = $entity_types[$type_key][$entity_bundle_name];
$bundle_id = $type_key . '-' . $entity_bundle_name;
$settings_id = 'sync-entities-' . $bundle_id;
$current_values = $this
->getCurrentValues($form_state);
$push_option_labels = [
PushIntent::PUSH_DISABLED => $this
->t('Disabled')
->render(),
PushIntent::PUSH_AUTOMATICALLY => $this
->t('All')
->render(),
PushIntent::PUSH_AS_DEPENDENCY => $this
->t('Referenced')
->render(),
PushIntent::PUSH_MANUALLY => $this
->t('Manually')
->render(),
];
$pull_option_labels = [
PullIntent::PULL_DISABLED => $this
->t('Disabled')
->render(),
PullIntent::PULL_AUTOMATICALLY => $this
->t('All')
->render(),
PullIntent::PULL_AS_DEPENDENCY => $this
->t('Referenced')
->render(),
PullIntent::PULL_MANUALLY => $this
->t('Manually')
->render(),
];
$bundle_info = [
'#prefix' => '<div id="' . $settings_id . '">',
'#suffix' => '</div>',
'#markup' => '<h2>' . $this
->t('@bundle (@machine_name)', [
'@bundle' => $entity_bundle['label'],
'@machine_name' => $entity_bundle_name,
]) . '</h2>',
];
$entity_handlers = $this->entityPluginManager
->getHandlerOptions($type_key, $entity_bundle_name, true);
if (empty($entity_handlers)) {
$bundle_info['#markup'] .= '<p>This entity type / bundle is not supported.</p>';
}
else {
$does_push = isset($current_values['sync_entities'][$bundle_id]['export']) && PushIntent::PUSH_DISABLED !== $current_values['sync_entities'][$bundle_id]['export'];
$does_pull = isset($current_values['sync_entities'][$bundle_id]['import']) && PullIntent::PULL_DISABLED !== $current_values['sync_entities'][$bundle_id]['import'];
$push_label = $does_push ? 'Push ' . $push_option_labels[$current_values['sync_entities'][$bundle_id]['export']] : null;
$pull_label = $does_pull ? 'Pull ' . $pull_option_labels[$current_values['sync_entities'][$bundle_id]['import']] : null;
$bundle_info['summary'] = [
'#markup' => $push_label ? $pull_label ? $push_label . ' and ' . $pull_label : $push_label : ($does_pull ? $pull_label : 'Not configured'),
];
$title = $this
->t('Edit');
$bundle_info['edit'] = [
'#type' => 'hidden',
'#value' => '0',
];
$bundle_info['enable'] = [
'#type' => 'submit',
'#submit' => [
'::enableBundle',
],
'#value' => $title,
'#name' => 'enable-' . $type_key . '-' . $entity_bundle_name,
'#entity_type' => $type_key,
'#bundle' => $entity_bundle_name,
'#limit_validation_errors' => [],
'#ajax' => [
'callback' => '::ajaxReturn',
'wrapper' => $settings_id,
'method' => 'replace',
'effect' => 'fade',
'progress' => [
'type' => 'throbber',
'message' => 'loading settings...',
],
],
];
}
return $bundle_info;
}