page_layouts-1.0.1/page_layouts.theme.inc
page_layouts.theme.inc
<?php
/**
* @file
* Theming for page layouts views.
*/
/**
* Implements hook_preprocess_HOOK().
*/
function template_preprocess_views_view_page_layouts(&$variables) {
$options = $variables['view']->style_plugin->options;
$content = [];
foreach ($variables['view']->result as $key => $result) {
$pageLayoutsLayout = \Drupal::entityTypeManager()->getStorage('page_layouts_layout')->load($result->id);
$plugin_type = \Drupal::service('plugin.manager.layouts');
$plugin_definitions = $plugin_type->getDefinitions();
foreach ($plugin_definitions as $plugin_id => $definition) {
if ($plugin_id == $pageLayoutsLayout->layout->value) {
$content[] = $plugin_type->createInstance($plugin_id)->getLayout($pageLayoutsLayout);
}
}
}
$options['content'] = $content;
$variables['options'] = $options;
}
