Move all files to 2017/
This commit is contained in:
parent
ac7370f67f
commit
2875863330
15717 changed files with 0 additions and 0 deletions
|
|
@ -0,0 +1,6 @@
|
|||
name: 'Layout Discovery'
|
||||
type: module
|
||||
description: 'Provides a way for modules or themes to register layouts.'
|
||||
package: Core
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
|
|
@ -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,108 @@
|
|||
layout_onecol:
|
||||
label: 'One column'
|
||||
path: layouts/onecol
|
||||
template: layout--onecol
|
||||
library: layout_discovery/onecol
|
||||
category: 'Columns: 1'
|
||||
default_region: content
|
||||
icon_map:
|
||||
- [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: first
|
||||
icon_map:
|
||||
- [top]
|
||||
- [first, second]
|
||||
- [bottom]
|
||||
regions:
|
||||
top:
|
||||
label: Top
|
||||
first:
|
||||
label: First
|
||||
second:
|
||||
label: Second
|
||||
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
|
||||
icon_map:
|
||||
- [top]
|
||||
- [first_above, second_above]
|
||||
- [middle]
|
||||
- [first_below, second_below]
|
||||
- [bottom]
|
||||
regions:
|
||||
top:
|
||||
label: Top
|
||||
first_above:
|
||||
label: 'First above'
|
||||
second_above:
|
||||
label: 'Second above'
|
||||
middle:
|
||||
label: Middle
|
||||
first_below:
|
||||
label: 'First below'
|
||||
second_below:
|
||||
label: 'Second 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: second
|
||||
icon_map:
|
||||
- [top]
|
||||
- [first, second, second, third]
|
||||
- [bottom]
|
||||
regions:
|
||||
top:
|
||||
label: Top
|
||||
first:
|
||||
label: First
|
||||
second:
|
||||
label: Second
|
||||
third:
|
||||
label: Third
|
||||
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: first
|
||||
icon_map:
|
||||
- [top]
|
||||
- [first, second, third]
|
||||
- [bottom]
|
||||
regions:
|
||||
top:
|
||||
label: Top
|
||||
first:
|
||||
label: First
|
||||
second:
|
||||
label: Second
|
||||
third:
|
||||
label: Third
|
||||
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: {}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provides hook implementations for Layout Discovery.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Render\Element;
|
||||
use Drupal\Core\Template\Attribute;
|
||||
|
||||
/**
|
||||
* 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/docs/8/api/layout-api']) . '</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'] : [];
|
||||
|
||||
// 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']);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
{#
|
||||
/**
|
||||
* @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',
|
||||
'layout--onecol',
|
||||
]
|
||||
%}
|
||||
{% if content %}
|
||||
<div{{ attributes.addClass(classes) }}>
|
||||
<div {{ region_attributes.content.addClass('layout__region', 'layout__region--content') }}>
|
||||
{{ content.content }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
* @file
|
||||
* Provides the layout styles for layout_onecol.
|
||||
*/
|
||||
.layout--onecol .layout__region {
|
||||
width: 100%;
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
{#
|
||||
/**
|
||||
* @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',
|
||||
'layout--threecol-25-50-25',
|
||||
]
|
||||
%}
|
||||
{% if content %}
|
||||
<div{{ attributes.addClass(classes) }}>
|
||||
{% if content.top %}
|
||||
<div {{ region_attributes.top.addClass('layout__region', 'layout__region--top') }}>
|
||||
{{ content.top }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if content.first %}
|
||||
<div {{ region_attributes.first.addClass('layout__region', 'layout__region--first') }}>
|
||||
{{ content.first }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if content.second %}
|
||||
<div {{ region_attributes.second.addClass('layout__region', 'layout__region--second') }}>
|
||||
{{ content.second }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if content.third %}
|
||||
<div {{ region_attributes.third.addClass('layout__region', 'layout__region--third') }}>
|
||||
{{ content.third }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if content.bottom %}
|
||||
<div {{ region_attributes.bottom.addClass('layout__region', 'layout__region--bottom') }}>
|
||||
{{ content.bottom }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* @file
|
||||
* Provides the layout styles for layout_threecol_25_50_25.
|
||||
*
|
||||
* @todo Using display: flex requires https://www.drupal.org/node/2842298 to be
|
||||
* in before this can be marked as stable.
|
||||
*/
|
||||
.layout--threecol-25-50-25 {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.layout--threecol-25-50-25 > .layout__region,
|
||||
.layout--threecol-25-50-25 > .layout__region--second {
|
||||
flex: 0 1 100%;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 40em) {
|
||||
.layout--threecol-25-50-25 > .layout__region--first,
|
||||
.layout--threecol-25-50-25 > .layout__region--third {
|
||||
flex: 0 1 25%;
|
||||
}
|
||||
.layout--threecol-25-50-25 > .layout__region--second {
|
||||
flex: 0 1 50%;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
{#
|
||||
/**
|
||||
* @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',
|
||||
'layout--threecol-33-34-33',
|
||||
]
|
||||
%}
|
||||
{% if content %}
|
||||
<div{{ attributes.addClass(classes) }}>
|
||||
{% if content.top %}
|
||||
<div {{ region_attributes.top.addClass('layout__region', 'layout__region--top') }}>
|
||||
{{ content.top }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if content.first %}
|
||||
<div {{ region_attributes.first.addClass('layout__region', 'layout__region--first') }}>
|
||||
{{ content.first }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if content.second %}
|
||||
<div {{ region_attributes.second.addClass('layout__region', 'layout__region--second') }}>
|
||||
{{ content.second }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if content.third %}
|
||||
<div {{ region_attributes.third.addClass('layout__region', 'layout__region--third') }}>
|
||||
{{ content.third }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if content.bottom %}
|
||||
<div {{ region_attributes.bottom.addClass('layout__region', 'layout__region--bottom') }}>
|
||||
{{ content.bottom }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* @file
|
||||
* Provides the layout styles for layout_threecol_33_34_33.
|
||||
*
|
||||
* @todo Using display: flex requires https://www.drupal.org/node/2842298 to be
|
||||
* in before this can be marked as stable.
|
||||
*/
|
||||
|
||||
.layout--threecol-33-34-33 {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.layout--threecol-33-34-33 > .layout__region {
|
||||
flex: 0 1 100%;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 40em) {
|
||||
.layout--threecol-33-34-33 > .layout__region--first,
|
||||
.layout--threecol-33-34-33 > .layout__region--third {
|
||||
flex: 0 1 33%;
|
||||
}
|
||||
.layout--threecol-33-34-33 > .layout__region--second {
|
||||
flex: 0 1 34%;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
{#
|
||||
/**
|
||||
* @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',
|
||||
'layout--twocol',
|
||||
]
|
||||
%}
|
||||
{% if content %}
|
||||
<div{{ attributes.addClass(classes) }}>
|
||||
{% if content.top %}
|
||||
<div {{ region_attributes.top.addClass('layout__region', 'layout__region--top') }}>
|
||||
{{ content.top }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if content.first %}
|
||||
<div {{ region_attributes.first.addClass('layout__region', 'layout__region--first') }}>
|
||||
{{ content.first }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if content.second %}
|
||||
<div {{ region_attributes.second.addClass('layout__region', 'layout__region--second') }}>
|
||||
{{ content.second }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if content.bottom %}
|
||||
<div {{ region_attributes.bottom.addClass('layout__region', 'layout__region--bottom') }}>
|
||||
{{ content.bottom }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* @file
|
||||
* Provides the layout styles for layout_twocol.
|
||||
*
|
||||
* @todo Using display: flex requires https://www.drupal.org/node/2842298 to be
|
||||
* in before this can be marked as stable.
|
||||
*/
|
||||
|
||||
.layout--twocol {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.layout--twocol > .layout__region {
|
||||
flex: 0 1 100%;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 40em) {
|
||||
.layout--twocol > .layout__region--first,
|
||||
.layout--twocol > .layout__region--second {
|
||||
flex: 0 1 50%;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
{#
|
||||
/**
|
||||
* @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',
|
||||
'layout--twocol-bricks',
|
||||
]
|
||||
%}
|
||||
{% if content %}
|
||||
<div{{ attributes.addClass(classes) }}>
|
||||
{% if content.top %}
|
||||
<div {{ region_attributes.top.addClass('layout__region', 'layout__region--top') }}>
|
||||
{{ content.top }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if content.first_above %}
|
||||
<div {{ region_attributes.first_above.addClass('layout__region', 'layout__region--first-above') }}>
|
||||
{{ content.first_above }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if content.second_above %}
|
||||
<div {{ region_attributes.second_above.addClass('layout__region', 'layout__region--second-above') }}>
|
||||
{{ content.second_above }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if content.middle %}
|
||||
<div {{ region_attributes.middle.addClass('layout__region', 'layout__region--middle') }}>
|
||||
{{ content.middle }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if content.first_below %}
|
||||
<div {{ region_attributes.first_below.addClass('layout__region', 'layout__region--first-below') }}>
|
||||
{{ content.first_below }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if content.second_below %}
|
||||
<div {{ region_attributes.second_below.addClass('layout__region', 'layout__region--second-below') }}>
|
||||
{{ content.second_below }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if content.bottom %}
|
||||
<div {{ region_attributes.bottom.addClass('layout__region', 'layout__region--bottom') }}>
|
||||
{{ content.bottom }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* @file
|
||||
* Provides the layout styles for layout_twocol_bricks.
|
||||
*
|
||||
* @todo Using display: flex requires https://www.drupal.org/node/2842298 to be
|
||||
* in before this can be marked as stable.
|
||||
*/
|
||||
|
||||
.layout--twocol-bricks {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.layout--twocol-bricks > .layout__region {
|
||||
flex: 0 1 100%;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 40em) {
|
||||
.layout--twocol-bricks > .layout__region--first-above,
|
||||
.layout--twocol-bricks > .layout__region--second-above,
|
||||
.layout--twocol-bricks > .layout__region--first-below,
|
||||
.layout--twocol-bricks > .layout__region--second-below {
|
||||
flex: 0 1 50%;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
{#
|
||||
/**
|
||||
* @file
|
||||
* Template for a generic layout.
|
||||
*/
|
||||
#}
|
||||
{%
|
||||
set classes = [
|
||||
'layout',
|
||||
'layout--' ~ layout.id|clean_class,
|
||||
]
|
||||
%}
|
||||
{% if content %}
|
||||
<div{{ attributes.addClass(classes) }}>
|
||||
{% for region in layout.getRegionNames %}
|
||||
{% if content[region] %}
|
||||
<div {{ region_attributes[region].addClass('layout__region', 'layout__region--' ~ region|clean_class) }}>
|
||||
{{ content[region] }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
@ -0,0 +1,237 @@
|
|||
<?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');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @dataProvider renderLayoutData
|
||||
*/
|
||||
public function testRenderLayout($layout_id, $config, $regions, array $html) {
|
||||
$layout = $this->layoutPluginManager->createInstance($layout_id, $config);
|
||||
$built['layout'] = $layout->build($regions);
|
||||
$built['layout']['#prefix'] = 'Test prefix' . "\n";
|
||||
$built['layout']['#suffix'] = 'Test suffix' . "\n";
|
||||
|
||||
// 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);
|
||||
|
||||
// Add in the wrapping form elements and prefix/suffix.
|
||||
array_unshift($html, 'Test prefix');
|
||||
array_unshift($html, '<form data-drupal-selector="the-form-id" action="/" method="post" id="the-form-id" accept-charset="UTF-8">');
|
||||
// Retrieve the build ID from the rendered HTML since the string is random.
|
||||
$build_id_input = $this->cssSelect('input[name="form_build_id"]')[0]->asXML();
|
||||
$form_id_input = '<input data-drupal-selector="edit-the-form-id" type="hidden" name="form_id" value="the_form_id"/>';
|
||||
$html[] = 'Test suffix';
|
||||
$html[] = $build_id_input . $form_id_input . '</form>';
|
||||
|
||||
// Match the HTML to the full form element.
|
||||
$this->assertSame(implode("\n", $html), $this->cssSelect('#the-form-id')[0]->asXML());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function render(array &$elements) {
|
||||
$content = parent::render($elements);
|
||||
// Strip leading whitespace from every line.
|
||||
$this->content = preg_replace('/^\s+/m', '', $content);
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testRenderLayout().
|
||||
*/
|
||||
public function renderLayoutData() {
|
||||
$html = [];
|
||||
$html[] = '<div data-drupal-selector="edit-layout" class="layout layout--onecol">';
|
||||
$html[] = '<div data-drupal-selector="edit-content" class="layout__region layout__region--content">';
|
||||
$html[] = 'This is the content';
|
||||
$html[] = '</div>';
|
||||
$html[] = '</div>';
|
||||
$data['layout_onecol'] = [
|
||||
'layout_onecol',
|
||||
[],
|
||||
[
|
||||
'content' => [
|
||||
'#markup' => 'This is the content',
|
||||
],
|
||||
],
|
||||
$html,
|
||||
];
|
||||
|
||||
$html = [];
|
||||
$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 data-drupal-selector="edit-bottom" class="region-bottom">';
|
||||
$html[] = 'This is the bottom';
|
||||
$html[] = '</div>';
|
||||
$html[] = '</div>';
|
||||
$data['layout_test_1col_with_form'] = [
|
||||
'layout_test_1col',
|
||||
[],
|
||||
[
|
||||
'top' => [
|
||||
'#process' => [[static::class, 'processCallback']],
|
||||
],
|
||||
'bottom' => [
|
||||
'#markup' => 'This is the bottom',
|
||||
],
|
||||
],
|
||||
$html,
|
||||
];
|
||||
|
||||
$html = [];
|
||||
$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 data-drupal-selector="edit-bottom" class="region-bottom">';
|
||||
$html[] = 'This is the bottom';
|
||||
$html[] = '</div>';
|
||||
$html[] = '</div>';
|
||||
$data['layout_test_1col'] = [
|
||||
'layout_test_1col',
|
||||
[],
|
||||
[
|
||||
'top' => [
|
||||
'#markup' => 'This is the top',
|
||||
],
|
||||
'bottom' => [
|
||||
'#markup' => 'This is the bottom',
|
||||
],
|
||||
],
|
||||
$html,
|
||||
];
|
||||
|
||||
$html = [];
|
||||
$html[] = '<div data-drupal-selector="edit-layout" class="layout layout--layout-test-1col-no-template">';
|
||||
$html[] = '<div data-drupal-selector="edit-top" class="layout__region layout__region--top">';
|
||||
$html[] = 'This is the top';
|
||||
$html[] = '</div>';
|
||||
$html[] = '<div data-drupal-selector="edit-bottom" class="layout__region layout__region--bottom">';
|
||||
$html[] = 'This is the bottom';
|
||||
$html[] = '</div>';
|
||||
$html[] = '</div>';
|
||||
$data['layout_test_1col_no_template'] = [
|
||||
'layout_test_1col_no_template',
|
||||
[],
|
||||
[
|
||||
'top' => [
|
||||
'#markup' => 'This is the top',
|
||||
],
|
||||
'bottom' => [
|
||||
'#markup' => 'This is the bottom',
|
||||
],
|
||||
],
|
||||
$html,
|
||||
];
|
||||
|
||||
$html = [];
|
||||
$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 data-drupal-selector="edit-right" class="region-right">';
|
||||
$html[] = 'This is the right';
|
||||
$html[] = '</div>';
|
||||
$html[] = '</div>';
|
||||
$data['layout_test_2col'] = [
|
||||
'layout_test_2col',
|
||||
[],
|
||||
[
|
||||
'left' => [
|
||||
'#markup' => 'This is the left',
|
||||
],
|
||||
'right' => [
|
||||
'#markup' => 'This is the right',
|
||||
],
|
||||
],
|
||||
$html,
|
||||
];
|
||||
|
||||
$html = [];
|
||||
$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 data-drupal-selector="edit-main" class="region-main">';
|
||||
$html[] = 'Main region';
|
||||
$html[] = '</div>';
|
||||
$html[] = '</div>';
|
||||
$data['layout_test_plugin'] = [
|
||||
'layout_test_plugin',
|
||||
[
|
||||
'setting_1' => 'Config value',
|
||||
],
|
||||
[
|
||||
'main' => [
|
||||
'#markup' => 'Main region',
|
||||
],
|
||||
],
|
||||
$html,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a test #process callback.
|
||||
*/
|
||||
public static function processCallback($element) {
|
||||
$element['#markup'] = 'This string added by #process.';
|
||||
return $element;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
{{ content.content }}
|
||||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
test_layout_theme:
|
||||
label: 'Test Layout - Theme'
|
||||
category: 'Test Layout Theme'
|
||||
template: templates/test-layout-theme
|
||||
regions:
|
||||
content:
|
||||
label: Content
|
||||
Reference in a new issue