These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\PagePartBundle\Twig\Extension; |
||
4 | |||
5 | use Kunstmaan\PagePartBundle\PagePartAdmin\PagePartAdmin; |
||
6 | |||
7 | /** |
||
8 | * PagePartAdminTwigExtension |
||
9 | */ |
||
10 | class PagePartAdminTwigExtension extends \Twig_Extension |
||
11 | { |
||
12 | private $usesExtendedPagePartChooser = false; |
||
13 | |||
14 | /** |
||
15 | * @return array |
||
16 | */ |
||
17 | public function getFunctions() |
||
18 | { |
||
19 | return [ |
||
20 | new \Twig_SimpleFunction('pagepartadmin_widget', [$this, 'renderWidget'], ['needs_environment' => true, 'is_safe' => ['html']]), |
||
0 ignored issues
–
show
|
|||
21 | ]; |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * Renders the HTML for a given pagepart |
||
26 | * |
||
27 | * Example usage in Twig: |
||
28 | * |
||
29 | * {{ pagepartadmin_widget(ppAdmin) }} |
||
30 | * |
||
31 | * You can pass options during the call: |
||
32 | * |
||
33 | * {{ pagepartadmin_widget(ppAdmin, {'attr': {'class': 'foo'}}) }} |
||
34 | * |
||
35 | * {{ pagepartadmin_widget(ppAdmin, {'separator': '+++++'}) }} |
||
36 | * |
||
37 | * @param \Twig_Environment $env |
||
38 | * @param PagePartAdmin $ppAdmin The pagepart admin to render |
||
39 | * @param Form $form The form |
||
40 | * @param array $parameters Additional variables passed to the template |
||
41 | * @param string $templateName |
||
42 | * |
||
43 | * @return string The html markup |
||
44 | */ |
||
45 | public function renderWidget(\Twig_Environment $env, PagePartAdmin $ppAdmin, $form = null, array $parameters = [], $templateName = null) |
||
46 | { |
||
47 | if ($templateName === null) { |
||
48 | $templateName = 'KunstmaanPagePartBundle:PagePartAdminTwigExtension:widget.html.twig'; |
||
49 | } |
||
50 | |||
51 | $template = $env->loadTemplate($templateName); |
||
52 | |||
53 | return $template->render(array_merge($parameters, [ |
||
54 | 'pagepartadmin' => $ppAdmin, |
||
55 | 'page' => $ppAdmin->getPage(), |
||
56 | 'form' => $form, |
||
57 | 'extended' => $this->usesExtendedPagePartChooser, |
||
58 | ])); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * Get usesExtendedPagePartChooser. |
||
63 | * |
||
64 | * @return usesExtendedPagePartChooser |
||
65 | */ |
||
66 | public function getUsesExtendedPagePartChooser() |
||
67 | { |
||
68 | return $this->usesExtendedPagePartChooser; |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * Set usesExtendedPagePartChooser. |
||
73 | * |
||
74 | * @param usesExtendedPagePartChooser the value to set |
||
75 | */ |
||
76 | public function setUsesExtendedPagePartChooser($usesExtendedPagePartChooser) |
||
77 | { |
||
78 | $this->usesExtendedPagePartChooser = $usesExtendedPagePartChooser; |
||
0 ignored issues
–
show
It seems like
$usesExtendedPagePartChooser of type object<Kunstmaan\PagePar...dle\Twig\Extension\the> is incompatible with the declared type boolean of property $usesExtendedPagePartChooser .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..
Loading history...
|
|||
79 | } |
||
80 | } |
||
81 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.