Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -0,0 +1,6 @@
|
|||
name: 'Layout Discovery'
|
||||
type: module
|
||||
description: 'Provides a way for modules or themes to register layouts.'
|
||||
package: Core (Experimental)
|
||||
version: VERSION
|
||||
core: 8.x
|
22
web/core/modules/layout_discovery/layout_discovery.install
Normal file
22
web/core/modules/layout_discovery/layout_discovery.install
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install, update, and uninstall functions for the Layout Discovery module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_requirements().
|
||||
*/
|
||||
function layout_discovery_requirements($phase) {
|
||||
$requirements = [];
|
||||
if ($phase === 'install') {
|
||||
if (\Drupal::moduleHandler()->moduleExists('layout_plugin')) {
|
||||
$requirements['layout_discovery'] = [
|
||||
'description' => t('Layout Discovery cannot be installed because the Layout Plugin module is installed and incompatible.'),
|
||||
'severity' => REQUIREMENT_ERROR,
|
||||
];
|
||||
}
|
||||
}
|
||||
return $requirements;
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
layout_onecol:
|
||||
label: 'One column'
|
||||
path: layouts/onecol
|
||||
template: layout--onecol
|
||||
library: layout_discovery/onecol
|
||||
category: 'Columns: 1'
|
||||
default_region: content
|
||||
regions:
|
||||
content:
|
||||
label: Content
|
||||
|
||||
layout_twocol:
|
||||
label: 'Two column'
|
||||
path: layouts/twocol
|
||||
template: layout--twocol
|
||||
library: layout_discovery/twocol
|
||||
category: 'Columns: 2'
|
||||
default_region: left
|
||||
regions:
|
||||
top:
|
||||
label: Top
|
||||
left:
|
||||
label: Left
|
||||
right:
|
||||
label: Right
|
||||
bottom:
|
||||
label: Bottom
|
||||
|
||||
layout_twocol_bricks:
|
||||
label: 'Two column bricks'
|
||||
path: layouts/twocol_bricks
|
||||
template: layout--twocol-bricks
|
||||
library: layout_discovery/twocol_bricks
|
||||
category: 'Columns: 2'
|
||||
default_region: middle
|
||||
regions:
|
||||
top:
|
||||
label: Top
|
||||
left_above:
|
||||
label: 'Left above'
|
||||
right_above:
|
||||
label: 'Right above'
|
||||
middle:
|
||||
label: Middle
|
||||
left_below:
|
||||
label: 'Left below'
|
||||
right_below:
|
||||
label: 'Right below'
|
||||
bottom:
|
||||
label: Bottom
|
||||
|
||||
layout_threecol_25_50_25:
|
||||
label: 'Three column 25/50/25'
|
||||
path: layouts/threecol_25_50_25
|
||||
template: layout--threecol-25-50-25
|
||||
library: layout_discovery/threecol_25_50_25
|
||||
category: 'Columns: 3'
|
||||
default_region: left
|
||||
regions:
|
||||
top:
|
||||
label: Top
|
||||
left:
|
||||
label: Left
|
||||
middle:
|
||||
label: Middle
|
||||
right:
|
||||
label: Right
|
||||
bottom:
|
||||
label: Bottom
|
||||
|
||||
layout_threecol_33_34_33:
|
||||
label: 'Three column 33/34/33'
|
||||
path: layouts/threecol_33_34_33
|
||||
template: layout--threecol-33-34-33
|
||||
library: layout_discovery/threecol_33_34_33
|
||||
category: 'Columns: 3'
|
||||
default_region: left
|
||||
regions:
|
||||
top:
|
||||
label: Top
|
||||
left:
|
||||
label: Left
|
||||
middle:
|
||||
label: Middle
|
||||
right:
|
||||
label: Right
|
||||
bottom:
|
||||
label: Bottom
|
|
@ -0,0 +1,25 @@
|
|||
onecol:
|
||||
version: VERSION
|
||||
css:
|
||||
theme:
|
||||
layouts/onecol/onecol.css: {}
|
||||
twocol_bricks:
|
||||
version: VERSION
|
||||
css:
|
||||
theme:
|
||||
layouts/twocol_bricks/twocol_bricks.css: {}
|
||||
twocol:
|
||||
version: VERSION
|
||||
css:
|
||||
theme:
|
||||
layouts/twocol/twocol.css: {}
|
||||
threecol_25_50_25:
|
||||
version: VERSION
|
||||
css:
|
||||
theme:
|
||||
layouts/threecol_25_50_25/threecol_25_50_25.css: {}
|
||||
threecol_33_34_33:
|
||||
version: VERSION
|
||||
css:
|
||||
theme:
|
||||
layouts/threecol_33_34_33/threecol_33_34_33.css: {}
|
39
web/core/modules/layout_discovery/layout_discovery.module
Normal file
39
web/core/modules/layout_discovery/layout_discovery.module
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provides hook implementations for Layout Discovery.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_help().
|
||||
*/
|
||||
function layout_discovery_help($route_name) {
|
||||
switch ($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>';
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function layout_discovery_theme() {
|
||||
return \Drupal::service('plugin.manager.core.layout')->getThemeImplementations();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares variables for layout templates.
|
||||
*
|
||||
* @param array &$variables
|
||||
* An associative array containing:
|
||||
* - content: An associative array containing the properties of the element.
|
||||
* Properties used: #settings, #layout.
|
||||
*/
|
||||
function template_preprocess_layout(&$variables) {
|
||||
$variables['settings'] = isset($variables['content']['#settings']) ? $variables['content']['#settings'] : [];
|
||||
$variables['layout'] = isset($variables['content']['#layout']) ? $variables['content']['#layout'] : [];
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
services:
|
||||
plugin.manager.core.layout:
|
||||
class: Drupal\Core\Layout\LayoutPluginManager
|
||||
arguments: ['@container.namespaces', '@cache.discovery', '@module_handler', '@theme_handler']
|
|
@ -0,0 +1,24 @@
|
|||
{#
|
||||
/**
|
||||
* @file
|
||||
* Default theme implementation to display a one-column layout.
|
||||
*
|
||||
* Available variables:
|
||||
* - content: The content for this layout.
|
||||
* - attributes: HTML attributes for the layout <div>.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
#}
|
||||
{%
|
||||
set classes = [
|
||||
'layout--onecol',
|
||||
]
|
||||
%}
|
||||
{% if content %}
|
||||
<div{{ attributes.addClass(classes) }}>
|
||||
<div class="layout-region layout-region--content">
|
||||
{{ content.content }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
|
@ -0,0 +1,3 @@
|
|||
.layout--onecol .layout-region {
|
||||
width: 100%;
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
{#
|
||||
/**
|
||||
* @file
|
||||
* Default theme implementation for a three column layout.
|
||||
*
|
||||
* This template provides a three column 25%-50%-25% display layout, with
|
||||
* additional areas for the top and the bottom.
|
||||
*
|
||||
* Available variables:
|
||||
* - content: The content for this layout.
|
||||
* - attributes: HTML attributes for the layout <div>.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
#}
|
||||
{%
|
||||
set classes = [
|
||||
'layout--threecol',
|
||||
]
|
||||
%}
|
||||
{% if content %}
|
||||
<div{{ attributes.addClass(classes) }}>
|
||||
{% if content.top %}
|
||||
<div class="layout-region layout-region--fullwidth">
|
||||
{{ content.top }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="layout-region layout-region--side">
|
||||
{{ content.left }}
|
||||
</div>
|
||||
|
||||
<div class="layout-region layout-region--middle">
|
||||
{{ content.middle }}
|
||||
</div>
|
||||
|
||||
<div class="layout-region layout-region--side">
|
||||
{{ content.right }}
|
||||
</div>
|
||||
|
||||
{% if content.bottom %}
|
||||
<div class="layout-region layout-region--fullwidth">
|
||||
{{ content.bottom }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
|
@ -0,0 +1,17 @@
|
|||
.layout--threecol {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.layout--threecol > .layout-region {
|
||||
flex: 0 1 25%;
|
||||
}
|
||||
|
||||
.layout--threecol > .layout-region--fullwidth {
|
||||
flex: 0 1 100%;
|
||||
}
|
||||
|
||||
.layout--threecol > .layout-region--middle {
|
||||
flex: 0 1 50%;
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
{#
|
||||
/**
|
||||
* @file
|
||||
* Default theme implementation for a three column layout.
|
||||
*
|
||||
* This template provides a three column 33%-34%-33% display layout, with
|
||||
* additional areas for the top and the bottom.
|
||||
*
|
||||
* Available variables:
|
||||
* - content: The content for this layout.
|
||||
* - attributes: HTML attributes for the layout <div>.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
#}
|
||||
{%
|
||||
set classes = [
|
||||
'layout--threecol-33',
|
||||
]
|
||||
%}
|
||||
{% if content %}
|
||||
<div{{ attributes.addClass(classes) }}>
|
||||
{% if content.top %}
|
||||
<div class="layout-region layout-region--fullwidth">
|
||||
{{ content.top }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="layout-region">
|
||||
{{ content.left }}
|
||||
</div>
|
||||
|
||||
<div class="layout-region">
|
||||
{{ content.middle }}
|
||||
</div>
|
||||
|
||||
<div class="layout-region">
|
||||
{{ content.right }}
|
||||
</div>
|
||||
|
||||
{% if content.bottom %}
|
||||
<div class="layout-region layout-region--fullwidth">
|
||||
{{ content.bottom }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
|
@ -0,0 +1,13 @@
|
|||
.layout--threecol-33 {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.layout--threecol-33 > .layout-region {
|
||||
flex: 0 1 33%;
|
||||
}
|
||||
|
||||
.layout--threecol-33 > .layout-region--fullwidth {
|
||||
flex: 0 1 100%;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
{#
|
||||
/**
|
||||
* @file
|
||||
* Default theme implementation to display a two-column layout.
|
||||
*
|
||||
* Available variables:
|
||||
* - content: The content for this layout.
|
||||
* - attributes: HTML attributes for the layout <div>.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
#}
|
||||
{%
|
||||
set classes = [
|
||||
'layout--twocol',
|
||||
]
|
||||
%}
|
||||
{% if content %}
|
||||
<div{{ attributes.addClass(classes) }}>
|
||||
<div class="layout-region layout-region--fullwidth">
|
||||
{{ content.top }}
|
||||
</div>
|
||||
|
||||
<div class="layout-region layout-region--left">
|
||||
{{ content.left }}
|
||||
</div>
|
||||
|
||||
<div class="layout-region layout-region--right">
|
||||
{{ content.right }}
|
||||
</div>
|
||||
|
||||
<div class="layout-region layout-region--fullwidth">
|
||||
{{ content.bottom }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
13
web/core/modules/layout_discovery/layouts/twocol/twocol.css
Normal file
13
web/core/modules/layout_discovery/layouts/twocol/twocol.css
Normal file
|
@ -0,0 +1,13 @@
|
|||
.layout--twocol {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.layout--twocol > .layout-region {
|
||||
flex: 0 1 50%;
|
||||
}
|
||||
|
||||
.layout--twocol > .layout-region--fullwidth {
|
||||
flex: 0 1 100%;
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
{#
|
||||
/**
|
||||
* @file
|
||||
* Default theme implementation for a two column layout.
|
||||
*
|
||||
* This template provides a two column display layout with full width areas at
|
||||
* the top, bottom and in the middle.
|
||||
*
|
||||
* Available variables:
|
||||
* - content: The content for this layout.
|
||||
* - attributes: HTML attributes for the layout <div>.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
#}
|
||||
{%
|
||||
set classes = [
|
||||
'layout--twocol-bricks',
|
||||
]
|
||||
%}
|
||||
{% if content %}
|
||||
<div{{ attributes.addClass(classes) }}>
|
||||
<div class="layout-region layout-region--fullwidth">
|
||||
{{ content.top }}
|
||||
</div>
|
||||
|
||||
<div class="layout-region layout-region--left_above">
|
||||
{{ content.left_above }}
|
||||
</div>
|
||||
|
||||
<div class="layout-region layout-region--right_above">
|
||||
{{ content.right_above }}
|
||||
</div>
|
||||
|
||||
<div class="layout-region layout-region--middle">
|
||||
{{ content.middle }}
|
||||
</div>
|
||||
|
||||
<div class="layout-region layout-region--left_below">
|
||||
{{ content.left_below }}
|
||||
</div>
|
||||
|
||||
<div class="layout-region layout-region--right_below">
|
||||
{{ content.right_below }}
|
||||
</div>
|
||||
|
||||
<div class="layout-region layout-region--fullwidth">
|
||||
{{ content.bottom }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
|
@ -0,0 +1,13 @@
|
|||
.layout--twocol-bricks {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.layout--twocol-bricks > .layout-region {
|
||||
flex: 0 1 50%;
|
||||
}
|
||||
|
||||
.layout--twocol-bricks > .layout-region--fullwidth {
|
||||
flex: 0 1 100%;
|
||||
}
|
18
web/core/modules/layout_discovery/templates/layout.html.twig
Normal file
18
web/core/modules/layout_discovery/templates/layout.html.twig
Normal file
|
@ -0,0 +1,18 @@
|
|||
{#
|
||||
/**
|
||||
* @file
|
||||
* Template for a generic layout.
|
||||
*/
|
||||
#}
|
||||
{% set classes = [
|
||||
'layout--' ~ layout.id|clean_class,
|
||||
] %}
|
||||
{% if content %}
|
||||
<div{{ attributes.addClass(classes) }}>
|
||||
{% for region in layout.getRegionNames %}
|
||||
<div class="{{ 'region--' ~ region|clean_class }}">
|
||||
{{ content[region] }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
|
@ -0,0 +1,212 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\layout_discovery\Kernel;
|
||||
|
||||
use Drupal\Core\Form\FormState;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
||||
/**
|
||||
* Tests Layout functionality.
|
||||
*
|
||||
* @group Layout
|
||||
*/
|
||||
class LayoutTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['system', 'layout_discovery', 'layout_test'];
|
||||
|
||||
/**
|
||||
* The layout plugin manager.
|
||||
*
|
||||
* @var \Drupal\Core\Layout\LayoutPluginManagerInterface
|
||||
*/
|
||||
protected $layoutPluginManager;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->layoutPluginManager = $this->container->get('plugin.manager.core.layout');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test rendering a layout.
|
||||
*
|
||||
* @dataProvider renderLayoutData
|
||||
*/
|
||||
public function testRenderLayout($layout_id, $config, $regions, $html) {
|
||||
$layout = $this->layoutPluginManager->createInstance($layout_id, $config);
|
||||
$built['layout'] = $layout->build($regions);
|
||||
$built['layout']['#prefix'] = 'Test prefix';
|
||||
$built['layout']['#suffix'] = 'Test suffix';
|
||||
$html = 'Test prefix' . $html . "\n" . 'Test suffix';
|
||||
|
||||
// Assume each layout is contained by a form, in order to ensure the
|
||||
// building of the layout does not interfere with form processing.
|
||||
$form_state = new FormState();
|
||||
$form_builder = $this->container->get('form_builder');
|
||||
$form_builder->prepareForm('the_form_id', $built, $form_state);
|
||||
$form_builder->processForm('the_form_id', $built, $form_state);
|
||||
|
||||
$this->render($built);
|
||||
$this->assertRaw($html);
|
||||
$this->assertRaw('<input data-drupal-selector="edit-the-form-id" type="hidden" name="form_id" value="the_form_id" />');
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testRenderLayout().
|
||||
*/
|
||||
public function renderLayoutData() {
|
||||
$data['layout_onecol'] = [
|
||||
'layout_onecol',
|
||||
[],
|
||||
[
|
||||
'content' => [
|
||||
'#markup' => 'This is the content',
|
||||
],
|
||||
],
|
||||
];
|
||||
$data['layout_test_1col_with_form'] = [
|
||||
'layout_test_1col',
|
||||
[],
|
||||
[
|
||||
'top' => [
|
||||
'#process' => [[static::class, 'processCallback']],
|
||||
],
|
||||
'bottom' => [
|
||||
'#markup' => 'This is the bottom',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$data['layout_test_1col'] = [
|
||||
'layout_test_1col',
|
||||
[],
|
||||
[
|
||||
'top' => [
|
||||
'#markup' => 'This is the top',
|
||||
],
|
||||
'bottom' => [
|
||||
'#markup' => 'This is the bottom',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$data['layout_test_1col_no_template'] = [
|
||||
'layout_test_1col_no_template',
|
||||
[],
|
||||
[
|
||||
'top' => [
|
||||
'#markup' => 'This is the top',
|
||||
],
|
||||
'bottom' => [
|
||||
'#markup' => 'This is the bottom',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$data['layout_test_2col'] = [
|
||||
'layout_test_2col',
|
||||
[],
|
||||
[
|
||||
'left' => [
|
||||
'#markup' => 'This is the left',
|
||||
],
|
||||
'right' => [
|
||||
'#markup' => 'This is the right',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$data['layout_test_plugin'] = [
|
||||
'layout_test_plugin',
|
||||
[
|
||||
'setting_1' => 'Config value',
|
||||
],
|
||||
[
|
||||
'main' => [
|
||||
'#markup' => 'Main region',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$data['layout_onecol'][] = <<<'EOD'
|
||||
<div data-drupal-selector="edit-layout" class="layout--onecol">
|
||||
<div class="layout-region layout-region--content">
|
||||
This is the content
|
||||
</div>
|
||||
</div>
|
||||
EOD;
|
||||
|
||||
$data['layout_test_1col_with_form'][] = <<<'EOD'
|
||||
<div class="layout-example-1col clearfix">
|
||||
<div class="region-top">
|
||||
This string added by #process.
|
||||
</div>
|
||||
<div class="region-bottom">
|
||||
This is the bottom
|
||||
</div>
|
||||
</div>
|
||||
EOD;
|
||||
|
||||
$data['layout_test_1col'][] = <<<'EOD'
|
||||
<div class="layout-example-1col clearfix">
|
||||
<div class="region-top">
|
||||
This is the top
|
||||
</div>
|
||||
<div class="region-bottom">
|
||||
This is the bottom
|
||||
</div>
|
||||
</div>
|
||||
EOD;
|
||||
|
||||
$data['layout_test_1col_no_template'][] = <<<'EOD'
|
||||
<div data-drupal-selector="edit-layout" class="layout--layout-test-1col-no-template">
|
||||
<div class="region--top">
|
||||
This is the top
|
||||
</div>
|
||||
<div class="region--bottom">
|
||||
This is the bottom
|
||||
</div>
|
||||
</div>
|
||||
EOD;
|
||||
|
||||
$data['layout_test_2col'][] = <<<'EOD'
|
||||
<div class="layout-example-2col clearfix">
|
||||
<div class="region-left">
|
||||
This is the left
|
||||
</div>
|
||||
<div class="region-right">
|
||||
This is the right
|
||||
</div>
|
||||
</div>
|
||||
EOD;
|
||||
|
||||
$data['layout_test_plugin'][] = <<<'EOD'
|
||||
<div class="layout-test-plugin clearfix">
|
||||
<div>
|
||||
<span class="setting-1-label">Blah: </span>
|
||||
Config value
|
||||
</div>
|
||||
<div class="region-main">
|
||||
Main region
|
||||
</div>
|
||||
</div>
|
||||
EOD;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a test #process callback.
|
||||
*/
|
||||
public static function processCallback($element) {
|
||||
$element['#markup'] = 'This string added by #process.';
|
||||
return $element;
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue