+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -u b/core/modules/layout/layout.module b/core/modules/layout/layout.module --- b/core/modules/layout/layout.module +++ b/core/modules/layout/layout.module @@ -2,26 +2,40 @@ -function layout_manager() { - return drupal_container()->get('plugin.manager.layout'); -} - -function layout_init() { - drupal_set_message('
' . var_export(layout_manager()->getDefinition('default_layout:layout__onecol'), TRUE) . '');
+/**
+ * Implements hook_page_build().
+ */
+function layout_page_build(&$page) {
+ $page['#pre_render'][] = 'layout_page_pre_render';
}
/**
- * Implements hook_theme().
+ * #pre_render callback for $page.
+ *
+ * @todo Eventually, Drupal routing will be improved so as to replace
+ * drupal_render_page() (which builds blocks from bottom-up, even if the
+ * layout instance is not configured to render them) with a top-down
+ * subrequest workflow. For now, however, we integrate with the
+ * drupal_render_page() flow, but replace theme('page') with
+ * $layout->renderLayout().
*/
-function layout_theme($existing, $type, $theme, $path) {
- foreach (layout_manager()->getDefinitions() as $name => $layout) {
- $variables = array('css_id' => NULL, 'renderer' => NULL);
- foreach (array_keys($layout['regions']) as $key) {
- $variables[$key] = NULL;
+function layout_page_pre_render($page) {
+ global $theme;
+
+ // @todo Don't hard-code the bartik__bartik layout; let that be administrator
+ // configurable.
+ if ($theme == 'bartik') {
+ $layout_manager = drupal_container()->get('plugin.manager.layout');
+ $layout = $layout_manager->createInstance('default_layout:bartik__bartik', array());
+ $regions = array();
+ foreach ($layout->getRegions() as $region => $title) {
+ $regions[$region] = isset($page[$region]) ? drupal_render($page[$region]) : NULL;
}
- $theme[$layout['theme']] = array(
- 'variables' => $variables,
- 'path' => $layout['path'],
- 'template' => str_replace('_', '-', $layout['theme']),
- );
+ $output = $layout->renderLayout(FALSE, $regions);
+
+ // When drupal_render_page() goes away, so will this, but in the meantime,
+ // this is how we replace page.tpl.php with the layout.
+ $page['#children'] = $output;
+ $page['#theme'] = NULL;
}
- return $theme;
+
+ return $page;
}
diff -u b/core/modules/layout/lib/Drupal/layout/Plugin/Derivative/Layout.php b/core/modules/layout/lib/Drupal/layout/Plugin/Derivative/Layout.php
--- b/core/modules/layout/lib/Drupal/layout/Plugin/Derivative/Layout.php
+++ b/core/modules/layout/lib/Drupal/layout/Plugin/Derivative/Layout.php
@@ -58,7 +58,7 @@
elseif ($fileinfo->isFile() && $fileinfo->getExtension() == 'yml') {
$directory = new FileStorage($fileinfo->getPath());
$this->derivatives[$provider['provider'] . '__' . $fileinfo->getBasename('.yml')] = $directory->read($fileinfo->getBasename('.yml'));
- $this->derivatives[$provider['provider'] . '__' . $fileinfo->getBasename('.yml')]['theme'] = $provider['provider'] . '__' . $fileinfo->getBasename('.yml');
+ $this->derivatives[$provider['provider'] . '__' . $fileinfo->getBasename('.yml')]['template'] = $provider['provider'] . '--' . $fileinfo->getBasename('.yml');
$this->derivatives[$provider['provider'] . '__' . $fileinfo->getBasename('.yml')]['path'] = $fileinfo->getPath();
}
}
diff -u b/core/modules/layout/lib/Drupal/layout/Plugin/LayoutInterface.php b/core/modules/layout/lib/Drupal/layout/Plugin/LayoutInterface.php
--- b/core/modules/layout/lib/Drupal/layout/Plugin/LayoutInterface.php
+++ b/core/modules/layout/lib/Drupal/layout/Plugin/LayoutInterface.php
@@ -4,8 +4,6 @@
-use Drupal\layout\Plugin\RendererInterface;
-
interface LayoutInterface {
public function getRegions();
- public function renderLayout(RendererInterface $renderer);
+ public function renderLayout();
}
diff -u b/core/modules/layout/lib/Drupal/layout/Plugin/layout/layout/DefaultLayout.php b/core/modules/layout/lib/Drupal/layout/Plugin/layout/layout/DefaultLayout.php
--- b/core/modules/layout/lib/Drupal/layout/Plugin/layout/layout/DefaultLayout.php
+++ b/core/modules/layout/lib/Drupal/layout/Plugin/layout/layout/DefaultLayout.php
@@ -36,20 +36,28 @@
}
}
- public function renderLayout(RendererInterface $renderer, $admin = FALSE) {
+ // @todo The $regions parameter is here only temporarily. It allows the caller
+ // to pass already rendered regions, while layout/block configuration code
+ // is still in progress.
+ public function renderLayout($admin = FALSE, $regions = array()) {
$definition = $this->getDefinition();
- $regions = array();
+
+ // Render all regions not already rendered by the caller.
foreach ($this->getRegions() as $region => $title) {
- foreach ($this->configuration['regions'][$region] as $block_id => $configuration) {
- $block = block_load($block_id, $configuration);
- if ($block->access()) {
- // Need to check the caching method on the block to determine exactly
- // how we're going to get it. Should probably be abstracted out of
- // this code so that the renderer worries about it instead.
- $regions[$region][] = $block->build();
+ if (!isset($regions[$region]) && isset($this->configuration['regions'][$region])) {
+ foreach ($this->configuration['regions'][$region] as $block_id => $configuration) {
+ $regions[$region] = '';
+ $block = block_load($block_id, $configuration);
+ if ($block->access()) {
+ // Need to check the caching method on the block to determine exactly
+ // how we're going to get it. Should probably be abstracted out of
+ // this code so that the renderer worries about it instead.
+ $regions[$region] .= $block->build();
+ }
}
}
}
+
if (!$admin) {
$this->getCss();
$this->getJs();
@@ -60,3 +68,7 @@
- return theme($definition['layout'], $regions);
+
+ $template = $definition['path'] . '/' . $definition['template'] . '.tpl.php';
+ $output = theme_render_template($template, array('content' => $regions));
+
+ return $output;
}
-}
\ No newline at end of file
+}
only in patch2:
unchanged:
--- /dev/null
+++ b/core/themes/bartik/layout/bartik/bartik--bartik.tpl.php
@@ -0,0 +1,69 @@
+
+