diff --git a/core/modules/layout/layouts/static/twocol/twocol.yml b/core/modules/layout/layouts/static/twocol/twocol.yml index 6362669..5e19696 100644 --- a/core/modules/layout/layouts/static/twocol/twocol.yml +++ b/core/modules/layout/layouts/static/twocol/twocol.yml @@ -1,7 +1,8 @@ title: Two column category: Columns: 2 template: twocol -css: twocol.css +stylesheets: + - twocol.css regions: left: 'Left side' right: 'Right side' diff --git a/core/modules/layout/lib/Drupal/layout/Plugin/layout/layout/StaticLayout.php b/core/modules/layout/lib/Drupal/layout/Plugin/layout/layout/StaticLayout.php index 581d38b..e300dc3 100644 --- a/core/modules/layout/lib/Drupal/layout/Plugin/layout/layout/StaticLayout.php +++ b/core/modules/layout/lib/Drupal/layout/Plugin/layout/layout/StaticLayout.php @@ -43,60 +43,45 @@ public function getRegions() { } /** - * Add the CSS files associated with this layout to the page. + * Returns the list of CSS files associated with this layout. */ - public function getCssFiles() { + public function getStylesheetFiles() { $definition = $this->getDefinition(); - $files = $definition['css']; - if (is_string($files)) { - $files = array($files); - } - return $files; + return $definition['stylesheets']; } /** - * Add the administrative CSS files associated with this layout to the page. + * Returns the list of administrative CSS files associated with this layout. */ - public function getAdminCssFiles() { + public function getAdminStylesheetFiles() { $definition = $this->getDefinition(); // Fall back on regular CSS for the admin page if admin CSS not provided. - $files = isset($definition['admin css']) ? $definition['admin css'] : $definition['css']; - if (is_string($files)) { - $files = array($files); - } - return $files; + return isset($definition['admin stylesheets']) ? $definition['admin stylesheets'] : $definition['stylesheets']; } /** - * Add the JS files associated with this layout to the page. + * Returns the list of JS files associated with this layout. */ - public function getJsFiles() { + public function getScriptFiles() { $definition = $this->getDefinition(); - if (isset($definition['js'])) { - $files = $definition['js']; - if (is_string($files)) { - $files = array($files); - } - return $files; + if (isset($definition['scripts'])) { + return $definition['scripts']; } return array(); } /** - * Add the admin JS files associated with this layout to the page. + * Returns the list of administrative JS files associated with this layout. */ - public function getAdminJsFiles() { + public function getAdminScriptFiles() { $definition = $this->getDefinition(); $files = array(); - if (isset($definition['admin js'])) { - $files = $definition['admin js']; + if (isset($definition['admin scripts'])) { + $files = $definition['admin scripts']; } - elseif (isset($definition['js'])) { + elseif (isset($definition['scripts'])) { // Fall back on regular JS for the admin page if admin JS not provided. - $files = $definition['js']; - } - if (is_string($files)) { - $files = array($files); + $files = $definition['scripts']; } return $files; } @@ -108,7 +93,7 @@ public function renderLayout($admin = FALSE) { $definition = $this->getDefinition(); // Assemble a render array with the regions and attached CSS/JS. - $render = array( + $build = array( '#theme' => $definition['theme'], '#content' => array(), ); @@ -118,30 +103,30 @@ public function renderLayout($admin = FALSE) { // @todo This is just stub code to fill in regions with stuff for now. // When blocks are related to layouts and not themes, we can make this // really be filled in with blocks. - $render['#content'][$region] = '

' . $title . '

'; + $build['#content'][$region] = '

' . $title . '

'; } // Fill in attached CSS and JS files based on metadata. if (!$admin) { - $render['#attached'] = array( - 'css' => $this->getCssFiles(), - 'js' => $this->getJsFiles(), + $build['#attached'] = array( + 'css' => $this->getStylesheetFiles(), + 'js' => $this->getScriptFiles(), ); } else { - $render['#attached'] = array( - 'css' => $this->getAdminCssFiles(), - 'js' => $this->getAdminJsFiles(), + $build['#attached'] = array( + 'css' => $this->getAdminStylesheetFiles(), + 'js' => $this->getAdminScriptFiles(), ); } // Include the path of the definition in all CSS and JS files. foreach (array('css', 'js') as $type) { - foreach ($render['#attached'][$type] as &$filename) { + foreach ($build['#attached'][$type] as &$filename) { $filename = $definition['path'] . '/' . $filename; } } - return drupal_render($render); + return drupal_render($build); } } diff --git a/core/modules/layout/tests/themes/layout_test_theme/layouts/static/page/page.yml b/core/modules/layout/tests/themes/layout_test_theme/layouts/static/page/page.yml index 68bb478..e44950a 100644 --- a/core/modules/layout/tests/themes/layout_test_theme/layouts/static/page/page.yml +++ b/core/modules/layout/tests/themes/layout_test_theme/layouts/static/page/page.yml @@ -1,7 +1,8 @@ title: Layout test page category: Other template: test-layout -css: page.css +stylesheets: + - page.css regions: header: 'Header' help: 'Help'