summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
dafd335)
Add dance listing to application form
Cleanup
<?php declare(strict_types=1);
/*
<?php declare(strict_types=1);
/*
- * This file is part of the Rapsys UserBundle package.
+ * This file is part of the Rapsys AirBundle package.
*
* (c) Raphaël Gertz <symfony@rapsys.eu>
*
*
* (c) Raphaël Gertz <symfony@rapsys.eu>
*
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Contracts\Service\ServiceSubscriberInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Contracts\Service\ServiceSubscriberInterface;
+use Rapsys\AirBundle\Entity\Dance;
use Rapsys\AirBundle\Entity\Location;
use Rapsys\AirBundle\Entity\Slot;
use Rapsys\AirBundle\Entity\User;
use Rapsys\AirBundle\RapsysAirBundle;
/**
use Rapsys\AirBundle\Entity\Location;
use Rapsys\AirBundle\Entity\Slot;
use Rapsys\AirBundle\Entity\User;
use Rapsys\AirBundle\RapsysAirBundle;
/**
* Provides common features needed in controllers.
*
* {@inheritdoc}
* Provides common features needed in controllers.
*
* {@inheritdoc}
//Fetch doctrine
$doctrine = $this->get('doctrine');
//Fetch doctrine
$doctrine = $this->get('doctrine');
+ //Get favorites dances
+ $danceFavorites = $doctrine->getRepository(Dance::class)->findByUserId($this->getUser()->getId());
+
+ //Set dance default
+ $danceDefault = !empty($danceFavorites)?current($danceFavorites):null;
+
//Get favorites locations
$locationFavorites = $doctrine->getRepository(Location::class)->findByUserId($this->getUser()->getId());
//Set location default
//Get favorites locations
$locationFavorites = $doctrine->getRepository(Location::class)->findByUserId($this->getUser()->getId());
//Set location default
- $locationDefault = current($locationFavorites);
+ $locationDefault = !empty($locationFavorites)?current($locationFavorites):null;
//With admin
if ($this->isGranted('ROLE_ADMIN')) {
//With admin
if ($this->isGranted('ROLE_ADMIN')) {
+ //Get dances
+ $dances = $doctrine->getRepository(Dance::class)->findAll();
+
//Get locations
$locations = $doctrine->getRepository(Location::class)->findAll();
//Without admin
} else {
//Get locations
$locations = $doctrine->getRepository(Location::class)->findAll();
//Without admin
} else {
+ //Restrict to favorite dances
+ $dances = $danceFavorites;
+
+ //Reset favorites
+ $danceFavorites = [];
+
//Restrict to favorite locations
$locations = $locationFavorites;
//Restrict to favorite locations
$locations = $locationFavorites;
'action' => $this->generateUrl('rapsys_air_application_add'),
//Set the form attribute
'attr' => [ 'class' => 'col' ],
'action' => $this->generateUrl('rapsys_air_application_add'),
//Set the form attribute
'attr' => [ 'class' => 'col' ],
+ //Set dance choices
+ 'dance_choices' => $dances,
+ //Set dance default
+ 'dance_default' => $danceDefault,
+ //Set dance favorites
+ 'dance_favorites' => $danceFavorites,
//Set location choices
'location_choices' => $locations,
//Set location default
//Set location choices
'location_choices' => $locations,
//Set location default