Unverified Commit 4a70ba37 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3109480 by longwave, catch, bnjmnm, xjm, lauriii, Gábor Hojtsy:...

Issue #3109480 by longwave, catch, bnjmnm, xjm, lauriii, Gábor Hojtsy: Properly deprecate theme functions for Drupal 10
parent 6ae9811c
Loading
Loading
Loading
Loading
+1 −0
Changes for core/lib/Drupal/Core/Theme/Registry.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -495,6 +495,7 @@ protected function processExtension(array &$cache, $name, $type, $theme, $path)
        // if the theme hook specifies a function callback instead, check to
        // ensure the function actually exists.
        if (isset($info['function'])) {
          @trigger_error('Theme functions are deprecated in drupal:8.0.0 and are removed from drupal:10.0.0. Use Twig templates instead. See https://www.drupal.org/node/1831138', E_USER_DEPRECATED);
          if (!function_exists($info['function'])) {
            throw new \BadFunctionCallException(sprintf(
              'Theme hook "%s" refers to a theme function callback that does not exist: "%s"',
+0 −18
Changes for core/modules/system/tests/modules/common_test/common_test.module: 0 added lines, 18 removed lines.
Original line number Diff line number Diff line
@@ -121,27 +121,9 @@ function common_test_theme() {
    'common_test_render_element' => [
      'render element' => 'foo',
    ],
    'common_test_empty' => [
      'variables' => ['foo' => 'foo'],
      'function' => 'theme_common_test_empty',
    ],
  ];
}

/**
 * Provides a theme function for drupal_render().
 */
function theme_common_test_foo($variables) {
  return $variables['foo'] . $variables['bar'];
}

/**
 * Always returns an empty string.
 */
function theme_common_test_empty($variables) {
  return '';
}

/**
 * Implements MODULE_preprocess().
 *
+1 −1
Changes for core/modules/system/tests/modules/theme_legacy_suggestions_test/theme_legacy_suggestions_test.inc: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@

/**
 * @file
 * Include file for testing theme suggestion hooks.
 * Include file for testing theme suggestion hooks for legacy theme functions.
 */

/**
+5 −0
Changes for core/modules/system/tests/modules/theme_legacy_suggestions_test/theme_legacy_suggestions_test.info.yml: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
name: 'Legacy theme functions suggestions test'
type: module
description: 'Support module for testing theme suggestions for legacy theme functions.'
package: Testing
version: VERSION
+33 −0
Changes for core/modules/system/tests/modules/theme_legacy_suggestions_test/theme_legacy_suggestions_test.module: 33 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

/**
 * @file
 * Support module for testing theme suggestions.
 *
 * @todo Remove in https://www.drupal.org/project/drupal/issues/3097889
 */

/**
 * Implements hook_theme().
 */
function theme_legacy_suggestions_test_theme() {
  $items['theme_suggestions_test_include'] = [
    'file' => 'theme_legacy_suggestions_test.inc',
    'function' => 'theme_theme_suggestions_test_include',
  ];
  return $items;
}

/**
 * Implements hook_theme_suggestions_HOOK_alter().
 */
function theme_legacy_suggestions_test_theme_suggestions_theme_test_function_suggestions_alter(array &$suggestions, array $variables) {
  $suggestions[] = 'theme_test_function_suggestions__module_override';
}

/**
 * Implements hook_theme_suggestions_HOOK_alter().
 */
function theme_legacy_suggestions_test_theme_suggestions_theme_test_suggestions_include_alter(array &$suggestions, array $variables, $hook) {
  $suggestions[] = 'theme_suggestions_test_include';
}
Loading