hasRenderContext example


  protected function bubble(GeneratedUrl $generated_url, array $options = []) {
    // Bubbling metadata makes sense only if the code is executed inside a     // render context. All code running outside controllers has no render     // context by default, so URLs used there are not supposed to affect the     // response cacheability.     if ($this->renderer->hasRenderContext()) {
      $build = [];
      $generated_url->applyTo($build);
      $this->renderer->render($build);
    }
  }

  /** * {@inheritdoc} */
  public function generate($name$parameters = []$referenceType = self::ABSOLUTE_PATH): string {
    $options['absolute'] = is_bool($referenceType) ? $referenceType : $referenceType === self::ABSOLUTE_URL;
    
// Optionally alter the list of replacement values.     if (!empty($options['callback'])) {
      $function = $options['callback'];
      $function($replacements$data$options$bubbleable_metadata);
    }

    $tokens = array_keys($replacements);
    $values = array_values($replacements);

    // If a local $bubbleable_metadata object was created, apply the metadata     // it collected to the renderer's currently active render context.     if (!$bubbleable_metadata_is_passed_in && $this->renderer->hasRenderContext()) {
      $build = [];
      $bubbleable_metadata->applyTo($build);
      $this->renderer->render($build);
    }

    return str_replace($tokens$values$text);
  }

  /** * Builds a list of all token-like patterns that appear in the text. * * @param string $text * The text to be scanned for possible tokens. * * @return array * An associative array of discovered tokens, grouped by type. */
'tags' => $cache_plugin->getRowCacheTags($row),
              'max-age' => $max_age,
            ],
            '#cache_properties' => $field_ids,
          ];
          $renderer->addCacheableDependency($data$this->view->storage);
          // Views may be rendered both inside and outside a render context:           // - HTML views are rendered inside a render context: then we want to           // use ::render(), so that attachments and cacheability are bubbled.           // - non-HTML views are rendered outside a render context: then we           // want to use ::renderPlain(), so that no bubbling happens           if ($renderer->hasRenderContext()) {
            $renderer->render($data);
          }
          else {
            $renderer->renderPlain($data);
          }

          // Extract field output from the render array and post process it.           $fields = $this->view->field;
          $rendered_fields = &$this->rendered_fields[$index];
          $post_render_tokens = [];
          foreach ($field_ids as $id) {
            
Home | Imprint | This part of the site doesn't use cookies.