Problem/Motivation

The \Drupal::theme() service is now the primary place to interact with the theme system. On the other hand we still have _theme().

Proposed resolution

Let's encapsulate the logic by replace calls from _theme() to \Drupal::theme()->render. At some point we can then move _theme() inside \Drupal::theme() or onto another service.

Remaining tasks

User interface changes

API changes

Comments

asif_khan’s picture

hi
i found another issue Replace all calls to _theme with calling \Drupal::theme()->render() i think it's a duplicate issue.
ok i've change 6 calls out of 7 callsof _theme() to \Drupal::theme()

asif_khan’s picture

Status: Active » Needs review
dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Perfect, thank you for also finding the duplicate issue!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 1: drupal-8-core-replace-theme-calls-to-2325571-1.patch, failed testing.

asif_khan’s picture

Status: Needs work » Needs review
StatusFileSize
new5.1 KB
dawehner’s picture

Status: Needs review » Reviewed & tested by the community

I think this is fine for now

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/system/src/Tests/Theme/ThemeTest.php
@@ -56,18 +56,18 @@ function testAttributeMerging() {
+    // theme_test_false is an implemented theme hook so \Drupal::theme() service container should return a
     // string, even though the theme function itself can return anything.

"service container" is this not just a service? Plus line wrapping.

      $elements['#children'] = _theme($wrapper_hook, $wrapper_elements);

This call in drupal_render() can be replaced too.

We should also have a followup to move _theme, template_preprocess and _template_preprocess_default_variables into one of the Theme services.

dawehner’s picture

Here is a follow up #2340341: Move template_preprocess, _template_preprocess_default_variables into services

@asif_khan
Do you want to try to fix the points from alex's review?

omers’s picture

Ok here is the patch with the fix, hope it works :)

omers’s picture

Status: Needs work » Needs review
dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Great!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed e92eb2d and pushed to 8.0.x. Thanks!

alexpott’s picture

Committed 4d82422 and pushed to 8.0.x. Thanks!

  • alexpott committed 4d82422 on 8.0.x
    Issue #2325571 by asif_khan, omers | dawehner: Replace _theme() calls by...
omers’s picture

THANK YOU GUYS !!! I hope to contribute my two cents in #2340341 :)

star-szr’s picture

+++ b/core/includes/common.inc
@@ -2906,7 +2906,7 @@ function drupal_render(&$elements, $is_recursive_call = FALSE) {
-      $elements['#children'] = _theme($wrapper_hook, $wrapper_elements);
+      $elements['#children'] = Drupal::theme()->render($wrapper_hook, $wrapper_elements);

Minor, but why is this one Drupal and not \Drupal?

alexpott’s picture

#16 it's a mistake - I should have caught it. We need a small follow-up (in this issue) to address that - feel free to rtbc straight away.

omers’s picture

OMG sorry about that ... my mistake, i don't know how to proceed when the patch is pushed, but here is the fix.

star-szr’s picture

We just need a patch for that one line change, not all the changes that have already been committed. Thanks!

omers’s picture

Here is :)

omers’s picture

omers’s picture

Status: Fixed » Reviewed & tested by the community
star-szr’s picture

Great, thanks @omers!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed c58bca3 and pushed to 8.0.x. Thanks!

  • alexpott committed c58bca3 on 8.0.x
    Issue #2325571 followup by omers: Replace _theme() calls by calls to \...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.