1 | <?php |
||
37 | abstract class AbstractDataTablesProvider implements DataTablesProviderInterface { |
||
38 | |||
39 | use ButtonTwigExtensionTrait; |
||
40 | use RouterTrait; |
||
41 | use TranslatorTrait; |
||
42 | |||
43 | /** |
||
44 | * Constructor. |
||
45 | * |
||
46 | * @param RouterInterface $router The router. |
||
47 | * @param TranslatorInterface $translator The translator. |
||
48 | * @param ButtonTwigExtension $buttonTwigExtension The button Twig extension. |
||
49 | */ |
||
50 | public function __construct(RouterInterface $router, TranslatorInterface $translator, ButtonTwigExtension $buttonTwigExtension) { |
||
55 | |||
56 | /** |
||
57 | * {@inheritDoc} |
||
58 | */ |
||
59 | public function getCSVExporter() { |
||
62 | |||
63 | /** |
||
64 | * {@inheritDoc} |
||
65 | */ |
||
66 | public function getEditor() { |
||
69 | |||
70 | /** |
||
71 | * {@inheritDoc} |
||
72 | */ |
||
73 | public function getMethod() { |
||
76 | |||
77 | /** |
||
78 | * {@inheritDoc} |
||
79 | */ |
||
80 | public function getOptions() { |
||
88 | |||
89 | /** |
||
90 | * Render an action button "delete". |
||
91 | * |
||
92 | * @param DataTablesEntityInterface $entity The entity. |
||
93 | * @param string $route The route. |
||
94 | * @return string Returns the action button "delete". |
||
95 | * @throws InvalidArgumentException Throws an invalid argument exception if the entity is invalid. |
||
96 | * @throws InvalidParameterException Throws an invalid parameter exception if a parameter is invalid. |
||
97 | * @throws RouteNotFoundException Throws a route not found exception if the route doesn't exist. |
||
98 | * @throws MissingMandatoryParametersException Throws a missing mandatory parameter exception if a mandatory exception is missing. |
||
99 | */ |
||
100 | protected function renderActionButtonDelete($entity, $route) { |
||
114 | |||
115 | /** |
||
116 | * Render an action button "duplicate". |
||
117 | * |
||
118 | * @param DataTablesEntityInterface $entity The entity. |
||
119 | * @param string $route The route. |
||
120 | * @return string Returns the action button "duplicate". |
||
121 | * @throws InvalidArgumentException Throws an invalid argument exception if the entity is invalid. |
||
122 | * @throws InvalidParameterException Throws an invalid parameter exception if a parameter is invalid. |
||
123 | * @throws RouteNotFoundException Throws a route not found exception if the route doesn't exist. |
||
124 | * @throws MissingMandatoryParametersException Throws a missing mandatory parameter exception if a mandatory exception is missing. |
||
125 | */ |
||
126 | protected function renderActionButtonDuplicate($entity, $route) { |
||
138 | |||
139 | /** |
||
140 | * Render an action button "edit". |
||
141 | * |
||
142 | * @param DataTablesEntityInterface $entity The entity. |
||
143 | * @param string $route The route. |
||
144 | * @return string Returns the action button "edit". |
||
145 | * @throws InvalidArgumentException Throws an invalid argument exception if the entity is invalid. |
||
146 | * @throws InvalidParameterException Throws an invalid parameter exception if a parameter is invalid. |
||
147 | * @throws RouteNotFoundException Throws a route not found exception if the route doesn't exist. |
||
148 | * @throws MissingMandatoryParametersException Throws a missing mandatory parameter exception if a mandatory exception is missing. |
||
149 | */ |
||
150 | protected function renderActionButtonEdit($entity, $route) { |
||
162 | |||
163 | /** |
||
164 | * Render an action button "show". |
||
165 | * |
||
166 | * @param DataTablesEntityInterface $entity The entity. |
||
167 | * @param string $route The route. |
||
168 | * @return string Returns the action button "show". |
||
169 | * @throws InvalidArgumentException Throws an invalid argument exception if the entity is invalid. |
||
170 | * @throws InvalidParameterException Throws an invalid parameter exception if a parameter is invalid. |
||
171 | * @throws RouteNotFoundException Throws a route not found exception if the route doesn't exist. |
||
172 | * @throws MissingMandatoryParametersException Throws a missing mandatory parameter exception if a mandatory exception is missing. |
||
173 | */ |
||
174 | protected function renderActionButtonShow($entity, $route) { |
||
186 | |||
187 | /** |
||
188 | * Render the DataTables buttons. |
||
189 | * |
||
190 | * @param DataTablesEntityInterface $entity The entity. |
||
191 | * @param string $editRoute The edit route. |
||
192 | * @param string $deleteRoute The delete route. |
||
193 | * @param bool $enableDelete Enable delete ? |
||
194 | * @return string Returns the DataTables buttons. |
||
195 | * @throws InvalidArgumentException Throws an invalid argument exception if the entity is invalid. |
||
196 | * @throws InvalidParameterException Throws an invalid parameter exception if a parameter is invalid. |
||
197 | * @throws RouteNotFoundException Throws a route not found exception if the route doesn't exist. |
||
198 | * @throws MissingMandatoryParametersException Throws a missing mandatory parameter exception if a mandatory exception is missing. |
||
199 | * @deprecated since 3.4.0 use {@see WBW\Bundle\JQuery\DataTablesBundle\Provider\AbstractDataTablesProvider::renderRowButtons()} instead |
||
200 | */ |
||
201 | protected function renderButtons($entity, $editRoute, $deleteRoute = null, $enableDelete = true) { |
||
207 | |||
208 | /** |
||
209 | * Render a date. |
||
210 | * |
||
211 | * @param DateTime $date The date. |
||
212 | * @param string $format The format. |
||
213 | * @return string Returns the rendered date. |
||
214 | */ |
||
215 | protected function renderDate(DateTime $date = null, $format = "Y-m-d") { |
||
218 | |||
219 | /** |
||
220 | * Render a date/time. |
||
221 | * |
||
222 | * @param DateTime $date The date/time. |
||
223 | * @param string $format The format. |
||
224 | * @return string Returns the rendered date/time. |
||
225 | */ |
||
226 | protected function renderDateTime(DateTime $date = null, $format = DateTimeRenderer::DATETIME_FORMAT) { |
||
229 | |||
230 | /** |
||
231 | * Render a float. |
||
232 | * |
||
233 | * @param float $number The number. |
||
234 | * @param int $decimals The decimals. |
||
235 | * @param string $decPoint The decimal point. |
||
236 | * @param string $thousandsSep The thousands separator. |
||
237 | * @return string Returns the rendered number. |
||
238 | */ |
||
239 | protected function renderFloat($number, $decimals = 2, $decPoint = ".", $thousandsSep = ",") { |
||
245 | |||
246 | /** |
||
247 | * {@inheritdoc} |
||
248 | */ |
||
249 | public function renderRow($dtRow, $entity, $rowNumber) { |
||
269 | |||
270 | /** |
||
271 | * Render the DataTables row buttons. |
||
272 | * |
||
273 | * @param DataTablesEntityInterface $entity The entity. |
||
274 | * @param string|null $editRoute The edit route. |
||
275 | * @param string|null $deleteRoute The delete route. |
||
276 | * @param string|null $showRoute The show route. |
||
277 | * @return string Returns the DataTables row buttons. |
||
278 | * @throws InvalidArgumentException Throws an invalid argument exception if the entity is invalid. |
||
279 | * @throws InvalidParameterException Throws an invalid parameter exception if a parameter is invalid. |
||
280 | * @throws RouteNotFoundException Throws a route not found exception if the route doesn't exist. |
||
281 | * @throws MissingMandatoryParametersException Throws a missing mandatory parameter exception if a mandatory exception is missing. |
||
282 | */ |
||
283 | protected function renderRowButtons($entity, $editRoute = null, $deleteRoute = null, $showRoute = null) { |
||
301 | |||
302 | /** |
||
303 | * Wrap a content. |
||
304 | * |
||
305 | * @param string|null $prefix The prefix |
||
306 | * @param string $content The content. |
||
307 | * @param string|null $suffix The suffix. |
||
308 | * @return string Returns the wrapped content. |
||
309 | */ |
||
310 | protected function wrapContent($prefix, $content, $suffix) { |
||
324 | } |
||
325 |