You are here

public function PanelizerNode::getDefaultDisplay in Panelizer 8.5

Same name and namespace in other branches
  1. 8.3 src/Plugin/PanelizerEntity/PanelizerNode.php \Drupal\panelizer\Plugin\PanelizerEntity\PanelizerNode::getDefaultDisplay()
  2. 8.4 src/Plugin/PanelizerEntity/PanelizerNode.php \Drupal\panelizer\Plugin\PanelizerEntity\PanelizerNode::getDefaultDisplay()

Creates a default Panels display from the core Entity display.

As much as possible, this should attempt to make the settings on the Panels display match the existing core settings, so that ideally the user doesn't notice any change upon Panelizing an entity's view mode.

Parameters

\Drupal\Core\Entity\Display\EntityViewDisplayInterface $display: The entity view display holding the display options configured for the entity components.

string $bundle: The bundle to panelize.

string $view_mode: The view mode to panelize.

Return value

\Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant

Overrides PanelizerEntityBase::getDefaultDisplay

File

src/Plugin/PanelizerEntity/PanelizerNode.php, line 20

Class

PanelizerNode
Panelizer entity plugin for integrating with nodes.

Namespace

Drupal\panelizer\Plugin\PanelizerEntity

Code

public function getDefaultDisplay(EntityViewDisplayInterface $display, $bundle, $view_mode) {
  $panels_display = parent::getDefaultDisplay($display, $bundle, $view_mode)
    ->setPageTitle('[node:title]');

  // Remove the 'title' block because it's covered already.
  foreach ($panels_display
    ->getRegionAssignments() as $region => $blocks) {

    /** @var \Drupal\Core\Block\BlockPluginInterface[] $blocks */
    foreach ($blocks as $block_id => $block) {
      if ($block
        ->getPluginId() == 'entity_field:node:title') {
        $panels_display
          ->removeBlock($block_id);
      }
    }
  }
  if ($display
    ->getComponent('links')) {

    // @todo: add block for node links.
  }
  if ($display
    ->getComponent('langcode')) {

    // @todo: add block for node language.
  }
  return $panels_display;
}