Skip to content
Snippets Groups Projects

Issue #2258355: Move hide and show to render/element class

Open Bhanu D requested to merge issue/drupal-2258355:2258355-move-hide-and into 10.1.x
4 files
+ 65
30
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 16
25
@@ -348,14 +348,8 @@ function drupal_attach_tabledrag(&$element, array $options) {
/**
* Hides an element from later rendering.
*
* The first time render() or RenderInterface::render() is called on an element
* tree, as each element in the tree is rendered, it is marked with a #printed
* flag and the rendered children of the element are cached. Subsequent calls to
* render() or RenderInterface::render() will not traverse the child tree of
* this element again: they will just use the cached children. So if you want to
* hide an element, be sure to call hide() on the element before its parent tree
* is rendered for the first time, as it will have no effect on subsequent
* renderings of the parent tree.
* Refer to Drupal\core\lib\Drupal\Core\Render\RendererInterface::render()
* for additional documentation.
*
* @param $element
* The element to be hidden.
@@ -363,11 +357,14 @@ function drupal_attach_tabledrag(&$element, array $options) {
* @return array
* The element.
*
* @see \Drupal\Core\Render\RendererInterface
* @see render()
* @see show()
* @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use
* to inline #printed=TRUE instead.
*
* @see https://www.drupal.org/node/3261271
* @see \Drupal\Core\Render\RendererInterface::render()
*/
function hide(&$element) {
@trigger_error('The global hide() function is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use to inline #printed=TRUE instead. See https://www.drupal.org/node/3261271', E_USER_DEPRECATED);
$element['#printed'] = TRUE;
return $element;
}
@@ -375,17 +372,8 @@ function hide(&$element) {
/**
* Shows a hidden element for later rendering.
*
* You can also use render($element), which shows the element while rendering
* it.
*
* The first time render() or RenderInterface::render() is called on an element
* tree, as each element in the tree is rendered, it is marked with a #printed
* flag and the rendered children of the element are cached. Subsequent calls to
* render() or RenderInterface::render() will not traverse the child tree of
* this element again: they will just use the cached children. So if you want to
* show an element, be sure to call show() on the element before its parent tree
* is rendered for the first time, as it will have no effect on subsequent
* renderings of the parent tree.
* Refer to Drupal\core\lib\Drupal\Core\Render\RendererInterface::render()
* for additional documentation.
*
* @param $element
* The element to be shown.
@@ -393,11 +381,14 @@ function hide(&$element) {
* @return array
* The element.
*
* @see \Drupal\Core\Render\RendererInterface
* @see render()
* @see hide()
* @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use
* to inline #printed=FALSE instead.
*
* @see https://www.drupal.org/node/3261271
* @see \Drupal\Core\Render\RendererInterface::render()
*/
function show(&$element) {
@trigger_error('The global show() function is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use to inline #printed=FALSE instead. See https://www.drupal.org/node/3261271', E_USER_DEPRECATED);
$element['#printed'] = FALSE;
return $element;
}
Loading