Verified Commit 0e8a558b authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3348848 by andypost, Purencool, daffie: Deprecate theme_get_registry()

parent 8a924f77
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -87,13 +87,20 @@
 * @return array|\Drupal\Core\Utility\ThemeRegistry
 *   The complete theme registry array, or an instance of the
 *   Drupal\Core\Utility\ThemeRegistry class.
 *
 * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use
 *   theme.registry service methods get() or getRuntime() instead.
 *
 * @see https://www.drupal.org/node/3348850
 */
function theme_get_registry($complete = TRUE) {
  $theme_registry = \Drupal::service('theme.registry');
  if ($complete) {
    @trigger_error(__FUNCTION__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use theme.registry service method get() instead. See https://www.drupal.org/node/3348850', E_USER_DEPRECATED);
    return $theme_registry->get();
  }
  else {
    @trigger_error(__FUNCTION__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use theme.registry service method getRuntime() instead. See https://www.drupal.org/node/3348850', E_USER_DEPRECATED);
    return $theme_registry->getRuntime();
  }
}
+1 −1
Original line number Diff line number Diff line
@@ -547,7 +547,7 @@ function hook_preprocess(&$variables, $hook) {
  }

  if (!isset($hooks)) {
    $hooks = theme_get_registry();
    $hooks = \Drupal::service('theme.registry')->get();
  }

  // Determine the primary theme function argument.
+14 −0
Original line number Diff line number Diff line
@@ -272,4 +272,18 @@ public function testLegacyThemeRegistryRebuild() {
    $this->assertSame($hooks, $registry->get());
  }

  /**
   * Tests deprecated theme_get_registry function.
   *
   * @see theme_get_registry()
   * @group legacy
   */
  public function testLegacyThemeGetRegistry() {
    $registry = \Drupal::service('theme.registry');
    $this->expectDeprecation('theme_get_registry() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use theme.registry service method get() instead. See https://www.drupal.org/node/3348850');
    $this->assertEquals($registry->get(), theme_get_registry());
    $this->expectDeprecation('theme_get_registry() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use theme.registry service method getRuntime() instead. See https://www.drupal.org/node/3348850');
    $this->assertEquals($registry->getRuntime(), theme_get_registry(FALSE));
  }

}