You are here

function paragraphs_previewer_preprocess_page__paragraphs_previewer in Paragraphs Previewer 8

Implements hook_preprocess_page().

File

./paragraphs_previewer.module, line 39
Provides a rendered preview of a paragraphs item on an entity form.

Code

function paragraphs_previewer_preprocess_page__paragraphs_previewer(&$variables) {
  if (!empty($variables['page'])) {
    $page_keys = Element::children($variables['page']);
    foreach ($page_keys as $page_key) {
      if ($page_key != 'content') {
        unset($variables['page'][$page_key]);
      }
      elseif ($content_keys = Element::children($variables['page'][$page_key])) {
        foreach ($content_keys as $content_key) {
          if (isset($variables['page'][$page_key][$content_key]['#base_plugin_id']) && $variables['page'][$page_key][$content_key]['#base_plugin_id'] != 'system_main_block') {
            unset($variables['page'][$page_key][$content_key]);
          }
        }
      }
    }
  }
}