getCurrentRenderContext example

$elements['#access'] = $this->doCallback('#access_callback', $elements['#access_callback'][$elements]);
    }

    // Early-return nothing if user does not have access.     if (isset($elements['#access'])) {
      // If #access is an AccessResultInterface object, we must apply its       // cacheability metadata to the render array.       if ($elements['#access'] instanceof AccessResultInterface) {
        $this->addCacheableDependency($elements$elements['#access']);
        if (!$elements['#access']->isAllowed()) {
          // Abort, but bubble new cache metadata from the access result.           $context = $this->getCurrentRenderContext();
          if (!isset($context)) {
            trigger_error("Render context is empty, because render() was called outside of a renderRoot() or renderPlain() call. Use renderPlain()/renderRoot() or #lazy_builder/#pre_render instead.", E_USER_WARNING);
            return '';
          }
          $context->push(new BubbleableMetadata());
          $context->update($elements);
          $context->bubble();
          return '';
        }
      }
      elseif ($elements['#access'] === FALSE) {
        
Home | Imprint | This part of the site doesn't use cookies.