1 | <?php |
||
2 | |||
3 | namespace Dtc\GridBundle\Grid\Renderer; |
||
4 | |||
5 | use Symfony\Component\Routing\RouterInterface; |
||
0 ignored issues
–
show
|
|||
6 | use Twig\Environment; |
||
0 ignored issues
–
show
The type
Twig\Environment was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
7 | |||
8 | class RendererFactory |
||
9 | { |
||
10 | protected $twig; |
||
11 | protected $router; |
||
12 | protected $translator; |
||
13 | protected $themeCss; |
||
14 | protected $themeJs; |
||
15 | protected $pageDivStyle; |
||
16 | protected $jqGridJs; |
||
17 | protected $jqGridCss; |
||
18 | protected $jqGridLocalJs; |
||
19 | protected $jqGridLocalCss; |
||
20 | protected $jqGridOptions; |
||
21 | protected $tableOptions; |
||
22 | protected $dataTablesCss; |
||
23 | protected $dataTablesJs; |
||
24 | protected $dataTablesLocalCss; |
||
25 | protected $dataTablesLocalJs; |
||
26 | protected $dataTablesClass; |
||
27 | protected $dataTablesOptions; |
||
28 | protected $jQuery; |
||
29 | protected $purl; |
||
30 | |||
31 | public function __construct( |
||
32 | RouterInterface $router, |
||
33 | $translator, |
||
34 | array $config |
||
35 | ) { |
||
36 | $this->router = $router; |
||
37 | $this->translator = $translator; |
||
38 | $this->themeCss = $config['theme.css']; |
||
39 | $this->themeJs = $config['theme.js']; |
||
40 | $this->pageDivStyle = $config['page_div_style']; |
||
41 | $this->jQuery = $config['jquery']; |
||
42 | $this->purl = $config['purl']; |
||
43 | $this->dataTablesCss = $config['datatables.css']; |
||
44 | $this->dataTablesJs = $config['datatables.js']; |
||
45 | $this->dataTablesLocalCss = $config['datatables.local.css']; |
||
46 | $this->dataTablesLocalJs = $config['datatables.local.js']; |
||
47 | $this->dataTablesClass = $config['datatables.class']; |
||
48 | $this->dataTablesOptions = $config['datatables.options']; |
||
49 | $this->jqGridCss = $config['jq_grid.css']; |
||
50 | $this->jqGridJs = $config['jq_grid.js']; |
||
51 | $this->jqGridLocalCss = $config['jq_grid.local.css']; |
||
52 | $this->jqGridLocalJs = $config['jq_grid.local.js']; |
||
53 | $this->jqGridOptions = $config['jq_grid.options']; |
||
54 | $this->tableOptions = $config['table.options']; |
||
55 | } |
||
56 | |||
57 | public function setTwigEnvironment(Environment $twig) |
||
58 | { |
||
59 | $this->twig = $twig; |
||
60 | } |
||
61 | |||
62 | public function getTwigEnvironment() |
||
63 | { |
||
64 | return $this->twig; |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * Creates a new renderer of type $type, throws an exception if it's not known how to create a renderer of type $type. |
||
69 | * |
||
70 | * @param $type |
||
71 | * |
||
72 | * @return AbstractRenderer |
||
73 | * |
||
74 | * @throws \Exception |
||
75 | */ |
||
76 | public function create($type) |
||
77 | { |
||
78 | $twig = $this->getTwigEnvironment(); |
||
79 | if (!$twig) { |
||
80 | throw new \Exception('Twig Engine not found. Please see https://github.com/mmucklo/DtcGridBundle/README.md for instructions.'); |
||
81 | } |
||
82 | switch ($type) { |
||
83 | case 'datatables': |
||
84 | $renderer = new DataTablesRenderer($this->twig, $this->router, $this->translator, $this->dataTablesOptions); |
||
85 | break; |
||
86 | case 'jq_grid': |
||
87 | $renderer = new JQGridRenderer($this->twig, $this->router, $this->translator, $this->jqGridOptions); |
||
88 | break; |
||
89 | case 'table': |
||
90 | $renderer = new TableGridRenderer($this->twig, $this->router, $this->translator, $this->tableOptions); |
||
91 | break; |
||
92 | default: |
||
93 | throw new \Exception("No renderer for type '$type''"); |
||
94 | } |
||
95 | |||
96 | if (method_exists($renderer, 'setThemeCss')) { |
||
97 | $renderer->setThemeCss($this->themeCss); |
||
98 | } |
||
99 | |||
100 | if (method_exists($renderer, 'setThemeJs')) { |
||
101 | $renderer->setThemeJs($this->themeJs); |
||
102 | } |
||
103 | |||
104 | if (method_exists($renderer, 'setJQuery')) { |
||
105 | $renderer->setJQuery($this->jQuery); |
||
106 | } |
||
107 | |||
108 | if (method_exists($renderer, 'setPurl')) { |
||
109 | $renderer->setPurl($this->purl); |
||
110 | } |
||
111 | |||
112 | if (method_exists($renderer, 'setPageDivStyle')) { |
||
113 | $renderer->setPageDivStyle($this->pageDivStyle); |
||
114 | } |
||
115 | |||
116 | if (method_exists($renderer, 'setJqGridCss')) { |
||
117 | $renderer->setJqGridCss($this->jqGridCss); |
||
118 | } |
||
119 | |||
120 | if (method_exists($renderer, 'setJqGridJs')) { |
||
121 | $renderer->setJqGridJs($this->jqGridJs); |
||
122 | } |
||
123 | |||
124 | if (method_exists($renderer, 'setJqGridLocalCss')) { |
||
125 | $renderer->setJqGridLocalCss($this->jqGridLocalCss); |
||
126 | } |
||
127 | |||
128 | if (method_exists($renderer, 'setJqGridLocalJs')) { |
||
129 | $renderer->setJqGridLocalJs($this->jqGridLocalJs); |
||
130 | } |
||
131 | |||
132 | if (method_exists($renderer, 'setDataTablesCss')) { |
||
133 | $renderer->setDataTablesCss($this->dataTablesCss); |
||
134 | } |
||
135 | |||
136 | if (method_exists($renderer, 'setDataTablesJs')) { |
||
137 | $renderer->setDataTablesJs($this->dataTablesJs); |
||
138 | } |
||
139 | |||
140 | if (method_exists($renderer, 'setDataTablesLocalCss')) { |
||
141 | $renderer->setDataTablesLocalCss($this->dataTablesLocalCss); |
||
142 | } |
||
143 | |||
144 | if (method_exists($renderer, 'setDataTablesLocalJs')) { |
||
145 | $renderer->setDataTablesLocalJs($this->dataTablesLocalJs); |
||
146 | } |
||
147 | |||
148 | if (method_exists($renderer, 'setDatatablesClass') && $this->dataTablesClass) { |
||
149 | $renderer->setDatatablesClass($this->dataTablesClass); |
||
150 | } |
||
151 | |||
152 | return $renderer; |
||
153 | } |
||
154 | } |
||
155 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths