Move into nested docroot

This commit is contained in:
Rob Davies 2017-02-13 15:31:17 +00:00
parent 83a0d3a149
commit c8b70abde9
13405 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,55 @@
<?php
/**
* @file
* Handles integration of Nyan cat templates because we love kittens.
*/
use Drupal\Core\Extension\Extension;
/**
* Includes .theme file from themes.
*
* @param \Drupal\Core\Extension\Extension $theme
* The theme extension object.
*/
function nyan_cat_init(Extension $theme) {
$theme->load();
}
/**
* Implements hook_theme().
*/
function nyan_cat_theme($existing, $type, $theme, $path) {
$templates = drupal_find_theme_functions($existing, array($theme));
$templates += drupal_find_theme_templates($existing, '.nyan-cat.html', $path);
return $templates;
}
/**
* Implements hook_extension().
*/
function nyan_cat_extension() {
return '.nyan-cat.html';
}
/**
* Implements hook_render_template().
*
* @param string $template_file
* The filename of the template to render.
* @param mixed[] $variables
* A keyed array of variables that will appear in the output.
*
* @return string
* The output generated by the template.
*/
function nyan_cat_render_template($template_file, $variables) {
$output = str_replace('div', 'nyancat', file_get_contents(\Drupal::root() . '/' . $template_file));
foreach ($variables as $key => $variable) {
if (strpos($output, '9' . $key) !== FALSE) {
$output = str_replace('9' . $key, theme_render_and_autoescape($variable), $output);
}
}
return $output;
}

View file

@ -0,0 +1,5 @@
type: theme_engine
name: Nyan cat
core: 8.x
version: VERSION
package: Core

View file

@ -0,0 +1,13 @@
# Themes are not supposed to provide/install this kind of config normally.
# This exists for testing purposes only.
# @see \Drupal\KernelTests\Core\Theme\ThemeInstallerTest
id: fancy
label: 'Fancy date'
status: true
langcode: en
locked: false
pattern: 'U'
dependencies:
enforced:
theme:
- test_basetheme

View file

@ -0,0 +1,4 @@
features:
favicon: false
base: only
override: base

View file

@ -0,0 +1,10 @@
test_basetheme.settings:
type: theme_settings
label: 'Test base theme settings'
mapping:
base:
type: string
label: 'Base theme setting'
override:
type: string
label: 'Whether the setting has been overridden'

View file

@ -0,0 +1,24 @@
name: 'Theme test base theme'
type: theme
description: 'Test theme which acts as a base theme for other test subthemes.'
version: VERSION
core: 8.x
base theme: false
hidden: true
libraries:
- test_basetheme/global-styling
stylesheets-remove:
- '@theme_test/css/base-remove.css'
libraries-override:
core/drupal.dialog:
js:
misc/dialog/dialog.js: false
core/jquery.farbtastic:
css:
component:
assets/vendor/farbtastic/farbtastic.css: css/farbtastic.css
libraries-extend:
classy/base:
- test_basetheme/global-styling

View file

@ -0,0 +1,8 @@
global-styling:
version: VERSION
css:
base:
base-add.css: {}
base-add.sub-remove.css: {}
samename.css: {}
css/base-libraries-extend.css: {}

View file

@ -0,0 +1,37 @@
<?php
/**
* @file
* Add hooks for tests to use.
*/
use Drupal\views\Plugin\views\cache\CachePluginBase;
use Drupal\views\ViewExecutable;
/**
* Implements hook_views_pre_render().
*/
function test_basetheme_views_pre_render(ViewExecutable $view) {
// We append the function name to the title for test to check for.
$view->setTitle($view->getTitle() . ":" . __FUNCTION__);
}
/**
* Implements hook_views_post_render().
*/
function test_basetheme_views_post_render(ViewExecutable $view, &$output, CachePluginBase $cache) {
// We append the function name to the title for test to check for.
$view->setTitle($view->getTitle() . ":" . __FUNCTION__);
}
/**
* Implements hook_preprocess_HOOK() for theme_test_template_test templates.
*/
function test_basetheme_preprocess_theme_test_template_test(&$variables) {
}
/**
* Implements hook_preprocess_HOOK() for theme_test_function_suggestions theme functions.
*/
function test_basetheme_preprocess_theme_test_function_suggestions(&$variables) {
}

