You are here

public function PanelizerEditWizard::initValues in Panelizer 8.3

Same name and namespace in other branches
  1. 8.5 src/Wizard/PanelizerEditWizard.php \Drupal\panelizer\Wizard\PanelizerEditWizard::initValues()
  2. 8.4 src/Wizard/PanelizerEditWizard.php \Drupal\panelizer\Wizard\PanelizerEditWizard::initValues()

Initialize wizard values.

Return mixed.

Overrides PanelizerWizardBase::initValues

File

src/Wizard/PanelizerEditWizard.php, line 22

Class

PanelizerEditWizard

Namespace

Drupal\panelizer\Wizard

Code

public function initValues() {
  $cached_values = parent::initValues();

  // Load data in to values to be cached and managed by the
  // wizard until the user clicks on Save or Cancel.
  $cached_values['id'] = $this
    ->getMachineName();
  list($entity_type, $bundle, $view_mode, $display_id) = explode('__', $this
    ->getMachineName());
  $panelizer = \Drupal::service('panelizer');

  // Load the panels display variant.

  /** @var \Drupal\panelizer\Panelizer $panelizer */

  // @todo this $display_id looks all wrong to me since it's the name and view_mode.
  $variant_plugin = $panelizer
    ->getDefaultPanelsDisplay($display_id, $entity_type, $bundle, $view_mode);
  $cached_values['plugin'] = $variant_plugin;
  $cached_values['label'] = $cached_values['plugin']
    ->getConfiguration()['label'];
  $display = $panelizer
    ->getEntityViewDisplay($entity_type, $bundle, $view_mode);
  $config = $display
    ->getThirdPartySetting('panelizer', 'displays', []);
  if (!empty($config[$display_id]['static_context'])) {
    $cached_values['contexts'] = $config[$display_id]['static_context'];
  }
  return $cached_values;
}