diff --git a/core/includes/theme.inc b/core/includes/theme.inc index b349918..1f2694f 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1514,7 +1514,6 @@ function template_preprocess_feed_icon(&$variables) { '#height' => 16, '#alt' => $text, ); - $variables['attributes']['class'] = array('feed-icon'); // Stripping tags because that's what l() used to do. $variables['attributes']['title'] = strip_tags($text); } @@ -2262,39 +2261,30 @@ function drupal_common_theme() { // From theme.inc. 'html' => array( 'variables' => array('page_object' => NULL), - 'template' => 'html', ), 'page' => array( 'render element' => 'page', - 'template' => 'page', ), 'region' => array( 'render element' => 'elements', - 'template' => 'region', ), 'time' => array( 'variables' => array('timestamp' => NULL, 'text' => NULL, 'attributes' => array(), 'html' => FALSE), - 'template' => 'time', ), 'datetime_form' => array( - 'template' => 'datetime-form', 'render element' => 'element', ), 'datetime_wrapper' => array( - 'template' => 'datetime-wrapper', 'render element' => 'element', ), 'status_messages' => array( 'variables' => array('display' => NULL), - 'template' => 'status-messages', ), 'links' => array( 'variables' => array('links' => array(), 'attributes' => array('class' => array('links')), 'heading' => array(), 'set_active_class' => FALSE), - 'template' => 'links', ), 'dropbutton_wrapper' => array( 'variables' => array('children' => NULL), - 'template' => 'dropbutton-wrapper', ), 'image' => array( // HTML 4 and XHTML 1.0 always require an alt attribute. The HTML 5 draft @@ -2310,140 +2300,114 @@ function drupal_common_theme() { // The title attribute is optional in all cases, so it is omitted by // default. 'variables' => array('uri' => NULL, 'width' => NULL, 'height' => NULL, 'alt' => '', 'title' => NULL, 'attributes' => array()), - 'template' => 'image', ), 'breadcrumb' => array( 'variables' => array('links' => array()), - 'template' => 'breadcrumb', ), 'table' => array( 'variables' => array('header' => NULL, 'rows' => NULL, 'footer' => NULL, 'attributes' => array(), 'caption' => NULL, 'colgroups' => array(), 'sticky' => FALSE, 'responsive' => TRUE, 'empty' => ''), - 'template' => 'table', ), 'tablesort_indicator' => array( 'variables' => array('style' => NULL), - 'template' => 'tablesort-indicator', ), 'mark' => array( 'variables' => array('status' => MARK_NEW), - 'template' => 'mark', ), 'item_list' => array( 'variables' => array('items' => array(), 'title' => '', 'list_type' => 'ul', 'attributes' => array(), 'empty' => NULL), - 'template' => 'item-list', ), 'feed_icon' => array( 'variables' => array('url' => NULL, 'title' => NULL), - 'template' => 'feed-icon', ), 'progress_bar' => array( 'variables' => array('label' => NULL, 'percent' => NULL, 'message' => NULL), - 'template' => 'progress-bar', ), 'indentation' => array( 'variables' => array('size' => 1), + 'function' => 'theme_indentation', ), // From theme.maintenance.inc. 'maintenance_page' => array( 'render element' => 'page', - 'template' => 'maintenance-page', ), 'install_page' => array( 'render element' => 'page', - 'template' => 'install-page', ), 'task_list' => array( 'variables' => array('items' => NULL, 'active' => NULL, 'variant' => NULL), - 'template' => 'task-list', ), 'authorize_message' => array( 'variables' => array('message' => NULL, 'success' => TRUE), + 'function' => 'theme_authorize_message', ), 'authorize_report' => array( 'variables' => array('messages' => array()), + 'function' => 'theme_authozie_report', ), // From pager.inc. 'pager' => array( 'variables' => array('tags' => array(), 'element' => 0, 'parameters' => array(), 'quantity' => 9), - 'template' => 'pager', ), // From menu.inc. 'menu_link' => array( 'render element' => 'element', + 'function' => 'theme_menu_link', ), 'menu_tree' => array( 'render element' => 'tree', - 'template' => 'menu-tree', ), 'menu_local_task' => array( 'render element' => 'element', - 'template' => 'menu-local-task', ), 'menu_local_action' => array( 'render element' => 'element', - 'template' => 'menu-local-action', ), 'menu_local_tasks' => array( 'variables' => array('primary' => array(), 'secondary' => array()), - 'template' => 'menu-local-tasks', ), // From form.inc. 'input' => array( 'render element' => 'element', - 'template' => 'input', ), 'select' => array( 'render element' => 'element', - 'template' => 'select', ), 'fieldset' => array( 'render element' => 'element', - 'template' => 'fieldset', ), 'details' => array( 'render element' => 'element', - 'template' => 'details', ), 'radios' => array( 'render element' => 'element', - 'template' => 'radios', ), 'checkboxes' => array( 'render element' => 'element', - 'template' => 'checkboxes', ), 'form' => array( 'render element' => 'element', - 'template' => 'form', ), 'textarea' => array( 'render element' => 'element', - 'template' => 'textarea', ), 'form_element' => array( 'render element' => 'element', - 'template' => 'form-element', ), 'form_element_label' => array( 'render element' => 'element', - 'template' => 'form-element-label', ), 'vertical_tabs' => array( 'render element' => 'element', - 'template' => 'vertical-tabs', ), 'container' => array( 'render element' => 'element', - 'template' => 'container', ), // From field system. 'field' => array( 'render element' => 'element', - 'template' => 'field', ), 'field_multiple_value_form' => array( 'render element' => 'element', - 'template' => 'field-multiple-value-form', ), ); } diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php index 0ad005d..ab28c9b 100644 --- a/core/lib/Drupal/Core/Theme/Registry.php +++ b/core/lib/Drupal/Core/Theme/Registry.php @@ -401,6 +401,9 @@ protected function build() { * @see _theme() * @see hook_theme() * @see list_themes() + * @see twig_render_template() + * + * @throws \BadFunctionCallException */ protected function processExtension(&$cache, $name, $type, $theme, $path) { $result = array(); @@ -430,12 +433,6 @@ protected function processExtension(&$cache, $name, $type, $theme, $path) { $result[$hook]['type'] = $type; $result[$hook]['theme path'] = $path; - // If function and file are omitted, default to standard naming - // conventions. - if (!isset($info['template']) && !isset($info['function'])) { - $result[$hook]['function'] = ($type == 'module' ? 'theme_' : $name . '_') . $hook; - } - if (isset($cache[$hook]['includes'])) { $result[$hook]['includes'] = $cache[$hook]['includes']; } @@ -451,20 +448,32 @@ protected function processExtension(&$cache, $name, $type, $theme, $path) { $result[$hook]['includes'][] = $include_file; } + // Templates are the default implementation for a theme hook. If a + // theme hook provides a theme function callback, check to ensure that + // it actually exists. + if (isset($info['function']) && !function_exists($info['function'])) { + continue; + } + // Provide a default naming convention for 'template' based on the + // hook used. If the template does not exist, the theme engine used + // should throw an exception at runtime when attempting to include + // the template file. + elseif (!isset($info['template'])) { + $result[$hook]['template'] = strtr($hook, '_', '-'); + } + + // Prepend the current theming path when none is set. This is required + // for the default theme engine to know where the template lives. + if (isset($result[$hook]['template']) && !isset($info['path'])) { + $result[$hook]['path'] = $path . '/templates'; + } + // If the default keys are not set, use the default values registered // by the module. if (isset($cache[$hook])) { $result[$hook] += array_intersect_key($cache[$hook], $hook_defaults); } - // The following apply only to theming hooks implemented as templates. - if (isset($info['template'])) { - // Prepend the current theming path when none is set. - if (!isset($info['path'])) { - $result[$hook]['template'] = $path . '/templates/' . $info['template']; - } - } - // Preprocess variables for all theming hooks, whether the hook is // implemented as a template or as a function. Ensure they are arrays. if (!isset($info['preprocess functions']) || !is_array($info['preprocess functions'])) { diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index 64eb275..7bf900a 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -59,35 +59,27 @@ function aggregator_theme() { 'aggregator_feed_source' => array( 'variables' => array('aggregator_feed' => NULL, 'view_mode' => NULL), 'file' => 'aggregator.theme.inc', - 'template' => 'aggregator-feed-source', ), 'aggregator_block_item' => array( 'variables' => array('item' => NULL, 'feed' => 0), 'file' => 'aggregator.theme.inc', - 'template' => 'aggregator-block-item', ), 'aggregator_summary_items' => array( 'variables' => array('summary_items' => NULL, 'source' => NULL), 'file' => 'aggregator.theme.inc', - 'template' => 'aggregator-summary-items', ), 'aggregator_summary_item' => array( 'variables' => array('aggregator_item' => NULL, 'view_mode' => NULL), 'file' => 'aggregator.theme.inc', - 'template' => 'aggregator-summary-item', ), 'aggregator_item' => array( 'variables' => array('aggregator_item' => NULL, 'view_mode' => NULL), 'file' => 'aggregator.theme.inc', - 'template' => 'aggregator-item', ), 'aggregator_page_opml' => array( 'variables' => array('feeds' => NULL), 'file' => 'aggregator.theme.inc', - ), - 'aggregator_page_rss' => array( - 'variables' => array('feeds' => NULL), - 'file' => 'aggregator.theme.inc', + 'function' => 'theme_aggregator_page_opml', ), ); } diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 339d163..4e77e24 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -53,11 +53,9 @@ function block_theme() { return array( 'block' => array( 'render element' => 'elements', - 'template' => 'block', ), 'block_list' => array( 'render element' => 'form', - 'template' => 'block-list', ), ); } diff --git a/core/modules/block_content/block_content.module b/core/modules/block_content/block_content.module index dadcf4b..63c8fb3 100644 --- a/core/modules/block_content/block_content.module +++ b/core/modules/block_content/block_content.module @@ -46,7 +46,6 @@ function block_content_theme($existing, $type, $theme, $path) { 'block_content_add_list' => array( 'variables' => array('content' => NULL), 'file' => 'block_content.pages.inc', - 'template' => 'block-content-add-list', ), ); } diff --git a/core/modules/book/book.module b/core/modules/book/book.module index e67b279..4dbd3c4 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -54,30 +54,27 @@ function book_theme() { return array( 'book_navigation' => array( 'variables' => array('book_link' => NULL), - 'template' => 'book-navigation', ), 'book_tree' => array( 'render element' => 'tree', - 'template' => 'book-tree', ), 'book_link' => array( 'render element' => 'element', + 'function' => 'theme_book_link', ), 'book_export_html' => array( 'variables' => array('title' => NULL, 'contents' => NULL, 'depth' => NULL), - 'template' => 'book-export-html', ), 'book_admin_table' => array( 'render element' => 'form', 'file' => 'book.admin.inc', + 'function' => 'theme_book_admin_table', ), 'book_all_books_block' => array( 'render element' => 'book_menus', - 'template' => 'book-all-books-block', ), 'book_node_export_html' => array( 'variables' => array('node' => NULL, 'children' => NULL), - 'template' => 'book-node-export-html', ), ); } diff --git a/core/modules/ckeditor/ckeditor.module b/core/modules/ckeditor/ckeditor.module index 5cb8ef3..d1476d9 100644 --- a/core/modules/ckeditor/ckeditor.module +++ b/core/modules/ckeditor/ckeditor.module @@ -40,7 +40,6 @@ function ckeditor_theme() { 'ckeditor_settings_toolbar' => array( 'file' => 'ckeditor.admin.inc', 'variables' => array('editor' => NULL, 'plugins' => NULL), - 'template' => 'ckeditor-settings-toolbar', ), ); } diff --git a/core/modules/color/color.module b/core/modules/color/color.module index a0c0896..3aa2f68 100644 --- a/core/modules/color/color.module +++ b/core/modules/color/color.module @@ -38,7 +38,6 @@ function color_theme() { return array( 'color_scheme_form' => array( 'render element' => 'form', - 'template' => 'color-scheme-form', ), ); } diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index dbe3bee..6f67392 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -129,11 +129,9 @@ function comment_theme() { return array( 'comment' => array( 'render element' => 'elements', - 'template' => 'comment', ), 'field__comment' => array( 'base hook' => 'field', - 'template' => 'field--comment', ), ); } diff --git a/core/modules/config_translation/config_translation.module b/core/modules/config_translation/config_translation.module index 43aa754..c756394 100644 --- a/core/modules/config_translation/config_translation.module +++ b/core/modules/config_translation/config_translation.module @@ -55,7 +55,6 @@ function config_translation_theme() { return array( 'config_translation_manage_form_element' => array( 'render element' => 'element', - 'template' => 'config_translation_manage_form_element', ), ); } diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index 9dbcbd2..b349527 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -96,6 +96,7 @@ function field_ui_theme() { return array( 'field_ui_table' => array( 'render element' => 'elements', + 'function' => 'theme_field_ui_table', ), ); } diff --git a/core/modules/file/file.module b/core/modules/file/file.module index 03e10bf..ffd5fc0 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -577,27 +577,22 @@ function file_theme() { // From file.module. 'file_link' => array( 'variables' => array('file' => NULL, 'icon_directory' => NULL, 'description' => NULL, 'attributes' => array()), - 'template' => 'file-link', ), 'file_managed_file' => array( 'render element' => 'element', - 'template' => 'file-managed-file', ), // From file.field.inc. 'file_widget' => array( 'render element' => 'element', - 'template' => 'file-widget', 'file' => 'file.field.inc', ), 'file_widget_multiple' => array( 'render element' => 'element', - 'template' => 'file-widget-multiple', 'file' => 'file.field.inc', ), 'file_upload_help' => array( 'variables' => array('description' => NULL, 'upload_validators' => NULL, 'cardinality' => NULL), - 'template' => 'file-upload-help', 'file' => 'file.field.inc', ), ); diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index d31cca1..d17329a 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -61,7 +61,6 @@ function filter_theme() { return array( 'filter_tips' => array( 'variables' => array('tips' => NULL, 'long' => FALSE), - 'template' => 'filter-tips', ), 'text_format_wrapper' => array( 'variables' => array( @@ -69,11 +68,9 @@ function filter_theme() { 'description' => NULL, 'attributes' => array(), ), - 'template' => 'text-format-wrapper', ), 'filter_guidelines' => array( 'variables' => array('format' => NULL), - 'template' => 'filter-guidelines', ), 'filter_caption' => array( 'variables' => array( @@ -82,7 +79,6 @@ function filter_theme() { 'caption' => NULL, 'classes' => NULL, ), - 'template' => 'filter-caption', ) ); } diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 039c305..8b6aea2 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -82,19 +82,15 @@ function forum_help($route_name, RouteMatchInterface $route_match) { function forum_theme() { return array( 'forums' => array( - 'template' => 'forums', 'variables' => array('forums' => array(), 'topics' => array(), 'topics_pager' => array(), 'parents' => NULL, 'term' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL, 'header' => array()), ), 'forum_list' => array( - 'template' => 'forum-list', 'variables' => array('forums' => NULL, 'parents' => NULL, 'tid' => NULL), ), 'forum_icon' => array( - 'template' => 'forum-icon', 'variables' => array('new_posts' => NULL, 'num_posts' => 0, 'comment_mode' => 0, 'sticky' => 0, 'first_new' => FALSE), ), 'forum_submitted' => array( - 'template' => 'forum-submitted', 'variables' => array('topic' => NULL), ), ); diff --git a/core/modules/image/image.module b/core/modules/image/image.module index a6ce171..8a7ad86 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -107,47 +107,38 @@ function image_theme() { 'title' => NULL, 'attributes' => array(), ), - 'template' => 'image-style', ), // Theme functions in image.admin.inc. 'image_style_preview' => array( 'variables' => array('style' => NULL), 'file' => 'image.admin.inc', - 'template' => 'image-style-preview', ), 'image_anchor' => array( 'render element' => 'element', 'file' => 'image.admin.inc', - 'template' => 'image-anchor', ), 'image_resize_summary' => array( 'variables' => array('data' => NULL, 'effect' => array()), - 'template' => 'image-resize-summary', ), 'image_scale_summary' => array( 'variables' => array('data' => NULL, 'effect' => array()), - 'template' => 'image-scale-summary', ), 'image_crop_summary' => array( 'variables' => array('data' => NULL, 'effect' => array()), - 'template' => 'image-crop-summary', ), 'image_rotate_summary' => array( 'variables' => array('data' => NULL, 'effect' => array()), - 'template' => 'image-rotate-summary', ), // Theme functions in image.field.inc. 'image_widget' => array( 'render element' => 'element', 'file' => 'image.field.inc', - 'template' => 'image-widget', ), 'image_formatter' => array( 'variables' => array('item' => NULL, 'item_attributes' => NULL, 'path' => NULL, 'image_style' => NULL), 'file' => 'image.field.inc', - 'template' => 'image-formatter', ), ); } diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 0c37638..ad98e35 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -106,15 +106,16 @@ function language_theme() { 'language_negotiation_configure_form' => array( 'render element' => 'form', 'file' => 'language.admin.inc', - 'template' => 'language-negotiation-configure-form', ), 'language_negotiation_configure_browser_form_table' => array( 'render element' => 'form', 'file' => 'language.admin.inc', + 'function' => 'theme_language_negotiation_configure_browser_form_table', ), 'language_content_settings_table' => array( 'render element' => 'element', 'file' => 'language.admin.inc', + 'function' => 'theme_language_content_settings_table', ), ); } diff --git a/core/modules/link/link.module b/core/modules/link/link.module index d33181e..ba3c3a1 100644 --- a/core/modules/link/link.module +++ b/core/modules/link/link.module @@ -41,7 +41,6 @@ function link_theme() { return array( 'link_formatter_link_separate' => array( 'variables' => array('title' => NULL, 'url_title' => NULL, 'url' => NULL), - 'template' => 'link-formatter-link-separate', ), ); } diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 3122f59..67a9b79 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -193,16 +193,15 @@ function locale_theme() { 'locale_translate_edit_form_strings' => array( 'render element' => 'form', 'file' => 'locale.pages.inc', + 'function' => 'theme_locale_translate_edit_form_strings', ), 'locale_translation_last_check' => array( 'variables' => array('last' => NULL), 'file' => 'locale.pages.inc', - 'template' => 'locale-translation-last-check', ), 'locale_translation_update_info' => array( 'variables' => array('updates' => array(), 'not_found' => array()), 'file' => 'locale.pages.inc', - 'template' => 'locale-translation-update-info', ), ); } diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module index dcedc00..b709865 100644 --- a/core/modules/menu_ui/menu_ui.module +++ b/core/modules/menu_ui/menu_ui.module @@ -89,6 +89,7 @@ function menu_ui_theme() { 'menu_overview_form' => array( 'file' => 'menu_ui.admin.inc', 'render element' => 'form', + 'function' => 'theme_menu_overview_form', ), ); } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 030e62a..2bef3f6 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -159,31 +159,26 @@ function node_theme() { return array( 'node' => array( 'render element' => 'elements', - 'template' => 'node', ), 'node_search_admin' => array( 'render element' => 'form', + 'function' => 'theme_node_search_admin', ), 'node_add_list' => array( 'variables' => array('content' => NULL), 'file' => 'node.pages.inc', - 'template' => 'node-add-list', ), 'node_edit_form' => array( 'render element' => 'form', - 'template' => 'node-edit-form', ), 'field__node__title' => array( 'base hook' => 'field', - 'template' => 'field--node--title', ), 'field__node__uid' => array( 'base hook' => 'field', - 'template' => 'field--node--uid', ), 'field__node__created' => array( 'base hook' => 'field', - 'template' => 'field--node--created', ), ); } diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index 061dd03..576ae84 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -250,7 +250,6 @@ function rdf_theme() { return array( 'rdf_metadata' => array( 'variables' => array('metadata' => array()), - 'template' => 'rdf-metadata', ), ); } diff --git a/core/modules/responsive_image/responsive_image.module b/core/modules/responsive_image/responsive_image.module index d8985c9..42b9926 100644 --- a/core/modules/responsive_image/responsive_image.module +++ b/core/modules/responsive_image/responsive_image.module @@ -91,6 +91,7 @@ function responsive_image_theme() { 'attributes' => array(), 'mapping_id' => array(), ), + 'function' => 'theme_responsive_image', ), 'responsive_image_formatter' => array( 'variables' => array( @@ -99,6 +100,7 @@ function responsive_image_theme() { 'image_style' => NULL, 'mapping_id' => array(), ), + 'function' => 'theme_responsive_image_formatter', ), 'responsive_image_source' => array( 'variables' => array( @@ -107,6 +109,7 @@ function responsive_image_theme() { 'dimensions' => NULL, 'media' => NULL, ), + 'function' => 'theme_responsive_image_source', ), ); } diff --git a/core/modules/search/search.module b/core/modules/search/search.module index 7cbe706..fa7d1cf 100644 --- a/core/modules/search/search.module +++ b/core/modules/search/search.module @@ -104,7 +104,6 @@ function search_theme() { 'search_result' => array( 'variables' => array('result' => NULL, 'plugin_id' => NULL), 'file' => 'search.pages.inc', - 'template' => 'search-result', ), ); } diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module index 24665c7..8abb35d 100644 --- a/core/modules/simpletest/simpletest.module +++ b/core/modules/simpletest/simpletest.module @@ -56,7 +56,6 @@ function simpletest_theme() { return array( 'simpletest_result_summary' => array( 'variables' => array('label' => NULL, 'items' => array(), 'pass' => 0, 'fail' => 0, 'exception' => 0, 'debug' => 0), - 'template' => 'simpletest-result-summary', ), ); } diff --git a/core/modules/system/system.module b/core/modules/system/system.module index f3b65a2..bc5868d 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -159,7 +159,6 @@ function system_theme() { // is picked up. 'block__system_branding_block' => array( 'base hook' => 'block', - 'template' => 'block--system-branding-block', ), 'system_themes_page' => array( 'variables' => array( @@ -167,51 +166,46 @@ function system_theme() { 'theme_group_titles' => array(), ), 'file' => 'system.admin.inc', - 'template' => 'system-themes-page', ), 'system_config_form' => array( 'render element' => 'form', - 'template' => 'system-config-form', ), 'confirm_form' => array( 'render element' => 'form', - 'template' => 'confirm-form', ), 'system_modules_details' => array( 'render element' => 'form', 'file' => 'system.admin.inc', + 'function' => 'theme_system_modules_details', ), 'system_modules_uninstall' => array( 'render element' => 'form', 'file' => 'system.admin.inc', + 'function' => 'theme_system_modules_uninstall', ), 'status_report' => array( 'variables' => array('requirements' => NULL), 'file' => 'system.admin.inc', - 'template' => 'status-report', ), 'admin_page' => array( 'variables' => array('blocks' => NULL), 'file' => 'system.admin.inc', - 'template' => 'admin-page', ), 'admin_block' => array( 'variables' => array('block' => NULL), 'file' => 'system.admin.inc', - 'template' => 'admin-block', ), 'admin_block_content' => array( 'variables' => array('content' => NULL), 'file' => 'system.admin.inc', - 'template' => 'admin-block-content', ), 'system_admin_index' => array( 'variables' => array('menu_items' => NULL), 'file' => 'system.admin.inc', - 'template' => 'system-admin-index', ), 'system_compact_link' => array( 'variables' => array(), + 'function' => 'theme_system_compact_link', ), )); } diff --git a/core/modules/system/tests/modules/common_test/common_test.module b/core/modules/system/tests/modules/common_test/common_test.module index bd17563..28c5be3 100644 --- a/core/modules/system/tests/modules/common_test/common_test.module +++ b/core/modules/system/tests/modules/common_test/common_test.module @@ -115,14 +115,13 @@ function common_test_theme() { return array( 'common_test_foo' => array( 'variables' => array('foo' => 'foo', 'bar' => 'bar'), - 'template' => 'common-test-foo', ), 'common_test_render_element' => array( 'render element' => 'foo', - 'template' => 'common-test-render-element', ), 'common_test_empty' => array( 'variables' => array('foo' => 'foo'), + 'function' => 'theme_common_test_empty', ), ); } diff --git a/core/modules/system/tests/modules/theme_suggestions_test/theme_suggestions_test.module b/core/modules/system/tests/modules/theme_suggestions_test/theme_suggestions_test.module index e963c2f..974856a 100644 --- a/core/modules/system/tests/modules/theme_suggestions_test/theme_suggestions_test.module +++ b/core/modules/system/tests/modules/theme_suggestions_test/theme_suggestions_test.module @@ -12,6 +12,7 @@ function theme_suggestions_test_theme() { $items['theme_suggestions_test_include'] = array( 'file' => 'theme_suggestions_test.inc', 'variables' => array(), + 'function' => 'theme_theme_suggestions_test_include', ); return $items; } diff --git a/core/modules/system/tests/modules/theme_test/theme_test.module b/core/modules/system/tests/modules/theme_test/theme_test.module index dd71fb7..e2378fb 100644 --- a/core/modules/system/tests/modules/theme_test/theme_test.module +++ b/core/modules/system/tests/modules/theme_test/theme_test.module @@ -9,6 +9,7 @@ function theme_test_theme($existing, $type, $theme, $path) { $items['theme_test'] = array( 'file' => 'theme_test.inc', 'variables' => array('foo' => ''), + 'function' => 'theme_theme_test', ); $items['theme_test_template_test'] = array( 'template' => 'theme_test.template_test', @@ -17,39 +18,39 @@ function theme_test_theme($existing, $type, $theme, $path) { 'template' => 'theme_test.template_test', ); $items['theme_test_suggestion_provided'] = array( - 'template' => 'theme-test-suggestion-provided', 'variables' => array(), ); $items['theme_test_specific_suggestions'] = array( - 'template' => 'theme-test-specific-suggestions', 'variables' => array(), ); $items['theme_test_suggestions'] = array( - 'template' => 'theme-test-suggestions', 'variables' => array(), ); $items['theme_test_general_suggestions'] = array( - 'template' => 'theme-test-general-suggestions', 'variables' => array(), ); $items['theme_test_function_suggestions'] = array( 'variables' => array(), + 'function' => 'theme_theme_test_function_suggestions', ); $items['theme_test_suggestions_include'] = array( 'variables' => array(), + 'function' => 'theme_theme_test_suggestions_include', ); $items['theme_test_foo'] = array( 'variables' => array('foo' => NULL), + 'function' => 'theme_theme_test_foo', ); $items['theme_test_render_element'] = array( 'render element' => 'elements', - 'template' => 'theme-test-render-element', ); $items['theme_test_render_element_children'] = array( 'render element' => 'element', + 'function' => 'theme_theme_test_render_element_children', ); $items['theme_test_function_template_override'] = array( 'variables' => array(), + 'function' => 'theme_theme_test_function_template_override', ); $info['test_theme_not_existing_function'] = array( 'function' => 'test_theme_not_existing_function', diff --git a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module index c8db9d6..fb8f857 100644 --- a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module +++ b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module @@ -17,11 +17,9 @@ function twig_theme_test_theme($existing, $type, $theme, $path) { ); $items['twig_namespace_test'] = array( 'variables' => array(), - 'template' => 'twig_namespace_test', ); $items['twig_raw_test'] = array( 'variables' => array('script' => ''), - 'template' => 'twig-raw-test', ); $items['twig_autoescape_test'] = array( 'variables' => array('script' => ''), diff --git a/core/modules/system/theme.api.php b/core/modules/system/theme.api.php index 089334f..18a2cb7 100644 --- a/core/modules/system/theme.api.php +++ b/core/modules/system/theme.api.php @@ -49,7 +49,6 @@ * 'plugin_id' => NULL, * ), * 'file' => 'search.pages.inc', - * 'template' => 'search-result', * ), * ); * @endcode diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 7b26e7b..75b3b81 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -219,7 +219,6 @@ function taxonomy_theme() { return array( 'taxonomy_term' => array( 'render element' => 'elements', - 'template' => 'taxonomy-term', ), ); } diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module index 49e2530..11bade8 100644 --- a/core/modules/toolbar/toolbar.module +++ b/core/modules/toolbar/toolbar.module @@ -50,10 +50,6 @@ function toolbar_permission() { function toolbar_theme($existing, $type, $theme, $path) { $items['toolbar'] = array( 'render element' => 'element', - 'template' => 'toolbar', - ); - $items['toolbar_item'] = array( - 'render element' => 'element', ); return $items; @@ -96,7 +92,6 @@ function toolbar_element_info() { // property contains a renderable array. $elements['toolbar_item'] = array( '#pre_render' => array('toolbar_pre_render_item'), - '#theme' => 'toolbar_item', 'tab' => array( '#type' => 'link', '#title' => NULL, diff --git a/core/modules/update/update.module b/core/modules/update/update.module index 6529a48..09ce0fc 100644 --- a/core/modules/update/update.module +++ b/core/modules/update/update.module @@ -176,24 +176,20 @@ function update_theme() { return array( 'update_last_check' => array( 'variables' => array('last' => 0), - 'template' => 'update-last-check', ), 'update_report' => array( 'variables' => array('data' => NULL), 'file' => 'update.report.inc', - 'template' => 'update-report', ), 'update_project_status' => array( 'variables' => array('project' => array(), 'includes_status' => array()), 'file' => 'update.report.inc', - 'template' => 'update-project-status', ), + // We are using template instead of '#type' => 'table' here to keep markup + // out of preprocess and allow for easier changes to markup. 'update_version' => array( 'variables' => array('version' => NULL, 'title' => NULL, 'attributes' => array()), 'file' => 'update.report.inc', - // We are using template instead of '#type' => 'table' here to keep markup - // out of preprocess and allow for easier changes to markup. - 'template' => 'update-version', ), ); } diff --git a/core/modules/user/user.module b/core/modules/user/user.module index eb3d5ae..e8580e7 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -100,11 +100,9 @@ function user_theme() { 'user' => array( 'render element' => 'elements', 'file' => 'user.pages.inc', - 'template' => 'user', ), 'username' => array( 'variables' => array('account' => NULL, 'attributes' => array(), 'link_options' => array()), - 'template' => 'username', ), ); } diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 3ba93f5..6d796eb 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -121,7 +121,6 @@ function views_theme($existing, $type, $theme, $path) { // Our extra version of pager from pager.inc $hooks['views_mini_pager'] = $base + array( 'variables' => array('tags' => array(), 'quantity' => 9, 'element' => 0, 'parameters' => array()), - 'template' => 'views-mini-pager', ); $variables = array( @@ -155,10 +154,10 @@ function views_theme($existing, $type, $theme, $path) { // Default view themes $hooks['views_view_field'] = $base + array( 'variables' => array('view' => NULL, 'field' => NULL, 'row' => NULL), + 'function' => 'theme_views_view_field', ); $hooks['views_view_grouping'] = $base + array( 'variables' => array('view' => NULL, 'grouping' => NULL, 'grouping_level' => NULL, 'rows' => NULL, 'title' => NULL), - 'template' => 'views-view-grouping', ); $plugins = Views::getPluginDefinitions(); @@ -187,35 +186,44 @@ function views_theme($existing, $type, $theme, $path) { 'variables' => $variables[$type], ); - // For the views module we ensure views.theme.inc is included. - if ($def['provider'] == 'views') { - $def['theme_file'] = 'views.theme.inc'; - } // We always use the module directory as base dir. $module_dir = drupal_get_path('module', $def['provider']); + $hooks[$def['theme']]['path'] = $module_dir; + // For the views module we ensure views.theme.inc is included. + if ($def['provider'] == 'views') { + if (!isset($hooks[$def['theme']]['includes'])) { + $hooks[$def['theme']]['includes'] = array(); + } + if (!in_array('views.theme.inc', $hooks[$def['theme']]['includes'])) { + $hooks[$def['theme']]['includes'][] = $module_dir . '/views.theme.inc'; + } + } // The theme_file definition is always relative to the modules directory. - if (isset($def['theme_file'])) { - $hooks[$def['theme']]['path'] = $module_dir; + elseif (!empty($def['theme_file'])) { $hooks[$def['theme']]['file'] = $def['theme_file']; } + // Whenever we got a theme file, we include it directly so we can // auto-detect the theme function. if (isset($def['theme_file'])) { - $include = DRUPAL_ROOT . '/' . $module_dir. '/' . $def['theme_file']; + $include = DRUPAL_ROOT . '/' . $module_dir . '/' . $def['theme_file']; if (is_file($include)) { require_once $include; } } - // If there is no theme function for the given theme definition, we assume - // a template file shall be used. By default this file is located in the - // /templates directory of the module's folder. - // If a module wants to define its own location it has to set - // register_theme of the plugin to FALSE and implement hook_theme() by - // itself. + + // If there is no theme function for the given theme definition, it must + // be a template file. By default this file is located in the /templates + // directory of the module's folder. If a module wants to define its own + // location it has to set register_theme of the plugin to FALSE and + // implement hook_theme() by itself. if (!function_exists('theme_' . $def['theme'])) { - $hooks[$def['theme']]['path'] = $module_dir; - $hooks[$def['theme']]['template'] = 'templates/' . drupal_clean_css_identifier($def['theme']); + $hooks[$def['theme']]['path'] .= '/templates'; + $hooks[$def['theme']]['template'] = drupal_clean_css_identifier($def['theme']); + } + else { + $hooks[$def['theme']]['function'] = 'theme_' . $def['theme']; } } } @@ -225,13 +233,11 @@ function views_theme($existing, $type, $theme, $path) { ); $hooks['views_exposed_form'] = $base + array( - 'template' => 'views-exposed-form', 'render element' => 'form', ); $hooks['views_more'] = $base + array( 'variables' => array('more_url' => NULL, 'link_text' => 'more', 'view' => NULL), - 'template' => 'views-more', ); return $hooks; diff --git a/core/modules/views_ui/views_ui.module b/core/modules/views_ui/views_ui.module index 3960294..f083adc 100644 --- a/core/modules/views_ui/views_ui.module +++ b/core/modules/views_ui/views_ui.module @@ -70,57 +70,50 @@ function views_ui_theme() { // edit a view 'views_ui_display_tab_setting' => array( 'variables' => array('description' => '', 'link' => '', 'settings_links' => array(), 'overridden' => FALSE, 'defaulted' => FALSE, 'description_separator' => TRUE, 'class' => array()), - 'template' => 'views-ui-display-tab-setting', 'file' => 'views_ui.theme.inc', ), 'views_ui_display_tab_bucket' => array( 'render element' => 'element', - 'template' => 'views-ui-display-tab-bucket', 'file' => 'views_ui.theme.inc', ), 'views_ui_rearrange_filter_form' => array( 'render element' => 'form', 'file' => 'views_ui.theme.inc', - 'template' => 'views-ui-rearrange-filter-form', ), 'views_ui_expose_filter_form' => array( 'render element' => 'form', 'file' => 'views_ui.theme.inc', - 'template' => 'views-ui-expose-filter-form', ), // list views 'views_ui_view_info' => array( 'variables' => array('view' => NULL, 'displays' => NULL), 'file' => 'views_ui.theme.inc', - 'template' => 'views-ui-view-info', ), // Group of filters. 'views_ui_build_group_filter_form' => array( 'render element' => 'form', 'file' => 'views_ui.theme.inc', + 'function' => 'theme_views_ui_build_group_filter_form', ), // On behalf of a plugin 'views_ui_style_plugin_table' => array( 'render element' => 'form', 'file' => 'views_ui.theme.inc', - 'template' => 'views-ui-style-plugin-table', ), // When previewing a view. 'views_ui_view_preview_section' => array( 'variables' => array('view' => NULL, 'section' => NULL, 'content' => NULL, 'links' => ''), 'file' => 'views_ui.theme.inc', - 'template' => 'views-ui-view-preview-section', ), // Generic container wrapper, to use instead of theme_container when an id // is not desired. 'views_ui_container' => array( 'variables' => array('children' => NULL, 'attributes' => array()), - 'template' => 'views-ui-container', 'file' => 'views_ui.theme.inc', ), ); diff --git a/core/themes/engines/twig/twig.engine b/core/themes/engines/twig/twig.engine index e0cfcc2..06ec07c 100644 --- a/core/themes/engines/twig/twig.engine +++ b/core/themes/engines/twig/twig.engine @@ -38,23 +38,28 @@ function twig_init(Extension $theme) { * If the Twig debug setting is enabled, HTML comments including _theme() call * and template file name suggestions will surround the template markup. * - * @param $template_file + * @param string $template_file * The file name of the template to render. - * @param $variables + * @param array $variables * A keyed array of variables that will appear in the output. * - * @return + * @return string * The output generated by the template, plus any debug information. */ function twig_render_template($template_file, $variables) { /** @var \Twig_Environment $twig_service */ $twig_service = \Drupal::service('twig'); - $output = array( - 'debug_prefix' => '', - 'debug_info' => '', - 'rendered_markup' => $twig_service->loadTemplate($template_file)->render($variables), - 'debug_suffix' => '', - ); + try { + $output = array( + 'debug_prefix' => '', + 'debug_info' => '', + 'rendered_markup' => $twig_service->loadTemplate($template_file)->render($variables), + 'debug_suffix' => '', + ); + } + catch (\Twig_Error_Loader $e) { + drupal_set_message($e->getMessage(), 'error'); + } if ($twig_service->isDebug()) { $output['debug_prefix'] .= "\n\n"; $output['debug_prefix'] .= "\n";