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 | use Twig\Environment; |
||
7 | use Twig\Extension\AbstractExtension; |
||
8 | use Twig\TwigFunction; |
||
9 | |||
10 | /** |
||
11 | * PagePartAdminTwigExtension |
||
12 | * |
||
13 | * @final since 5.4 |
||
14 | */ |
||
15 | class PagePartAdminTwigExtension extends AbstractExtension |
||
16 | { |
||
17 | private $usesExtendedPagePartChooser = false; |
||
18 | |||
19 | /** |
||
20 | * @return array |
||
21 | */ |
||
22 | public function getFunctions() |
||
23 | { |
||
24 | return [ |
||
25 | new TwigFunction('pagepartadmin_widget', [$this, 'renderWidget'], ['needs_environment' => true, 'is_safe' => ['html']]), |
||
26 | ]; |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * Renders the HTML for a given pagepart |
||
31 | * |
||
32 | * Example usage in Twig: |
||
33 | * |
||
34 | * {{ pagepartadmin_widget(ppAdmin) }} |
||
35 | * |
||
36 | * You can pass options during the call: |
||
37 | * |
||
38 | * {{ pagepartadmin_widget(ppAdmin, {'attr': {'class': 'foo'}}) }} |
||
39 | * |
||
40 | * {{ pagepartadmin_widget(ppAdmin, {'separator': '+++++'}) }} |
||
41 | * |
||
42 | * @param Environment $env |
||
43 | * @param PagePartAdmin $ppAdmin The pagepart admin to render |
||
44 | * @param Form $form The form |
||
45 | * @param array $parameters Additional variables passed to the template |
||
46 | * @param string $templateName |
||
47 | * |
||
48 | * @return string The html markup |
||
49 | */ |
||
50 | public function renderWidget(Environment $env, PagePartAdmin $ppAdmin, $form = null, array $parameters = [], $templateName = null) |
||
51 | { |
||
52 | if ($templateName === null) { |
||
53 | $templateName = '@KunstmaanPagePart/PagePartAdminTwigExtension/widget.html.twig'; |
||
54 | } |
||
55 | |||
56 | $template = $env->load($templateName); |
||
57 | |||
58 | return $template->render(array_merge($parameters, [ |
||
59 | 'pagepartadmin' => $ppAdmin, |
||
60 | 'page' => $ppAdmin->getPage(), |
||
61 | 'form' => $form, |
||
62 | 'extended' => $this->usesExtendedPagePartChooser, |
||
63 | ])); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * Get usesExtendedPagePartChooser. |
||
68 | * |
||
69 | * @return usesExtendedPagePartChooser |
||
70 | */ |
||
71 | public function getUsesExtendedPagePartChooser() |
||
72 | { |
||
73 | return $this->usesExtendedPagePartChooser; |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * Set usesExtendedPagePartChooser. |
||
78 | * |
||
79 | * @param usesExtendedPagePartChooser the value to set |
||
80 | */ |
||
81 | public function setUsesExtendedPagePartChooser($usesExtendedPagePartChooser) |
||
82 | { |
||
83 | $this->usesExtendedPagePartChooser = $usesExtendedPagePartChooser; |
||
0 ignored issues
–
show
|
|||
84 | } |
||
85 | } |
||
86 |
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..