diff --git a/core/modules/theme_layout/config/schema/theme_layout.schema.yml b/core/modules/theme_layout/config/schema/theme_layout.schema.yml index 67c8f0b..388ba5d 100644 --- a/core/modules/theme_layout/config/schema/theme_layout.schema.yml +++ b/core/modules/theme_layout/config/schema/theme_layout.schema.yml @@ -1,2 +1,10 @@ theme_settings.third_party.theme_layout: - type: field_layout.third_party_settings + type: mapping + label: 'Per-theme layout settings' + mapping: + layout: + type: string + label: 'Layout ID' + settings: + type: layout_plugin.settings.[%parent.id] + label: 'Layout settings' diff --git a/core/modules/theme_layout/theme_layout.info.yml b/core/modules/theme_layout/theme_layout.info.yml index 90b99af..22ed914 100644 --- a/core/modules/theme_layout/theme_layout.info.yml +++ b/core/modules/theme_layout/theme_layout.info.yml @@ -4,5 +4,3 @@ description: 'Adds layout capabilities to themes.' package: Core (Experimental) version: VERSION core: 8.x -dependencies: - - field_layout diff --git a/core/modules/theme_layout/theme_layout.install b/core/modules/theme_layout/theme_layout.install index 5c1651c..9a81b2f 100644 --- a/core/modules/theme_layout/theme_layout.install +++ b/core/modules/theme_layout/theme_layout.install @@ -31,7 +31,7 @@ function theme_layout_themes_installed($theme_list) { * @todo. */ function _theme_layout_install_theme_settings($themes) { - $layout_definitions = \Drupal::service('field_layout.layout_repository')->getDefinitions(); + $layout_definitions = \Drupal::service('plugin.manager.core.layout')->getDefinitions(); foreach (array_intersect($themes, array_keys($layout_definitions)) as $theme) { \Drupal::configFactory()->getEditable($theme . '.settings') ->set('third_party_settings.theme_layout.layout', $theme) diff --git a/core/modules/theme_layout/theme_layout.module b/core/modules/theme_layout/theme_layout.module index 3d008cf..3b58faf 100644 --- a/core/modules/theme_layout/theme_layout.module +++ b/core/modules/theme_layout/theme_layout.module @@ -37,13 +37,7 @@ function theme_layout_form_system_theme_settings_alter(&$form, FormStateInterfac '#title' => t('Layout'), '#open' => TRUE, ]; - $definitions = \Drupal::service('field_layout.layout_repository')->getGroupedDefinitions(); - $layout_options = []; - foreach ($definitions as $category => $layouts) { - foreach ($layouts as $name => $layout) { - $layout_options[$category][$name] = $layout['label']; - } - } + $layout_options = \Drupal::service('plugin.manager.core.layout')->getLayoutOptions(); $form['theme_layouts']['theme_layout'] = [ '#type' => 'select', '#title' => t('Select a layout'), @@ -72,7 +66,7 @@ function theme_layout_system_theme_settings_submit(array &$form, FormStateInterf if ($new_layout !== $old_layout) { // @todo Devise a mechanism for mapping old regions to new ones in // https://www.drupal.org/node/2796877. - $layout_definition = \Drupal::service('field_layout.layout_repository')->getLayout($new_layout); + $layout_definition = \Drupal::service('plugin.manager.core.layout')->getLayout($new_layout); $new_region = isset($layout_definition['default_region']) ? $layout_definition['default_region'] : key($layout_definition['regions']); /** @var \Drupal\block\BlockInterface[] $blocks */ @@ -93,8 +87,8 @@ function theme_layout_system_theme_settings_submit(array &$form, FormStateInterf function theme_layout_system_info_alter(array &$info, Extension $file, $type) { if ($file->getType() === 'theme' && $layout_definition = _theme_layout_get_layout_for_theme($file->getName())) { unset($info['regions'], $info['regions_hidden']); - foreach ($layout_definition['regions'] as $region => $region_info) { - $info['regions'][$region] = $region_info['label']->getUntranslatedString(); + foreach ($layout_definition->getRegions() as $region => $region_info) { + $info['regions'][$region] = (string) $region_info['label']; if (isset($region_info['hidden'])) { $info['regions_hidden'][] = $region; } @@ -117,9 +111,9 @@ function theme_layout_element_info_alter(array &$info) { function theme_layout_page_pre_render($element) { $theme = \Drupal::theme()->getActiveTheme()->getName(); if ($layout_definition = _theme_layout_get_layout_for_theme($theme)) { - $element['#theme'] = $layout_definition['theme']; - if (isset($layout_definition['library'])) { - $element['#attached']['library'][] = $layout_definition['library']; + $element['#theme'] = $layout_definition->getThemeHook(); + if ($library = $layout_definition->getLibrary()) { + $element['#attached']['library'][] = $library; } } return $element; @@ -128,10 +122,10 @@ function theme_layout_page_pre_render($element) { /** * Gets the layout for a given theme. * - * @return mixed[] + * @return \Drupal\Core\Layout\LayoutDefinition * The layout definition for the given layout ID. */ function _theme_layout_get_layout_for_theme($theme) { $layout_id = \Drupal::config($theme . '.settings')->get('third_party_settings.theme_layout.layout'); - return \Drupal::service('field_layout.layout_repository')->getLayout($layout_id); + return \Drupal::service('plugin.manager.core.layout')->getDefinition($layout_id, FALSE); } diff --git a/core/themes/seven/seven.layouts.yml b/core/themes/seven/seven.layouts.yml new file mode 100644 index 0000000..84b87da --- /dev/null +++ b/core/themes/seven/seven.layouts.yml @@ -0,0 +1,28 @@ +seven: + label: 'Seven' + theme_hook: page + library: seven/global-styling + category: 'Theme-specific' + default_region: content + regions: + header: + label: Header + pre_content: + label: Pre-Content + breadcrumb: + label: Breadcrumb + highlighted: + label: Highlighted + help: + label: Help + content: + label: Content + page_top: + label: 'Page top' + hidden: true + page_bottom: + label: 'Page bottom' + hidden: true + sidebar_first: + label: 'Sidebar first' + hidden: true