Problem/Motivation

Conceptually, the discovery of theme functions and templates is part of the Theme Registry. In actuality, the two discover functions (drupal_find_theme_templates() and drupal_find_theme_functions()) are still in theme.inc and portions of them call the Theme Registry service.

The practical implication is that extending/modifying template discovery is much harder with these procedural functions.

Proposed resolution

  • Create methods on the theme registry service for finding theme templates and theme functions.
  • Have the procedural functions to nothing more than wrap the service.

Remaining tasks

Mark functions as deprecated?
Update interface?

User interface changes

None

API changes

Mark the procedural functions as deprecated?

Data model changes

none

Comments

stevector created an issue. See original summary.

stevector’s picture

Assigned: stevector » Unassigned
Status: Active » Needs review
FileSize
14.73 KB

Here's a first pass.

Status: Needs review » Needs work

The last submitted patch, 2: theme-discovery-2612800-2.patch, failed testing.

stevector’s picture

I had an errant debug message in that last patch.

stevector’s picture

Status: Needs work » Needs review

The last submitted patch, 2: theme-discovery-2612800-2.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 4: theme-discovery-2612800-4.patch, failed testing.

stevector’s picture

Status: Needs work » Needs review
FileSize
14.08 KB

Odd,

$theme = $this->theme->getName();

fails in one test but this does not:

$theme = $this->themeManager->getActiveTheme()->getName();

Trying again.

joelpittet’s picture

Status: Needs review » Needs work

Thanks for this clean-up. These is my favourite clean-ups:)

+++ b/core/includes/theme.inc
@@ -117,51 +117,8 @@ function drupal_theme_rebuild() {
  *   The functions found, suitable for returning from hook_theme;
  */
 function drupal_find_theme_functions($cache, $prefixes) {

Likely will need those deprecated notices in the docblocks.

re #8 that is strange.

+++ b/core/lib/Drupal/Core/Theme/Registry.php
@@ -766,4 +766,168 @@ public function getPrefixGroupedUserFunctions() {
+  public function find_theme_templates($cache, $extension, $path) {

Since this is a OOP thing now it should be findThemeTemplates() or just findTemplates() to save a bit of redundency but most important is the camel casing for methods.

stevector’s picture

Thanks for the review! This patch adds the deprecated notice, camel casing and fixes an unnecessary line break.

joelpittet’s picture

Thanks for the cleanup @stevector. This is the related type of move #2591515: Move twig_without() to the TwigExtension where all the other filters are and deprecate and this patch is trying to touch the same bit of code #2339447: Improve theme registry build performance by 85% which may cause a re-roll.

Not sure if this will will make it into a patch release or 8.1.x, so I'll just leave it until 8.0.0 is released.

The last submitted patch, 2: theme-discovery-2612800-2.patch, failed testing.

The last submitted patch, 4: theme-discovery-2612800-4.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.