Skip to content

Instantly share code, notes, and snippets.

@sonnykt
Last active August 29, 2024 03:37
Show Gist options
  • Save sonnykt/a7072b512d826bce3be598d1f7e013df to your computer and use it in GitHub Desktop.
Save sonnykt/a7072b512d826bce3be598d1f7e013df to your computer and use it in GitHub Desktop.
Drupal 10 - Check node view displays using Panelizer
use \Drupal\node\Entity\NodeType;

$panelizer = [];
$repo = \Drupal::service('entity_display.repository');

$types = NodeType::loadMultiple();
foreach (array_keys($types) as $node_type) {
  $viewmode_options = $repo->getViewModeOptionsByBundle('node', $node_type);
  foreach (array_keys($viewmode_options) as $viewmode_option) {
    if ($repo->getViewDisplay('node', $node_type, $viewmode_option)->getThirdPartySetting('panelizer', 'enable') === TRUE) {
      $panelizer[] = $node_type . '/' . $viewmode_option;
    }
  }
}

echo 'panelizer: ', $panelizer ? implode(',', $panelizer) : 'no', PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment