Update Composer, update everything

This commit is contained in:
Oliver Davies 2018-11-23 12:29:20 +00:00
parent ea3e94409f
commit dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions

View file

@ -1,6 +1,6 @@
name: 'Layout Discovery'
type: module
description: 'Provides a way for modules or themes to register layouts.'
package: Core (Experimental)
package: Core
version: VERSION
core: 8.x

View file

@ -5,6 +5,8 @@ layout_onecol:
library: layout_discovery/onecol
category: 'Columns: 1'
default_region: content
icon_map:
- [content]
regions:
content:
label: Content
@ -16,6 +18,10 @@ layout_twocol:
library: layout_discovery/twocol
category: 'Columns: 2'
default_region: first
icon_map:
- [top]
- [first, second]
- [bottom]
regions:
top:
label: Top
@ -33,6 +39,12 @@ layout_twocol_bricks:
library: layout_discovery/twocol_bricks
category: 'Columns: 2'
default_region: middle
icon_map:
- [top]
- [first_above, second_above]
- [middle]
- [first_below, second_below]
- [bottom]
regions:
top:
label: Top
@ -56,6 +68,10 @@ layout_threecol_25_50_25:
library: layout_discovery/threecol_25_50_25
category: 'Columns: 3'
default_region: second
icon_map:
- [top]
- [first, second, second, third]
- [bottom]
regions:
top:
label: Top
@ -75,6 +91,10 @@ layout_threecol_33_34_33:
library: layout_discovery/threecol_33_34_33
category: 'Columns: 3'
default_region: first
icon_map:
- [top]
- [first, second, third]
- [bottom]
regions:
top:
label: Top

View file

@ -5,6 +5,9 @@
* Provides hook implementations for Layout Discovery.
*/
use Drupal\Core\Render\Element;
use Drupal\Core\Template\Attribute;
/**
* Implements hook_help().
*/
@ -13,7 +16,7 @@ function layout_discovery_help($route_name) {
case 'help.page.layout_discovery':
$output = '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Layout Discovery allows modules or themes to register layouts, and for other modules to list the available layouts and render them.') . '</p>';
$output .= '<p>' . t('For more information, see the <a href=":layout-discovery-documentation">online documentation for the Layout Discovery module</a>.', [':layout-discovery-documentation' => 'https://www.drupal.org/node/2619128']) . '</p>';
$output .= '<p>' . t('For more information, see the <a href=":layout-discovery-documentation">online documentation for the Layout Discovery module</a>.', [':layout-discovery-documentation' => 'https://www.drupal.org/docs/8/api/layout-api']) . '</p>';
return $output;
}
}
@ -36,4 +39,12 @@ function layout_discovery_theme() {
function template_preprocess_layout(&$variables) {
$variables['settings'] = isset($variables['content']['#settings']) ? $variables['content']['#settings'] : [];
$variables['layout'] = isset($variables['content']['#layout']) ? $variables['content']['#layout'] : [];
// Create an attributes variable for each region.
foreach (Element::children($variables['content']) as $name) {
if (!isset($variables['content'][$name]['#attributes'])) {
$variables['content'][$name]['#attributes'] = [];
}
$variables['region_attributes'][$name] = new Attribute($variables['content'][$name]['#attributes']);
}
}

View file

@ -2,3 +2,6 @@ services:
plugin.manager.core.layout:
class: Drupal\Core\Layout\LayoutPluginManager
arguments: ['@container.namespaces', '@cache.discovery', '@module_handler', '@theme_handler']
layout.icon_builder:
class: Drupal\Core\Layout\Icon\SvgIconBuilder
shared: false

View file

@ -18,7 +18,7 @@
%}
{% if content %}
<div{{ attributes.addClass(classes) }}>
<div class="layout__region layout__region--content">
<div {{ region_attributes.content.addClass('layout__region', 'layout__region--content') }}>
{{ content.content }}
</div>
</div>

View file

@ -22,31 +22,31 @@
{% if content %}
<div{{ attributes.addClass(classes) }}>
{% if content.top %}
<div class="layout__region layout__region--top">
<div {{ region_attributes.top.addClass('layout__region', 'layout__region--top') }}>
{{ content.top }}
</div>
{% endif %}
{% if content.first %}
<div class="layout__region layout__region--first">
<div {{ region_attributes.first.addClass('layout__region', 'layout__region--first') }}>
{{ content.first }}
</div>
{% endif %}
{% if content.second %}
<div class="layout__region layout__region--second">
<div {{ region_attributes.second.addClass('layout__region', 'layout__region--second') }}>
{{ content.second }}
</div>
{% endif %}
{% if content.third %}
<div class="layout__region layout__region--third">
<div {{ region_attributes.third.addClass('layout__region', 'layout__region--third') }}>
{{ content.third }}
</div>
{% endif %}
{% if content.bottom %}
<div class="layout__region layout__region--bottom">
<div {{ region_attributes.bottom.addClass('layout__region', 'layout__region--bottom') }}>
{{ content.bottom }}
</div>
{% endif %}

View file

@ -22,31 +22,31 @@
{% if content %}
<div{{ attributes.addClass(classes) }}>
{% if content.top %}
<div class="layout__region layout__region--top">
<div {{ region_attributes.top.addClass('layout__region', 'layout__region--top') }}>
{{ content.top }}
</div>
{% endif %}
{% if content.first %}
<div class="layout__region layout__region--first">
<div {{ region_attributes.first.addClass('layout__region', 'layout__region--first') }}>
{{ content.first }}
</div>
{% endif %}
{% if content.second %}
<div class="layout__region layout__region--second">
<div {{ region_attributes.second.addClass('layout__region', 'layout__region--second') }}>
{{ content.second }}
</div>
{% endif %}
{% if content.third %}
<div class="layout__region layout__region--third">
<div {{ region_attributes.third.addClass('layout__region', 'layout__region--third') }}>
{{ content.third }}
</div>
{% endif %}
{% if content.bottom %}
<div class="layout__region layout__region--bottom">
<div {{ region_attributes.bottom.addClass('layout__region', 'layout__region--bottom') }}>
{{ content.bottom }}
</div>
{% endif %}

View file

@ -17,8 +17,10 @@
@media screen and (min-width: 40em) {
.layout--threecol-33-34-33 > .layout__region--first,
.layout--threecol-33-34-33 > .layout__region--second,
.layout--threecol-33-34-33 > .layout__region--third {
flex: 0 1 33%;
}
.layout--threecol-33-34-33 > .layout__region--second {
flex: 0 1 34%;
}
}

View file

@ -19,25 +19,25 @@
{% if content %}
<div{{ attributes.addClass(classes) }}>
{% if content.top %}
<div class="layout__region layout__region--top">
<div {{ region_attributes.top.addClass('layout__region', 'layout__region--top') }}>
{{ content.top }}
</div>
{% endif %}
{% if content.first %}
<div class="layout__region layout__region--first">
<div {{ region_attributes.first.addClass('layout__region', 'layout__region--first') }}>
{{ content.first }}
</div>
{% endif %}
{% if content.second %}
<div class="layout__region layout__region--second">
<div {{ region_attributes.second.addClass('layout__region', 'layout__region--second') }}>
{{ content.second }}
</div>
{% endif %}
{% if content.bottom %}
<div class="layout__region layout__region--bottom">
<div {{ region_attributes.bottom.addClass('layout__region', 'layout__region--bottom') }}>
{{ content.bottom }}
</div>
{% endif %}

View file

@ -22,43 +22,43 @@
{% if content %}
<div{{ attributes.addClass(classes) }}>
{% if content.top %}
<div class="layout__region layout__region--top">
<div {{ region_attributes.top.addClass('layout__region', 'layout__region--top') }}>
{{ content.top }}
</div>
{% endif %}
{% if content.first_above %}
<div class="layout__region layout__region--first-above">
<div {{ region_attributes.first_above.addClass('layout__region', 'layout__region--first-above') }}>
{{ content.first_above }}
</div>
{% endif %}
{% if content.second_above %}
<div class="layout__region layout__region--second-above">
<div {{ region_attributes.second_above.addClass('layout__region', 'layout__region--second-above') }}>
{{ content.second_above }}
</div>
{% endif %}
{% if content.middle %}
<div class="layout__region layout__region--middle">
<div {{ region_attributes.middle.addClass('layout__region', 'layout__region--middle') }}>
{{ content.middle }}
</div>
{% endif %}
{% if content.first_below %}
<div class="layout__region layout__region--first-below">
<div {{ region_attributes.first_below.addClass('layout__region', 'layout__region--first-below') }}>
{{ content.first_below }}
</div>
{% endif %}
{% if content.second_below %}
<div class="layout__region layout__region--second-below">
<div {{ region_attributes.second_below.addClass('layout__region', 'layout__region--second-below') }}>
{{ content.second_below }}
</div>
{% endif %}
{% if content.bottom %}
<div class="layout__region layout__region--bottom">
<div {{ region_attributes.bottom.addClass('layout__region', 'layout__region--bottom') }}>
{{ content.bottom }}
</div>
{% endif %}

View file

@ -14,7 +14,7 @@
<div{{ attributes.addClass(classes) }}>
{% for region in layout.getRegionNames %}
{% if content[region] %}
<div class="{{ 'layout__region layout__region--' ~ region|clean_class }}">
<div {{ region_attributes[region].addClass('layout__region', 'layout__region--' ~ region|clean_class) }}>
{{ content[region] }}
</div>
{% endif %}

View file

@ -33,6 +33,17 @@ class LayoutTest extends KernelTestBase {
$this->layoutPluginManager = $this->container->get('plugin.manager.core.layout');
}
/**
* Tests that a layout provided by a theme has the preprocess function set.
*/
public function testThemeProvidedLayout() {
$this->container->get('theme_installer')->install(['test_layout_theme']);
$this->config('system.theme')->set('default', 'test_layout_theme')->save();
$theme_definitions = $this->container->get('theme.registry')->get();
$this->assertTrue(in_array('template_preprocess_layout', $theme_definitions['test_layout_theme']['preprocess functions']));
}
/**
* Test rendering a layout.
*
@ -82,7 +93,7 @@ class LayoutTest extends KernelTestBase {
public function renderLayoutData() {
$html = [];
$html[] = '<div data-drupal-selector="edit-layout" class="layout layout--onecol">';
$html[] = '<div class="layout__region layout__region--content">';
$html[] = '<div data-drupal-selector="edit-content" class="layout__region layout__region--content">';
$html[] = 'This is the content';
$html[] = '</div>';
$html[] = '</div>';
@ -98,11 +109,11 @@ class LayoutTest extends KernelTestBase {
];
$html = [];
$html[] = '<div class="layout-example-1col clearfix">';
$html[] = '<div class="region-top">';
$html[] = '<div data-drupal-selector="edit-layout" class="layout-example-1col clearfix">';
$html[] = '<div data-drupal-selector="edit-top" class="region-top">';
$html[] = 'This string added by #process.';
$html[] = '</div>';
$html[] = '<div class="region-bottom">';
$html[] = '<div data-drupal-selector="edit-bottom" class="region-bottom">';
$html[] = 'This is the bottom';
$html[] = '</div>';
$html[] = '</div>';
@ -121,11 +132,11 @@ class LayoutTest extends KernelTestBase {
];
$html = [];
$html[] = '<div class="layout-example-1col clearfix">';
$html[] = '<div class="region-top">';
$html[] = '<div data-drupal-selector="edit-layout" class="layout-example-1col clearfix">';
$html[] = '<div data-drupal-selector="edit-top" class="region-top">';
$html[] = 'This is the top';
$html[] = '</div>';
$html[] = '<div class="region-bottom">';
$html[] = '<div data-drupal-selector="edit-bottom" class="region-bottom">';
$html[] = 'This is the bottom';
$html[] = '</div>';
$html[] = '</div>';
@ -145,10 +156,10 @@ class LayoutTest extends KernelTestBase {
$html = [];
$html[] = '<div data-drupal-selector="edit-layout" class="layout layout--layout-test-1col-no-template">';
$html[] = '<div class="layout__region layout__region--top">';
$html[] = '<div data-drupal-selector="edit-top" class="layout__region layout__region--top">';
$html[] = 'This is the top';
$html[] = '</div>';
$html[] = '<div class="layout__region layout__region--bottom">';
$html[] = '<div data-drupal-selector="edit-bottom" class="layout__region layout__region--bottom">';
$html[] = 'This is the bottom';
$html[] = '</div>';
$html[] = '</div>';
@ -167,11 +178,11 @@ class LayoutTest extends KernelTestBase {
];
$html = [];
$html[] = '<div class="layout-example-2col clearfix">';
$html[] = '<div class="region-left">';
$html[] = '<div data-drupal-selector="edit-layout" class="layout-example-2col clearfix">';
$html[] = '<div data-drupal-selector="edit-left" class="class-added-by-preprocess region-left">';
$html[] = 'This is the left';
$html[] = '</div>';
$html[] = '<div class="region-right">';
$html[] = '<div data-drupal-selector="edit-right" class="region-right">';
$html[] = 'This is the right';
$html[] = '</div>';
$html[] = '</div>';
@ -190,12 +201,12 @@ class LayoutTest extends KernelTestBase {
];
$html = [];
$html[] = '<div class="layout-test-plugin clearfix">';
$html[] = '<div data-drupal-selector="edit-layout" class="layout-test-plugin clearfix">';
$html[] = '<div>';
$html[] = '<span class="setting-1-label">Blah: </span>';
$html[] = 'Config value';
$html[] = '</div>';
$html[] = '<div class="region-main">';
$html[] = '<div data-drupal-selector="edit-main" class="region-main">';
$html[] = 'Main region';
$html[] = '</div>';
$html[] = '</div>';

View file

@ -0,0 +1,6 @@
name: 'Test layout theme'
type: theme
description: 'Theme for testing a theme-provided layout'
version: VERSION
base theme: classy
core: 8.x

View file

@ -0,0 +1,7 @@
test_layout_theme:
label: 'Test Layout - Theme'
category: 'Test Layout Theme'
template: templates/test-layout-theme
regions:
content:
label: Content