public function FlowListBuilder::render in CMS Content Sync 2.1.x
Same name and namespace in other branches
- 8 src/Controller/FlowListBuilder.php \Drupal\cms_content_sync\Controller\FlowListBuilder::render()
- 2.0.x src/Controller/FlowListBuilder.php \Drupal\cms_content_sync\Controller\FlowListBuilder::render()
Builds the entity listing as renderable array for table.html.twig.
@todo Add a link to add a new item to the #empty text.
Overrides EntityListBuilder::render
File
- src/
Controller/ FlowListBuilder.php, line 93
Class
- FlowListBuilder
- Provides a listing of Flow.
Namespace
Drupal\cms_content_sync\ControllerCode
public function render() {
$build = parent::render();
$status_overwritten = false;
$version_mismatch = false;
$rows = $build['table']['#rows'];
// Check if the site has already been registered.
$settings = ContentSyncSettings::getInstance();
if (Migration::alwaysUseV2() && !$settings
->getSiteUuid()) {
$link = Link::fromTextAndUrl($this
->t('registered'), Url::fromRoute('cms_content_sync.site'))
->toString();
$this
->messenger()
->addWarning($this
->t('The site needs to be @link before creating a flow.', [
'@link' => $link,
]));
}
$build['advanced'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Advanced'),
'add_form_advanced' => [
'#type' => 'link',
'#title' => $this
->t('Add advanced Flow (not recommended)'),
'#url' => Url::fromRoute('entity.cms_content_sync_flow.add_form_advanced'),
'#attributes' => [
'class' => [
'button',
'button-action',
'button--small',
],
],
],
'copy_remote' => [
'#type' => 'link',
'#title' => $this
->t('Copy advanced Flow from other site'),
'#url' => Url::fromRoute('entity.cms_content_sync_flow.copy_remote'),
'#attributes' => [
'class' => [
'button',
'button-action',
'button--small',
],
],
],
'assignment_form' => [
'#type' => 'link',
'#title' => $this
->t('Change Pool assignment of advanced Flow'),
'#url' => Url::fromRoute('cms_content_sync.pool_assignment_form'),
'#attributes' => [
'class' => [
'button',
'button-action',
'button--small',
],
],
],
];
if (!empty($rows)) {
foreach ($rows as $row) {
if (strpos($row['status']
->__toString(), 'Overwritten')) {
$status_overwritten = true;
}
if (strpos($row['status']
->__toString(), 'Requires export')) {
$version_mismatch = true;
}
}
if ($status_overwritten) {
$build['explanation_overwritten'] = [
'#markup' => '<i>' . $this
->t('Overwritten: The status of this flow has been overwritten in a settings file.') . '</i><br>',
];
}
if ($version_mismatch) {
$always_v2 = Migration::alwaysUseV2();
$message = $this
->t('Requires export: Entity types were changed, so the Flow must be exported again.');
$build['explanation_version_mismatch'] = [
'#markup' => '<i>' . $message . '</i>',
];
}
$build['hints'] = [
'#markup' => '<h3>' . $this
->t('Hints') . '</h3>' . $this
->t('You can enable / disable Flows using your settings.php file:'),
];
$overwrite_status = '<li>' . $this
->t('Status: <i>@overwrite_status</i>', [
'@overwrite_status' => '$config["cms_content_sync.flow.<flow_machine_name>"]["status"] = FALSE;',
]) . '</li>';
$build['hints_examples'] = [
'#markup' => '<ul>' . $overwrite_status . '</ul>',
];
}
return $build;
}