View file

@ -0,0 +1,9 @@
name: Test external CKEditor stylesheets
type: theme
description: 'A theme that uses an external CKEditor stylesheet.'
version: VERSION
base theme: false
core: 8.x
ckeditor_stylesheets:
- https://fonts.googleapis.com/css?family=Open+Sans

View file

@ -0,0 +1,9 @@
name: Test protocol-relative CKEditor stylesheets
type: theme
description: 'A theme that uses a protocol-relative CKEditor stylesheet.'
version: VERSION
base theme: false
core: 8.x
ckeditor_stylesheets:
- //fonts.googleapis.com/css?family=Open+Sans

View file

@ -0,0 +1,4 @@
/**
* @file
* Test CSS asset file for test_ckeditor_stylesheets_relative.theme.
*/

View file

@ -0,0 +1,9 @@
name: Test relative CKEditor stylesheets
type: theme
description: 'A theme that uses a relative CKEditor stylesheet.'
version: VERSION
base theme: false
core: 8.x
ckeditor_stylesheets:
- css/yokotsoko.css

View file

@ -0,0 +1,6 @@
name: 'Theme test with invalid base theme'
type: theme
description: 'Test theme which has a non-existent base theme.'
version: VERSION
core: 8.x
base theme: not_real_test_basetheme

View file

@ -0,0 +1,6 @@
name: 'Theme test with valid base theme but no grandparent base theme'
type: theme
description: 'Test theme which has a non-existent base theme in the base chain.'
version: VERSION
core: 8.x
base theme: test_invalid_basetheme

View file

@ -0,0 +1,5 @@
name: 'Theme test with invalid core version'
type: theme
description: 'Test theme which has an invalid core version.'
version: VERSION
core: 7.x

View file

@ -0,0 +1,7 @@
name: 'Theme test with invalid theme engine'
type: theme
description: 'Test theme which has a non-existent theme engine.'
version: VERSION
core: 8.x
engine: not_real_engine
base theme: false

View file

@ -0,0 +1,8 @@
name: 'Theme test with missing content region'
type: theme
description: 'Test theme which has a non-existent content region.'
version: VERSION
core: 8.x
regions:
- foo: Foo

View file

@ -0,0 +1,5 @@
name: Test Stable
type: theme
description: A theme to test that stable is set as the default.
version: VERSION
core: 8.x

View file

@ -0,0 +1,13 @@
<?php
/**
* @file
* Test preprocess functions for theme test_stable.
*/
/**
* Implements hook_preprocess_theme_test_render_element().
*/
function test_stable_preprocess_theme_test_render_element($variables) {
// This is used for Drupal\Tests\Core\Theme\RegistryTest.
}

View file

@ -0,0 +1,6 @@
name: 'Theme test subsubtheme'
type: theme
description: 'Test theme which uses test_subtheme as the base theme.'
version: VERSION
core: 8.x
base theme: test_subtheme

View file

@ -0,0 +1,12 @@
<?php
/**
* @file
* Add hooks for tests to use.
*/
/**
* Implements hook_preprocess_HOOK() for theme_test_template_test templates.
*/
function test_subsubtheme_preprocess_theme_test_template_test(&$variables) {
}

View file

@ -0,0 +1,7 @@
test_subtheme.settings:
type: theme_settings
label: 'Test sub theme settings'
mapping:
override:
type: string
label: 'Whether the setting has been overridden'

View file

