You are here

public function Panelizer::getPanelizerSettings in Panelizer 8.4

Same name and namespace in other branches
  1. 8.5 src/Panelizer.php \Drupal\panelizer\Panelizer::getPanelizerSettings()
  2. 8.3 src/Panelizer.php \Drupal\panelizer\Panelizer::getPanelizerSettings()

Get the Panelizer settings for an entity type, bundle and view mode.

Parameters

string $entity_type_id: The entity type id.

string $bundle: The bundle.

string $view_mode: The view mode.

\Drupal\Core\Entity\Display\EntityViewDisplayInterface|NULL $display: If the caller already has the correct display, it can optionally be passed in here so the Panelizer service doesn't have to look it up; otherwise, this argument can bo omitted.

Return value

array An associative array with the following keys:

  • enable (bool): Whether or not this view mode is panelized.
  • field (bool): Whether or not the field is present.

Overrides PanelizerInterface::getPanelizerSettings

3 calls to Panelizer::getPanelizerSettings()
Panelizer::getPanelsDisplay in src/Panelizer.php
Gets the Panels display for a given entity and view mode.
Panelizer::hasEntityPermission in src/Panelizer.php
Checks if a user has permission to perform an operation on an entity.
Panelizer::setPanelsDisplay in src/Panelizer.php
Sets the Panels display for a given entity and view mode.

File

src/Panelizer.php, line 469

Class

Panelizer
The Panelizer service.

Namespace

Drupal\panelizer

Code

public function getPanelizerSettings($entity_type_id, $bundle, $view_mode, EntityViewDisplayInterface $display = NULL) {
  if (!$display) {
    $display = $this
      ->getEntityViewDisplay($entity_type_id, $bundle, $view_mode);
  }
  $settings = [
    'enable' => $this
      ->isPanelized($entity_type_id, $bundle, $view_mode, $display),
    'custom' => $display
      ->getThirdPartySetting('panelizer', 'custom', FALSE),
    'allow' => $display
      ->getThirdPartySetting('panelizer', 'allow', FALSE),
    'default' => $display
      ->getThirdPartySetting('panelizer', 'default', 'default'),
  ];

  // Make sure that the Panelizer field actually exists.
  if ($settings['custom']) {
    $fields = $this->entityFieldManager
      ->getFieldDefinitions($entity_type_id, $bundle);
    $settings['custom'] = isset($fields['panelizer']) && $fields['panelizer']
      ->getType() == 'panelizer';
  }
  return $settings;
}