public function BlockVisibilityGroupController::selectCondition in Block Visibility Groups 8
Presents a list of conditions to add to the block_visibility_group entity.
Parameters
\Drupal\block_visibility_groups\Entity\BlockVisibilityGroup $block_visibility_group: The block_visibility_group entity.
string $redirect: The redirect option.
Return value
array The condition selection page.
1 string reference to 'BlockVisibilityGroupController::selectCondition'
File
- src/
Controller/ BlockVisibilityGroupController.php, line 66
Class
- BlockVisibilityGroupController
- Class BlockVisibilityGroupController.
Namespace
Drupal\block_visibility_groups\ControllerCode
public function selectCondition(BlockVisibilityGroup $block_visibility_group, $redirect) {
$build = [
'#theme' => 'links',
'#links' => [],
];
$available_plugins = $this->conditionManager
->getDefinitions();
// @todo Should nesting Conditions be allowed
unset($available_plugins['condition_group']);
foreach ($available_plugins as $condition_id => $condition) {
$build['#links'][$condition_id] = [
'title' => $condition['label'],
'url' => Url::fromRoute('block_visibility_groups.condition_add', [
'block_visibility_group' => $block_visibility_group
->id(),
'condition_id' => $condition_id,
'redirect' => $redirect,
]),
'attributes' => [
'class' => [
'use-ajax',
],
'data-dialog-type' => 'modal',
'data-dialog-options' => Json::encode([
'width' => 'auto',
]),
],
];
}
return $build;
}