Skip to content

Commit

Permalink
Handle non-registered layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
tonystar committed Jun 11, 2017
1 parent d13d8f0 commit 2dc78b5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bricks.module
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ function bricks_theme($existing, $type, $theme, $path) {
function bricks_entity_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
if ($entity->bundle() == 'layout' && !empty($build['#layout']) && !isset($build['_bricks_layout']) && \Drupal::service('module_handler')->moduleExists('layout_discovery')) {
$layoutPluginManager = \Drupal::service('plugin.manager.core.layout');
if (!$layoutPluginManager->getDefinition($build['#layout'], FALSE)) {
drupal_set_message(t('Layout `%layout_id` is unknown.', ['%layout_id' => $build['#layout']]), 'warning');
return;
}

// Provide any configuration to the layout plugin if necessary.
$layoutInstance = $layoutPluginManager->createInstance($build['#layout']);
Expand Down

0 comments on commit 2dc78b5

Please sign in to comment.