PageAddWizard.php in Page Manager 8.4
File
page_manager_ui/src/Wizard/PageAddWizard.php
View source
<?php
namespace Drupal\page_manager_ui\Wizard;
use Drupal\Core\Display\ContextAwareVariantInterface;
use Drupal\ctools\Plugin\PluginWizardInterface;
use Drupal\page_manager_ui\Form\PageVariantContextsForm;
use Drupal\page_manager_ui\Form\PageVariantConfigureForm;
use Drupal\page_manager_ui\Form\PageVariantSelectionForm;
class PageAddWizard extends PageWizardBase {
public function getRouteName() {
return 'entity.page.add_step_form';
}
public function getOperations($cached_values) {
$operations = parent::getOperations($cached_values);
$operations['contexts'] = [
'title' => $this
->t('Contexts'),
'form' => PageVariantContextsForm::class,
];
$operations['selection'] = [
'title' => $this
->t('Selection criteria'),
'form' => PageVariantSelectionForm::class,
];
$operations['display_variant'] = [
'title' => $this
->t('Configure variant'),
'form' => PageVariantConfigureForm::class,
];
if (isset($cached_values['page']) && !$cached_values['page']
->getParameterNames()) {
unset($operations['parameters']);
}
$optional_steps = [
'access',
'contexts',
'selection',
];
foreach ($optional_steps as $step_name) {
if (empty($cached_values['wizard_options'][$step_name])) {
unset($operations[$step_name]);
}
}
if (!empty($cached_values['page_variant'])) {
$page_variant = $cached_values['page_variant'];
$variant_plugin = $page_variant
->getVariantPlugin();
if ($variant_plugin instanceof PluginWizardInterface) {
if ($variant_plugin instanceof ContextAwareVariantInterface) {
$variant_plugin
->setContexts($page_variant
->getContexts());
}
$cached_values['plugin'] = $variant_plugin;
foreach ($variant_plugin
->getWizardOperations($cached_values) as $name => $operation) {
$operation['values']['plugin'] = $variant_plugin;
$operation['submit'][] = '::submitVariantStep';
$operations[$name] = $operation;
}
}
}
return $operations;
}
}