| 148 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
* This file is part of the Symfony package.
|
|
|
5 |
*
|
|
|
6 |
* (c) Fabien Potencier <fabien@symfony.com>
|
|
|
7 |
*
|
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
|
|
9 |
* file that was distributed with this source code.
|
|
|
10 |
*/
|
|
|
11 |
|
|
|
12 |
namespace Symfony\Component\HttpKernel\Fragment;
|
|
|
13 |
|
|
|
14 |
use Symfony\Component\HttpFoundation\Request;
|
|
|
15 |
use Symfony\Component\HttpKernel\Controller\ControllerReference;
|
|
|
16 |
use Symfony\Component\HttpKernel\EventListener\FragmentListener;
|
|
|
17 |
|
|
|
18 |
/**
|
|
|
19 |
* Adds the possibility to generate a fragment URI for a given Controller.
|
|
|
20 |
*
|
|
|
21 |
* @author Fabien Potencier <fabien@symfony.com>
|
|
|
22 |
*/
|
|
|
23 |
abstract class RoutableFragmentRenderer implements FragmentRendererInterface
|
|
|
24 |
{
|
|
|
25 |
/**
|
|
|
26 |
* @internal
|
|
|
27 |
*/
|
|
|
28 |
protected $fragmentPath = '/_fragment';
|
|
|
29 |
|
|
|
30 |
/**
|
|
|
31 |
* Sets the fragment path that triggers the fragment listener.
|
|
|
32 |
*
|
|
|
33 |
* @see FragmentListener
|
|
|
34 |
*/
|
|
|
35 |
public function setFragmentPath(string $path)
|
|
|
36 |
{
|
|
|
37 |
$this->fragmentPath = $path;
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
/**
|
|
|
41 |
* Generates a fragment URI for a given controller.
|
|
|
42 |
*
|
|
|
43 |
* @param bool $absolute Whether to generate an absolute URL or not
|
|
|
44 |
* @param bool $strict Whether to allow non-scalar attributes or not
|
|
|
45 |
*/
|
|
|
46 |
protected function generateFragmentUri(ControllerReference $reference, Request $request, bool $absolute = false, bool $strict = true): string
|
|
|
47 |
{
|
|
|
48 |
return (new FragmentUriGenerator($this->fragmentPath))->generate($reference, $request, $absolute, $strict, false);
|
|
|
49 |
}
|
|
|
50 |
}
|