add ordoring field & Display Activity type by Category

This commit is contained in:
Jean-Francois Monfort
2021-05-06 11:53:07 +02:00
parent f836114d84
commit 1f1b9c594f
10 changed files with 134 additions and 17 deletions

View File

@@ -27,7 +27,6 @@ use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Privacy\PrivacyEvent;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
@@ -104,12 +103,24 @@ class ActivityController extends AbstractController
throw $this->createNotFoundException('Person not found');
}
$activityTypes = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityType::class)
->findBy(['active' => true]);
$data = [];
$activityTypeCategories = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityTypeCategory::class)
->findBy(['active' => true], ['ordering' => 'ASC']);
foreach ($activityTypeCategories as $activityTypeCategory) {
$activityTypes = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityType::class)
->findBy(['active' => true, 'category' => $activityTypeCategory], ['ordering' => 'ASC']);
$data[] = [
'activityTypeCategory' => $activityTypeCategory,
'activityTypes' => $activityTypes,
];
}
return $this->render('ChillActivityBundle:Activity:selectType.html.twig', [
'person' => $person,
'activityTypes' => $activityTypes,
'data' => $data,
]);
}