@ -0,0 +1,15 @@
name: 'Theme test subtheme'
type: theme
description: 'Test theme which uses test_basetheme as the base theme.'
version: VERSION
core: 8.x
base theme: test_basetheme
libraries:
- test_subtheme/global-styling
stylesheets-remove:
- '@theme_test/css/sub-remove.css'
- '@test_basetheme/base-add.sub-remove.css'
libraries-extend:
classy/base:
- test_subtheme/global-styling

View file

@ -0,0 +1,7 @@
global-styling:
version: VERSION
css:
base:
css/sub-add.css: {}
css/samename.css: {}
css/sub-libraries-extend.css: {}

View file

@ -0,0 +1,34 @@
<?php
/**
* @file
* Add hooks for tests to use.
*/
use Drupal\views\Plugin\views\cache\CachePluginBase;
use Drupal\views\ViewExecutable;
/**
* Implements hook_views_pre_render().
*/
function test_subtheme_views_pre_render(ViewExecutable $view) {
// We append the function name to the title for test to check for.
$view->setTitle($view->getTitle() . ":" . __FUNCTION__);
}
/**
* Implements hook_views_post_render().
*/
function test_subtheme_views_post_render(ViewExecutable $view, &$output, CachePluginBase $cache) {
// We append the function name to the title for test to check for.
$view->setTitle($view->getTitle() . ":" . __FUNCTION__);
if ($view->id() == 'test_page_display') {
$output['#rows'][0]['#title'] = t('%total_rows items found.', array('%total_rows' => $view->total_rows));
}
}
/**
* Implements hook_preprocess_HOOK() for theme_test_template_test templates.
*/
function test_subtheme_preprocess_theme_test_template_test(&$variables) {
}

View file

@ -0,0 +1,4 @@
/**
* @file
* Test CSS asset file for test_theme.theme.
*/

View file

@ -0,0 +1,4 @@
/**
* @file
* Test JS asset file for test_theme.theme.
*/

View file

