You are here

public function PanelsDisplayVariant::getWizardOperations in Panels 8.3

Same name and namespace in other branches
  1. 8.4 src/Plugin/DisplayVariant/PanelsDisplayVariant.php \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant::getWizardOperations()

Retrieve a list of FormInterface classes by their step key in the wizard.

Parameters

mixed $cached_values: The cached values used in the wizard. The plugin we're editing will always be assigned to the 'plugin' key.

Return value

array An associative array keyed on the step name with an array value with the following keys:

  • title (string): Human-readable title of the step.
  • form (string): Fully-qualified class name of the form for this step.

Overrides PluginWizardInterface::getWizardOperations

File

src/Plugin/DisplayVariant/PanelsDisplayVariant.php, line 409

Class

PanelsDisplayVariant
Provides a display variant that simply contains blocks.

Namespace

Drupal\panels\Plugin\DisplayVariant

Code

public function getWizardOperations($cached_values) {
  $operations = [];
  $operations['layout'] = [
    'title' => $this
      ->t('Layout'),
    'form' => LayoutPluginSelector::class,
  ];
  if (!empty($this
    ->getConfiguration()['layout']) && $cached_values['plugin']
    ->getLayout() instanceof PluginFormInterface) {

    /** @var \Drupal\layout_plugin\Plugin\Layout\LayoutInterface $layout */
    if (empty($cached_values['layout_change']['new_layout'])) {
      $layout = $cached_values['plugin']
        ->getLayout();
      $r = new \ReflectionClass(get_class($layout));
    }
    else {
      $layout_definition = \Drupal::service('plugin.manager.layout_plugin')
        ->getDefinition($cached_values['layout_change']['new_layout']);
      $r = new \ReflectionClass($layout_definition['class']);
    }

    // If the layout uses the LayoutBase::buildConfigurationForm() method we
    // know it is not truly UI configurable, so there's no reason to include
    // the wizard step for displaying that UI.
    $method = $r
      ->getMethod('buildConfigurationForm');
    if ($method->class != 'Drupal\\layout_plugin\\Plugin\\Layout\\LayoutBase') {
      $operations['settings'] = [
        'title' => $this
          ->t('Layout Settings'),
        'form' => LayoutChangeSettings::class,
      ];
    }
  }
  if (!empty($cached_values['layout_change']['old_layout'])) {
    $operations['regions'] = [
      'title' => $this
        ->t('Layout Regions'),
      'form' => LayoutChangeRegions::class,
    ];
  }

  /** @var \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $plugin */
  $plugin = $cached_values['plugin'];
  $builder = $plugin
    ->getBuilder();
  if ($builder instanceof PluginWizardInterface) {
    $operations = array_merge($operations, $builder
      ->getWizardOperations($cached_values));
  }
  return $operations;
}