abstract class RoutableFragmentRenderer

Adds the possibility to generate a fragment URI for a given Controller.

@author Fabien Potencier <fabien@symfony.com>

Hierarchy

Expanded class hierarchy of RoutableFragmentRenderer

1 file declares its use of RoutableFragmentRenderer
RoutableFragmentRendererTest.php in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/RoutableFragmentRenderer.php, line 23

Namespace

Symfony\Component\HttpKernel\Fragment
View source
abstract class RoutableFragmentRenderer implements FragmentRendererInterface {
  private $fragmentPath = '/_fragment';

  /**
   * Sets the fragment path that triggers the fragment listener.
   *
   * @param string $path The path
   *
   * @see FragmentListener
   */
  public function setFragmentPath($path) {
    $this->fragmentPath = $path;
  }

  /**
   * Generates a fragment URI for a given controller.
   *
   * @param ControllerReference  $reference A ControllerReference instance
   * @param Request              $request    A Request instance
   *
   * @return string A fragment URI
   */
  protected function generateFragmentUri(ControllerReference $reference, Request $request) {
    if (!isset($reference->attributes['_format'])) {
      $reference->attributes['_format'] = $request
        ->getRequestFormat();
    }
    $reference->attributes['_controller'] = $reference->controller;
    $reference->query['_path'] = http_build_query($reference->attributes, '', '&');
    return $request
      ->getUriForPath($this->fragmentPath . '?' . http_build_query($reference->query, '', '&'));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FragmentRendererInterface::getName public function Gets the name of the strategy. 4
FragmentRendererInterface::render public function Renders a URI and returns the Response content. 4
RoutableFragmentRenderer::$fragmentPath private property
RoutableFragmentRenderer::generateFragmentUri protected function Generates a fragment URI for a given controller.
RoutableFragmentRenderer::setFragmentPath public function Sets the fragment path that triggers the fragment listener.