Verified Commit 84702133 authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3157353 by Utkarsh_33, lauriii, dww, smustgrave, longwave, narendraR,...

Issue #3157353 by Utkarsh_33, lauriii, dww, smustgrave, longwave, narendraR, quietone, larowlan, catch, Berdir, omkar.podey: Provide a mechanism to mark entire twig templates as deprecated
parent b06be9b6
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1246,6 +1246,8 @@ function hook_page_bottom(array &$page_bottom) {
 *     'module', 'theme_engine', or 'theme'.
 *   - theme path: The directory path of the theme or module. If not defined,
 *     it is determined during the registry process.
 *   - deprecated: The deprecated key marks a twig template as deprecated with
 *     a custom message.
 *
 * @see themeable
 * @see hook_theme_registry_alter()
+3 −0
Original line number Diff line number Diff line
@@ -182,6 +182,9 @@ public function render($hook, array $variables) {
    }

    $info = $theme_registry->get($hook);
    if (isset($info['deprecated'])) {
      @trigger_error($info['deprecated'], E_USER_DEPRECATED);
    }

    // If a renderable array is passed as $variables, then set $variables to
    // the arguments expected by the theme function.
+5 −0
Original line number Diff line number Diff line
name: 'Deprecated Twig Template Test'
type: module
description: 'Provides a deprecated Twig template for testing purposes.'
package: Testing
version: VERSION
+20 −0
Original line number Diff line number Diff line
<?php

/**
 * @file
 * This is a test module for deprecated twig templates.
 */

/**
 * Implements hook_theme().
 */
function deprecated_twig_template_theme() {
  return [
    'deprecated_template' => [
      'variables' => [
        'message' => NULL,
      ],
      'deprecated' => 'The "deprecated-template.html.twig" template is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use another template instead. See https://www.example.com',
    ],
  ];
}
+6 −0
Original line number Diff line number Diff line
deprecated_twig_template:
  path: '/deprecated-twig-template'
  defaults:
    _controller: '\Drupal\deprecated_twig_template\Controller\DeprecatedTwigTemplateController::deprecatedTwigTemplate'
  requirements:
    _access: 'TRUE'
Loading