/**
  * Tests whether the Panels display config schema is valid.
  */
 public function testPanelsConfigSchema()
 {
     $panels_display = $this->panelsManager->createDisplay();
     // Add a block.
     $panels_display->addBlock(['id' => 'entity_view:node', 'label' => 'View the node', 'provider' => 'page_manager', 'label_display' => 'visible', 'view_mode' => 'default', 'region' => 'middle']);
     $config = $this->panelsManager->exportDisplay($panels_display);
     // This will throw an exception if it doesn't validate.
     $new_panels_display = $this->panelsManager->importDisplay($config, TRUE);
     $this->assertEqual($panels_display->getConfiguration(), $new_panels_display->getConfiguration());
 }
 /**
  * Get the Panels display out of an the entity view display
  *
  * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity.
  * @param \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display
  *   The display.
  * @param $view_mode
  *   The view mode.
  *
  * @return \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant
  *   The Panels display.
  */
 protected function getPanelsDisplay(EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode)
 {
     // First, check if the entity has the panelizer field.
     if (isset($entity->field_panelizer)) {
         $values = [];
         foreach ($entity->field_panelizer as $item) {
             $values[$item->view_mode] = $item->panels_display;
         }
         if (isset($values[$view_mode])) {
             return $this->panelsManager->importDisplay($values[$view_mode]);
         }
     }
     // Otherwise, get the correct default off the entity view display.
     $displays = $display->getThirdPartySetting('panelizer', 'displays', []);
     if (!empty($displays['default'])) {
         $displays['default'] = $this->panelsManager->importDisplay($displays['default']);
     } else {
         $displays['default'] = $this->getPanelizerPlugin()->getDefaultDisplay($display, $entity->bundle(), $view_mode);
     }
     return $displays['default'];
 }