@@ -455,8 +455,8 @@ protected function deleteEntities(
455
455
}
456
456
457
457
/**
458
- * @param array<string, array<array{'target': string, 'targetColumn': string, 'type': string}>> $relations
459
- * @return string[]
458
+ * @template T of object
459
+ * @param class- string<T> $entityClass
460
460
*/
461
461
protected function deleteMultiple (
462
462
Request $ request ,
@@ -471,7 +471,9 @@ protected function deleteMultiple(
471
471
throw new BadRequestHttpException ('No IDs specified for deletion ' );
472
472
}
473
473
474
- $ entities = $ this ->em ->getRepository ($ entityClass )->findBy ([$ idProperty => $ ids ]);
474
+ /** @var \Doctrine\ORM\EntityRepository<T> $repository */
475
+ $ repository = $ this ->em ->getRepository ($ entityClass );
476
+ $ entities = $ repository ->findBy ([$ idProperty => $ ids ]);
475
477
476
478
if ($ filter ) {
477
479
$ entities = array_filter ($ entities , $ filter );
@@ -485,7 +487,10 @@ protected function deleteMultiple(
485
487
return $ this ->deleteEntities ($ request , $ entities , $ this ->generateUrl ($ redirectRoute ));
486
488
}
487
489
488
-
490
+ /**
491
+ * @param array<string, array<array{'target': string, 'targetColumn': string, 'type': string}>> $relations
492
+ * @return string[]
493
+ */
489
494
protected function getDependentEntities (string $ entityClass , array $ relations ): array
490
495
{
491
496
$ result = [];
@@ -514,6 +519,39 @@ protected function getDependentEntities(string $entityClass, array $relations):
514
519
return $ result ;
515
520
}
516
521
522
+ /**
523
+ * @param array<string, array<string, mixed>> $table_fields
524
+ */
525
+ protected function addSelectAllCheckbox (array &$ table_fields , string $ title ): void
526
+ {
527
+ if ($ this ->isGranted ('ROLE_ADMIN ' )) {
528
+ $ table_fields = array_merge (
529
+ ['checkbox ' => ['title ' => sprintf ('<input type="checkbox" class="select-all" title="Select all %s"> ' , $ title ), 'sort ' => false , 'search ' => false , 'raw ' => true ]],
530
+ $ table_fields
531
+ );
532
+ }
533
+ }
534
+
535
+ /**
536
+ * @param array<string, mixed> $data
537
+ */
538
+ protected function addEntityCheckbox (array &$ data , object $ entity , mixed $ identifierValue , string $ checkboxClass , ?callable $ condition = null ): void
539
+ {
540
+ if ($ this ->isGranted ('ROLE_ADMIN ' )) {
541
+ if ($ condition !== null && !$ condition ($ entity )) {
542
+ $ data ['checkbox ' ] = ['value ' => '' ];
543
+ return ;
544
+ }
545
+ $ data ['checkbox ' ] = [
546
+ 'value ' => sprintf (
547
+ '<input type="checkbox" name="ids[]" value="%s" class="%s"> ' ,
548
+ $ identifierValue ,
549
+ $ checkboxClass
550
+ )
551
+ ];
552
+ }
553
+ }
554
+
517
555
/**
518
556
* Get the contests that an event for the given entity should be triggered on
519
557
*
0 commit comments