Adds the possibility to generate a fragment URI for a given Controller.
@author Fabien Potencier <fabien@symfony.com>
Expanded class hierarchy of RoutableFragmentRenderer
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, '', '&'));
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FragmentRendererInterface:: |
public | function | Gets the name of the strategy. | 4 |
FragmentRendererInterface:: |
public | function | Renders a URI and returns the Response content. | 4 |
RoutableFragmentRenderer:: |
private | property | ||
RoutableFragmentRenderer:: |
protected | function | Generates a fragment URI for a given controller. | |
RoutableFragmentRenderer:: |
public | function | Sets the fragment path that triggers the fragment listener. |