Created
April 28, 2015 20:11
-
-
Save LionsAd/3a03f5c7716652ff767d to your computer and use it in GitHub Desktop.
toRenderArray support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php | |
| index bb29cd1..5461283 100644 | |
| --- a/core/lib/Drupal/Core/Template/TwigExtension.php | |
| +++ b/core/lib/Drupal/Core/Template/TwigExtension.php | |
| @@ -420,7 +420,11 @@ public function renderVar($arg) { | |
| } | |
| if (is_object($arg)) { | |
| - if (method_exists($arg, '__toString')) { | |
| + // @todo Replace with a proper interface. | |
| + if (method_exists($arg, 'toRenderArray')) { | |
| + return $this->renderer->render($arg->toRenderArray()); | |
| + } | |
| + elseif (method_exists($arg, '__toString')) { | |
| return (string) $arg; | |
| } | |
| // You can't throw exceptions in the magic PHP __toString methods, see |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment