@@ -455,8 +455,8 @@ protected function deleteEntities(
455455 }
456456
457457 /**
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
460460 */
461461 protected function deleteMultiple (
462462 Request $ request ,
@@ -471,7 +471,9 @@ protected function deleteMultiple(
471471 throw new BadRequestHttpException ('No IDs specified for deletion ' );
472472 }
473473
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 ]);
475477
476478 if ($ filter ) {
477479 $ entities = array_filter ($ entities , $ filter );
@@ -486,6 +488,10 @@ protected function deleteMultiple(
486488 }
487489
488490
491+ /**
492+ * @param array<string, array<array{'target': string, 'targetColumn': string, 'type': string}>> $relations
493+ * @return string[]
494+ */
489495 protected function getDependentEntities (string $ entityClass , array $ relations ): array
490496 {
491497 $ result = [];
@@ -514,6 +520,39 @@ protected function getDependentEntities(string $entityClass, array $relations):
514520 return $ result ;
515521 }
516522
523+ /**
524+ * @param array<string, array<string, mixed>> $table_fields
525+ */
526+ protected function addSelectAllCheckbox (array &$ table_fields , string $ title ): void
527+ {
528+ if ($ this ->isGranted ('ROLE_ADMIN ' )) {
529+ $ table_fields = array_merge (
530+ ['checkbox ' => ['title ' => sprintf ('<input type="checkbox" class="select-all" title="Select all %s"> ' , $ title ), 'sort ' => false , 'search ' => false , 'raw ' => true ]],
531+ $ table_fields
532+ );
533+ }
534+ }
535+
536+ /**
537+ * @param array<string, mixed> $data
538+ */
539+ protected function addEntityCheckbox (array &$ data , object $ entity , mixed $ identifierValue , string $ checkboxClass , ?callable $ condition = null ): void
540+ {
541+ if ($ this ->isGranted ('ROLE_ADMIN ' )) {
542+ if ($ condition !== null && !$ condition ($ entity )) {
543+ $ data ['checkbox ' ] = ['value ' => '' ];
544+ return ;
545+ }
546+ $ data ['checkbox ' ] = [
547+ 'value ' => sprintf (
548+ '<input type="checkbox" name="ids[]" value="%s" class="%s"> ' ,
549+ $ identifierValue ,
550+ $ checkboxClass
551+ )
552+ ];
553+ }
554+ }
555+
517556 /**
518557 * Get the contests that an event for the given entity should be triggered on
519558 *
0 commit comments