@ -0,0 +1,4 @@
{#
// node--1.html.twig - Dummy file for finding the template
#}
Node Content Dummy

View file

@ -0,0 +1,8 @@
<?php
namespace Drupal\test_theme;
/**
* Represents a random class, used to test if themes can provide classes.
*/
class ThemeClass { }

View file

@ -0,0 +1,13 @@
{#
/**
* @file
* Minimal template to ensure chained property access works with white-listing.
*/
#}
<article{{ attributes }}>
<div>
{{ node.field_term.entity.label }}
</div>
</article>

View file

@ -0,0 +1,2 @@
{# Output for Theme API test #}
Template overridden based on new theme suggestion provided by a module via hook_theme_suggestions_alter().

View file

@ -0,0 +1,2 @@
{# Output for Theme API test #}
Template overridden based on new theme suggestion provided by the test_theme theme via hook_theme_suggestions_alter().

View file

@ -0,0 +1,4 @@
<div class="suggestion">{{ foo }}</div>
{% if bar %}
<div class="suggestion">{{ bar }}</div>
{% endif %}

View file

@ -0,0 +1 @@
<div class="suggestion">{{ foo }}</div>

View file

@ -0,0 +1,5 @@
{# Output for Theme API test #}
Template overridden based on suggestion alter hook determined by the base hook.
<p>Theme hook suggestions:
{{ theme_hook_suggestions|safe_join("<br />") }}</p>

View file

@ -0,0 +1,5 @@
{# Output for Theme API test #}
Template matching the specific theme call.
<p>Theme hook suggestions:
{{ theme_hook_suggestions|safe_join("<br />") }}</p>

View file

@ -0,0 +1,2 @@
{# Output for Theme API test #}
Template overridden based on suggestion provided by the module declaring the theme hook.

View file

@ -0,0 +1,2 @@
{# Output for Theme API test #}
Template overridden based on new theme suggestion provided by a module via hook_theme_suggestions_HOOK_alter().

View file

@ -0,0 +1,2 @@
{# Output for Theme API test #}
Template overridden based on new theme suggestion provided by the test_theme theme via hook_theme_suggestions_HOOK_alter().

View file

@ -0,0 +1,67 @@
# Normally, themes may list CSS files like this, and if they exist in the theme
# folder, then they get added to the page. If they have the same file name as a
# module CSS file, then the theme's version overrides the module's version, so
# that the module's version is not added to the page. Additionally, a theme may
# have an entry like this one, without having the corresponding CSS file in the
# theme's folder, and in this case, it just stops the module's version from
# being loaded, and does not replace it with an alternate version. We have this
# here in order for a test to ensure that this correctly prevents the module
# version from being loaded, and that errors aren't caused by the lack of this
# file within the theme folder.
name: '<strong>Test theme</strong>'
type: theme
description: 'Theme for testing the theme system'
version: VERSION
base theme: classy
core: 8.x
stylesheets-remove:
- '@system/css/js.module.css'
libraries:
- test_theme/global-styling
libraries-override:
# Replace an entire library.
core/drupal.collapse: test_theme/collapse
# Remove an entire library.
core/drupal.progress: false
# Replace particular library assets.
classy/base:
css:
component:
css/components/button.css: css/my-button.css
css/components/collapse-processed.css: css/my-collapse-processed.css
css/components/container-inline.css: /themes/my_theme/css/my-container-inline.css
css/components/details.css: /themes/my_theme/css/my-details.css
# Remove particular library assets.
classy/dialog:
css:
component:
css/components/dialog.css: false
# It works for JS as well.
core/jquery:
js:
assets/vendor/jquery/jquery.min.js: js/collapse.js
# Use Drupal-relative paths.
core/drupal.dropbutton:
css:
component:
/core/themes/stable/css/core/dropbutton/dropbutton.css: /themes/my_theme/css/dropbutton.css
# Use stream wrappers.
core/drupal.vertical-tabs:
css:
component:
/core/themes/stable/css/core/vertical-tabs.css: public://my_css/vertical-tabs.css
# Use a protocol-relative URI.
core/jquery.ui:
css:
component:
assets/vendor/jquery.ui/themes/base/core.css: //my-server/my_theme/css/jquery_ui.css
# Use an absolute URI.
core/jquery.farbtastic:
css:
component:
assets/vendor/farbtastic/farbtastic.css: http://example.com/my_theme/css/farbtastic.css
regions:
content: Content
left: Left
right: Right

View file

@ -0,0 +1,13 @@
global-styling:
version: VERSION
css:
base:
kitten.css: {}
collapse:
version: VERSION
js:
js/collapse.js: { }
css:
base:
css/collapse.css: { }

View file

@ -0,0 +1,156 @@
<?php
/**
* @file
* Theme to help test the Twig engine.
*/
/**
* Implements THEME_preprocess_twig_theme_test_php_variables().
*/
function test_theme_preprocess_twig_theme_test_php_variables(&$variables) {
$variables['php_values'] = _test_theme_twig_php_values();
}
/**
* Tests a theme overriding a suggestion of a base theme hook.
*/
function test_theme_theme_test__suggestion($variables) {
return 'Theme hook implementor=test_theme_theme_test__suggestion(). Foo=' . $variables['foo'];
}
/**
* Implements hook_element_info_alter().
*/
function test_theme_element_info_alter(&$info) {
// Decrease the default size of textfields.
if (isset($info['textfield']['#size'])) {
$info['textfield']['#size'] = 40;
}
}
/**
* Implements hook_library_info_alter().
*/
function test_theme_library_info_alter(&$libraries, $extension) {
if ($extension === 'test_theme') {
$libraries['kitten']['js']['kittens.js'] = [];
}
}
/**
* Tests a theme implementing an alter hook.
*
* The confusing function name here is due to this being an implementation of
* the alter hook invoked when the 'theme_test' module calls
* \Drupal::moduleHandler->alter('theme_test_alter').
*/
function test_theme_theme_test_alter_alter(&$data) {
$data = 'test_theme_theme_test_alter_alter was invoked';
}
/**
* Implements hook_theme_suggestions_alter().
*/
function test_theme_theme_suggestions_alter(array &$suggestions, array $variables, $hook) {
drupal_set_message(__FUNCTION__ . '() executed.');
// Theme alter hooks run after module alter hooks, so add this theme
// suggestion to the beginning of the array so that the suggestion added by
// the theme_suggestions_test module can be picked up when that module is
// enabled.
if ($hook == 'theme_test_general_suggestions') {
array_unshift($suggestions, 'theme_test_general_suggestions__' . 'theme_override');
}
}
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function test_theme_theme_suggestions_theme_test_suggestions_alter(array &$suggestions, array $variables) {
drupal_set_message(__FUNCTION__ . '() executed.');
// Theme alter hooks run after module alter hooks, so add this theme
// suggestion to the beginning of the array so that the suggestion added by
// the theme_suggestions_test module can be picked up when that module is
// enabled.
array_unshift($suggestions, 'theme_test_suggestions__' . 'theme_override');
}
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function test_theme_theme_suggestions_theme_test_function_suggestions_alter(array &$suggestions, array $variables) {
// Theme alter hooks run after module alter hooks, so add this theme
// suggestion to the beginning of the array so that the suggestion added by
// the theme_suggestions_test module can be picked up when that module is
// enabled.
array_unshift($suggestions, 'theme_test_function_suggestions__' . 'theme_override');
}
/**
* Returns HTML for a theme function suggestion test.
*
* Implements the theme_test_function_suggestions__theme_override suggestion.
*/
function test_theme_theme_test_function_suggestions__theme_override($variables) {
return 'Theme function overridden based on new theme suggestion provided by the test_theme theme.';
}
/**
* Returns HTML for a theme function suggestion test.
*
* Implements the theme_test_function_suggestions__module_override suggestion.
*/
function test_theme_theme_test_function_suggestions__module_override($variables) {
return 'Theme function overridden based on new theme suggestion provided by a module.';
}
/**
* Implements hook_theme_registry_alter().
*/
function test_theme_theme_registry_alter(&$registry) {
$registry['theme_test_template_test']['variables']['additional'] = 'value';
}
/**
* Tests a theme overriding a suggestion of a base theme hook.
*/
function test_theme_theme_test_preprocess_suggestions__kitten__meerkat($variables) {
return 'Theme hook implementor=test_theme_theme_test__suggestion(). Foo=' . $variables['foo'];
}
/**
* Tests a theme overriding a default hook with a suggestion.
*
* Implements hook_preprocess_HOOK().
*/
function test_theme_preprocess_theme_test_preprocess_suggestions(&$variables) {
$variables['foo'] = 'Theme hook implementor=test_theme_preprocess_theme_test_preprocess_suggestions().';
}
/**
* Tests a theme overriding a default hook with a suggestion.
*/
function test_theme_preprocess_theme_test_preprocess_suggestions__suggestion(&$variables) {
$variables['foo'] = 'Suggestion';
}
/**
* Tests a theme overriding a default hook with a suggestion.
*/
function test_theme_preprocess_theme_test_preprocess_suggestions__kitten(&$variables) {
$variables['foo'] = 'Kitten';
}
/**
* Tests a theme overriding a default hook with a suggestion.
*/
function test_theme_preprocess_theme_test_preprocess_suggestions__kitten__flamingo(&$variables) {
$variables['bar'] = 'Flamingo';
}
/**
* Tests a preprocess function with suggestions.
*/
function test_theme_preprocess_theme_test_preprocess_suggestions__kitten__meerkat__tarsier__moose(&$variables) {
$variables['bar'] = 'Moose';
}

View file

@ -0,0 +1,2 @@
{# Output for Theme API test #}
Success: Template overrides theme function.

View file

@ -0,0 +1,2 @@
{# Output for Theme API test #}
Success: Template overridden.

View file

@ -0,0 +1,4 @@
type: theme
core: 8.x
name: 'Test theme with a too long name'
version: VERSION

View file

@ -0,0 +1,8 @@
name: 'Test theme libraries empty'
type: theme
description: 'Test theme with empty libraries in theme.info.yml'
version: VERSION
base theme: classy
core: 8.x
libraries:

View file

@ -0,0 +1,15 @@
name: 'Test theme libraries-extend'
type: theme
description: 'Test Theme with libraries-extend'
version: VERSION
base theme: classy
core: 8.x
libraries-extend:
classy/book-navigation:
- test_theme_libraries_extend/extend_one
- test_theme_libraries_extend/extend_two
core/drupal.dialog:
- test_theme_libraries_extend/non_existent_library
test_theme/collapse:
- not_a_string:
expected: 'an exception'

View file

@ -0,0 +1,11 @@
extend_one:
css:
theme:
css/extend_1.css: { }
js:
js/extend_1.js: { }
extend_two:
css:
theme:
css/extend_2.css: { }

View file

@ -0,0 +1,12 @@
name: 'Test theme libraries-override'
type: theme
description: 'Theme with drupalSettings libraries-override'
version: VERSION
base theme: classy
core: 8.x
libraries-override:
# drupalSettings libraries override. Should throw a
# \Drupal\Core\Asset\Exception\InvalidLibrariesOverrideSpecificationException.
core/drupal.ajax:
drupalSettings:
ajaxPageState: { }

View file

@ -0,0 +1,11 @@
name: 'Test theme libraries-override'
type: theme
description: 'Theme with invalid libraries-override asset spec.'
version: VERSION
base theme: classy
core: 8.x
libraries-override:
# A malformed library asset name. Should throw a
# \Drupal\Core\Asset\Exception\InvalidLibrariesOverrideSpecificationException.
core/drupal.dialog:
css: false

View file

@ -0,0 +1,7 @@
name: 'Test theme for Nyan Cat engine'
type: theme
description: 'Theme for testing the theme system with the Nyan Cat theme engine'
version: VERSION
core: 8.x
engine: nyan_cat
base theme: false

View file

@ -0,0 +1,13 @@
<?php
/**
* @file
* Test theme.
*/
/**
* Implements hook_preprocess_theme_test_template_test().
*/
function test_theme_nyan_cat_engine_preprocess_theme_test_template_test(&$variables) {
$variables['kittens'] = 'All of them';
}

View file

@ -0,0 +1 @@
Success: Template overridden with Nyan Cat theme. 9kittens

View file

@ -0,0 +1,5 @@
This line is from test_theme_twig_registry_loader/templates/twig-registry-loader-test-extend.html.twig
{% block content %}
This text is in a block.
{% endblock %}

View file

@ -0,0 +1 @@
This line is from test_theme_twig_registry_loader/templates/twig-registry-loader-test-include.html.twig

View file

@ -0,0 +1,5 @@
name: 'Twig registry loader test'
type: theme
description: 'Support module for Twig registry loader testing.'
version: VERSION
core: 8.x

View file

@ -0,0 +1,6 @@
name: 'Twig registry loader test subtheme'
type: theme
base theme: test_theme_twig_registry_loader_theme
description: 'Support module for Twig registry loader testing.'
version: VERSION
core: 8.x

View file

@ -0,0 +1,5 @@
This line is from test_theme_twig_registry_loader_theme/templates/twig-registry-loader-test-extend.html.twig
{% block content %}
This text is in a block.
{% endblock %}

View file

@ -0,0 +1 @@
This line is from test_theme_twig_registry_loader_theme/templates/twig-registry-loader-test-include.html.twig

View file

@ -0,0 +1,6 @@
name: 'Twig registry loader test theme'
type: theme
base theme: test_theme_twig_registry_loader
description: 'Support module for Twig registry loader testing.'
version: VERSION
core: 8.x

View file

@ -0,0 +1,6 @@
name: Test Wild West
type: theme
description: A theme that doesn't use Stable as its base. It tests the wild west instead.
version: VERSION
base theme: false
core: 8.x