diff -u b/core/lib/Drupal/Core/Render/RenderVariable.php b/core/lib/Drupal/Core/Render/RenderVariable.php --- b/core/lib/Drupal/Core/Render/RenderVariable.php +++ b/core/lib/Drupal/Core/Render/RenderVariable.php @@ -7,21 +7,25 @@ namespace Drupal\Core\Render; -use Drupal\Component\Utility\SafeMarkup; +use Drupal\Component\Render\MarkupInterface; +/** + * Provides helpers to generate render arrays. + */ class RenderVariable { /** * Prefixes a render variable. * - * @param string|\Drupal\Component\Utility\SafeStringInterface|array $thing + * @param string|\Drupal\Component\Render\MarkupInterface|array $thing * A render variable. Either a string, an object that is safe or a render * array. - * @param string|\Drupal\Component\Utility\SafeStringInterface... + * @param string|\Drupal\Component\Render\MarkupInterface... * Prefixes to add to the render variable. By default these will XSS admin * filtered. * * @return array + * A render array. */ public static function prefix($thing) { $args = func_get_args(); @@ -34,20 +38,22 @@ $output = static::makeRenderArray($output); $output['#prefix'] = $arg; } + return $output; } /** * Suffixes a render variable. * - * @param string|\Drupal\Component\Utility\SafeStringInterface|array $thing + * @param string|\Drupal\Component\Render\MarkupInterface|array $thing * A render variable. Either a string, an object that is safe or a render * array. - * @param string|\Drupal\Component\Utility\SafeStringInterface... + * @param string|\Drupal\Component\Render\MarkupInterface... * Suffixes to add to the render variable. By default these will XSS admin * filtered. * * @return array + * A render array. */ public static function suffix($thing) { $args = func_get_args(); @@ -60,36 +66,38 @@ $output = static::makeRenderArray($output); $output['#suffix'] = $arg; } + return $output; } /** * Wraps a render variable. * - * @param string|\Drupal\Component\Utility\SafeStringInterface|array $thing + * @param string|\Drupal\Component\Render\MarkupInterface|array $thing * A render variable. Either a string, an object that is safe or a render * array. - * @param string|\Drupal\Component\Utility\SafeStringInterface $prefix + * @param string|\Drupal\Component\Render\MarkupInterface $prefix * Prefix to add to the render variable. By default this will XSS admin * filtered. - * @param string|\Drupal\Component\Utility\SafeStringInterface $suffix + * @param string|\Drupal\Component\Render\MarkupInterface $suffix * Prefix to add to the render variable. By default this will XSS admin * filtered. * * @return array + * A render array. */ - public static function wrap($thing, $prefix, $suffix) { $output = static::makeRenderArray($thing); $output['#prefix'] = $prefix; $output['#suffix'] = $suffix; + return $output; } /** * Converts a render variable into a render array. * - * @param string|\Drupal\Component\Utility\SafeStringInterface|array $thing + * @param string|\Drupal\Component\Render\MarkupInterface|array $thing * A render variable. Either a string, an object that is safe or a render * array. * @@ -98,7 +106,7 @@ */ protected static function makeRenderArray($thing) { if (!is_array($thing)) { - if (SafeMarkup::isSafe($thing)) { + if ($thing instanceof MarkupInterface) { $output = [ '#markup' => $thing, ]; @@ -117,4 +125,5 @@ + return $output; } -} \ No newline at end of file +}