# see https://symfony.com/doc/current/reference/configuration/framework.html | # see https://symfony.com/doc/current/reference/configuration/framework.html | ||||
lc_sov: | lc_sov: | ||||
homepage_route: 'app_homepage' | |||||
homepage_route: 'app_homepage' | |||||
login_redirection: | |||||
redirect_referer: false | |||||
roles_redirection: | |||||
- { role: "ROLE_ADMIN", redirect: "admin_dashboard" } | |||||
- { role: "ROLE_ANIMATOR", redirect: "admin_dashboard_animator" } | |||||
- { role: "ROLE_SUPER_ADMIN", redirect: "admin_dashboard" } |
path: /admin | path: /admin | ||||
controller: App\Controller\Admin\DashboardController::index | controller: App\Controller\Admin\DashboardController::index | ||||
admin_dashboard_animator: | |||||
path: /admin-animator | |||||
controller: App\Controller\Admin\DashboardAnimatorController::index | |||||
app_homepage: | app_homepage: | ||||
path: / | path: / | ||||
controller: App\Controller\Frontend\DefaultController:home | controller: App\Controller\Frontend\DefaultController:home |
<?php | |||||
declare(strict_types=1); | |||||
namespace DoctrineMigrations; | |||||
use Doctrine\DBAL\Schema\Schema; | |||||
use Doctrine\Migrations\AbstractMigration; | |||||
/** | |||||
* Auto-generated Migration: Please modify to your needs! | |||||
*/ | |||||
final class Version20210602130250 extends AbstractMigration | |||||
{ | |||||
public function getDescription(): string | |||||
{ | |||||
return ''; | |||||
} | |||||
public function up(Schema $schema): void | |||||
{ | |||||
// this up() migration is auto-generated, please modify it to your needs | |||||
$this->addSql('ALTER TABLE territory ADD dev_alias VARCHAR(255) DEFAULT NULL'); | |||||
} | |||||
public function down(Schema $schema): void | |||||
{ | |||||
// this down() migration is auto-generated, please modify it to your needs | |||||
$this->addSql('ALTER TABLE territory DROP dev_alias'); | |||||
} | |||||
} |
namespace App\Controller\Admin; | namespace App\Controller\Admin; | ||||
use App\Entity\Configuration; | use App\Entity\Configuration; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||||
use Lc\SovBundle\Controller\Admin\AbstractCrudController; | use Lc\SovBundle\Controller\Admin\AbstractCrudController; | ||||
class ConfigurationCrudController extends AbstractCrudController | class ConfigurationCrudController extends AbstractCrudController | ||||
return Configuration::class; | return Configuration::class; | ||||
} | } | ||||
/* | |||||
public function configureFields(string $pageName): iterable | public function configureFields(string $pageName): iterable | ||||
{ | { | ||||
return [ | return [ | ||||
IdField::new('id'), | |||||
TextField::new('title'), | |||||
TextEditorField::new('description'), | |||||
TextField::new('devAlias'), | |||||
TextField::new('value'), | |||||
]; | ]; | ||||
} | } | ||||
*/ | |||||
} | } |
<?php | |||||
namespace App\Controller\Admin; | |||||
use App\Entity\CollectifData; | |||||
use App\Entity\Common\TaxRate; | |||||
use App\Entity\Configuration; | |||||
use App\Entity\IndividualData; | |||||
use App\Entity\Site\Page; | |||||
use App\Entity\Territory; | |||||
use App\Entity\Thematic; | |||||
use App\Entity\User\GroupUser; | |||||
use App\Entity\User\User; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Assets; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | |||||
use Lc\SovBundle\Controller\Admin\DashboardController as SovDashboardController; | |||||
use Symfony\Component\HttpFoundation\Response; | |||||
class DashboardAnimatorController extends SovDashboardController | |||||
{ | |||||
private $adminUrlGenerator; | |||||
public function __construct(AdminUrlGenerator $adminUrlGenerator) | |||||
{ | |||||
$this->adminUrlGenerator = $adminUrlGenerator; | |||||
} | |||||
public function configureMenuItems(): iterable | |||||
{ | |||||
$urlCreate = $this->adminUrlGenerator | |||||
->setController(CollectifDataCrudController::class) | |||||
->setAction('new') | |||||
->generateUrl(); | |||||
yield MenuItem::linkToDashboard('dashboard', 'circle'); | |||||
yield MenuItem::subMenu('account', 'user') | |||||
->setSubItems( | |||||
[ | |||||
MenuItem::linkToRoute('account_profile', '', 'sov_admin_account_profile'), | |||||
MenuItem::linkToRoute('account_password', '', 'sov_admin_account_password'), | |||||
] | |||||
); | |||||
yield MenuItem::linkToUrl('data_collectif_create', '', $urlCreate); | |||||
} | |||||
} |
namespace App\Controller\Admin; | namespace App\Controller\Admin; | ||||
use App\Entity\CollectifData; | |||||
use App\Entity\Common\TaxRate; | use App\Entity\Common\TaxRate; | ||||
use App\Entity\Configuration; | |||||
use App\Entity\IndividualData; | use App\Entity\IndividualData; | ||||
use App\Entity\Site\Page; | use App\Entity\Site\Page; | ||||
use App\Entity\Territory; | use App\Entity\Territory; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Assets; | use EasyCorp\Bundle\EasyAdminBundle\Config\Assets; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem; | use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | |||||
use Lc\SovBundle\Controller\Admin\DashboardController as SovDashboardController; | use Lc\SovBundle\Controller\Admin\DashboardController as SovDashboardController; | ||||
class DashboardController extends SovDashboardController | class DashboardController extends SovDashboardController | ||||
{ | { | ||||
const ROLE_ADMIN = "ROLE_ADMIN"; | |||||
const ROLE_SUPER_ADMIN = "ROLE_SUPER_ADMIN"; | |||||
private $adminUrlGenerator; | |||||
public function __construct(AdminUrlGenerator $adminUrlGenerator) | |||||
{ | |||||
$this->adminUrlGenerator = $adminUrlGenerator; | |||||
} | |||||
public function configureMenuItems(): iterable | public function configureMenuItems(): iterable | ||||
{ | { | ||||
$urlCreate = $this->adminUrlGenerator | |||||
->setController(CollectifDataCrudController::class) | |||||
->setAction('new') | |||||
->generateUrl(); | |||||
yield MenuItem::linkToDashboard('dashboard', 'circle'); | yield MenuItem::linkToDashboard('dashboard', 'circle'); | ||||
yield MenuItem::linkToCrud('page', 'copy', Page::class); | |||||
yield MenuItem::subMenu('user', 'user')->setSubItems( | |||||
yield MenuItem::subMenu('account', 'user') | |||||
->setSubItems( | |||||
[ | [ | ||||
MenuItem::linkToCrud('user_index', '', User::class), | |||||
MenuItem::linkToRoute('account_profile', '', 'sov_admin_account_profile'), | |||||
MenuItem::linkToRoute('account_password', '', 'sov_admin_account_password'), | |||||
] | ] | ||||
); | |||||
yield MenuItem::subMenu('account', 'user')->setSubItems( | |||||
); | |||||
yield MenuItem::subMenu('user', 'user') | |||||
->setPermission(self::ROLE_ADMIN) | |||||
->setSubItems( | |||||
[ | [ | ||||
MenuItem::linkToRoute('account_profile', '', 'sov_admin_account_profile'), | |||||
MenuItem::linkToRoute('account_password', '', 'sov_admin_account_password'), | |||||
MenuItem::linkToCrud('user_index', '', User::class), | |||||
] | ] | ||||
); | |||||
yield MenuItem::subMenu('data_individual', 'user')->setSubItems( | |||||
); | |||||
yield MenuItem::subMenu('data_individual', 'user') | |||||
->setPermission(self::ROLE_ADMIN) | |||||
->setSubItems( | |||||
[ | [ | ||||
MenuItem::linkToCrud('data_individual_validate', '', IndividualData::class), | |||||
MenuItem::linkToCrud('data_individual_waiting', '', IndividualData::class), | |||||
MenuItem::linkToCrud('data_individual_validate', '', IndividualData::class), | |||||
MenuItem::linkToCrud('data_individual_waiting', '', IndividualData::class), | |||||
] | ] | ||||
); | |||||
yield MenuItem::subMenu('data_collectif', 'user')->setSubItems( | |||||
); | |||||
yield MenuItem::subMenu('data_collectif', 'user') | |||||
->setPermission(self::ROLE_ADMIN) | |||||
->setSubItems( | |||||
[ | [ | ||||
MenuItem::linkToCrud('data_collectif_validate', '', IndividualData::class), | |||||
MenuItem::linkToCrud('data_collectif_waiting', '', IndividualData::class), | |||||
MenuItem::linkToCrud('data_collectif_validate', '', CollectifData::class), | |||||
MenuItem::linkToCrud('data_collectif_waiting', '', CollectifData::class), | |||||
] | ] | ||||
); | |||||
yield MenuItem::linkToCrud('thematic', 'copy', Thematic::class); | |||||
yield MenuItem::linkToCrud('territory', 'copy', Territory::class); | |||||
); | |||||
yield MenuItem::linkToCrud('thematic', 'copy', Thematic::class) | |||||
->setPermission(self::ROLE_ADMIN); | |||||
yield MenuItem::linkToCrud('territory', 'copy', Territory::class) | |||||
->setPermission(self::ROLE_SUPER_ADMIN); | |||||
yield MenuItem::linkToCrud('configuration', 'copy', Configuration::class) | |||||
->setPermission(self::ROLE_SUPER_ADMIN); | |||||
yield MenuItem::linkToCrud('page', 'copy', Page::class) | |||||
->setPermission(self::ROLE_ADMIN); | |||||
} | } | ||||
} | } |
namespace App\Controller\Admin; | namespace App\Controller\Admin; | ||||
use App\Entity\Configuration; | |||||
use App\Entity\IndividualData; | use App\Entity\IndividualData; | ||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; | use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\EmailField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||||
use Lc\SovBundle\Field\BooleanField; | |||||
class IndividualDataCrudController extends AbstractCrudController | class IndividualDataCrudController extends AbstractCrudController | ||||
{ | { | ||||
return IndividualData::class; | return IndividualData::class; | ||||
} | } | ||||
/* | |||||
public function configureFields(string $pageName): iterable | public function configureFields(string $pageName): iterable | ||||
{ | { | ||||
return [ | return [ | ||||
IdField::new('id'), | |||||
TextField::new('title'), | |||||
TextEditorField::new('description'), | |||||
TextField::new('firstname'), | |||||
TextField::new('lastname'), | |||||
EmailField::new('email'), | |||||
TextField::new('introAnswer'), | |||||
BooleanField::new('status')->setRequired(false) | |||||
]; | ]; | ||||
} | } | ||||
*/ | |||||
public function persistEntity(EntityManagerInterface $entityManager, $entityInstance): void | |||||
{ | |||||
$configurationRepository = $this->getDoctrine()->getRepository(Configuration::class); | |||||
$configuration = $configurationRepository->findOneByDevAlias('intro_question'); | |||||
$entityInstance->setIntroQuestion($configuration->getValue()); | |||||
$entityManager->persist($entityInstance); | |||||
$entityManager->flush(); | |||||
parent::persistEntity($entityManager, $entityInstance); // TODO: Change the autogenerated stub | |||||
} | |||||
} | } |
namespace App\Controller\Admin; | namespace App\Controller\Admin; | ||||
use App\Entity\Territory; | use App\Entity\Territory; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||||
use Lc\SovBundle\Controller\Admin\AbstractCrudController; | use Lc\SovBundle\Controller\Admin\AbstractCrudController; | ||||
class TerritoryCrudController extends AbstractCrudController | class TerritoryCrudController extends AbstractCrudController | ||||
return Territory::class; | return Territory::class; | ||||
} | } | ||||
/* | |||||
public function configureFields(string $pageName): iterable | public function configureFields(string $pageName): iterable | ||||
{ | { | ||||
return [ | return [ | ||||
IdField::new('id'), | |||||
TextField::new('title'), | |||||
TextEditorField::new('description'), | |||||
TextField::new('devAlias'), | |||||
TextField::new('name'), | |||||
]; | ]; | ||||
} | } | ||||
*/ | |||||
} | } |
return Thematic::class; | return Thematic::class; | ||||
} | } | ||||
public function configureFields(string $pageName): iterable | public function configureFields(string $pageName): iterable | ||||
{ | { | ||||
return [ | return [ |
namespace App\Controller\Admin; | namespace App\Controller\Admin; | ||||
use App\Entity\User\User; | use App\Entity\User\User; | ||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\ArrayField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\EmailField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||||
use Lc\SovBundle\Controller\Admin\UserCrudController as AbstractUserCrudController; | use Lc\SovBundle\Controller\Admin\UserCrudController as AbstractUserCrudController; | ||||
use Lc\SovBundle\Doctrine\EntityManager; | |||||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||||
use Symfony\Component\HttpFoundation\RequestStack; | |||||
use Symfony\Component\HttpFoundation\Session\SessionInterface; | |||||
use Symfony\Component\Mailer\MailerInterface; | |||||
use Symfony\Component\Mime\Email; | |||||
use Symfony\Component\Mime\Message; | |||||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; | |||||
use Twig\Environment; | |||||
class UserCrudController extends AbstractUserCrudController | class UserCrudController extends AbstractUserCrudController | ||||
{ | { | ||||
public static function getEntityFqcn(): string | |||||
{ | |||||
return User::class; | |||||
protected $passwordEncoder; | |||||
protected $entityManager; | |||||
protected $mailerInterface; | |||||
public function __construct( | |||||
SessionInterface $session, | |||||
RequestStack $request, | |||||
EntityManager $em, | |||||
TranslatorAdmin $translatorAdmin, | |||||
Environment $twig, | |||||
UserPasswordEncoderInterface $passwordEncoder, | |||||
EntityManager $entityManager, | |||||
MailerInterface $mailerInterface | |||||
) | |||||
{ | |||||
$this->passwordEncoder = $passwordEncoder; | |||||
$this->entityManager = $entityManager; | |||||
$this->mailerInterface = $mailerInterface; | |||||
parent::__construct($session, $request, $em, $translatorAdmin ,$twig); | |||||
} | |||||
public static function getEntityFqcn(): string | |||||
{ | |||||
return User::class; | |||||
} | |||||
public function configureFields(string $pageName): iterable | |||||
{ | |||||
return [ | |||||
TextField::new('firstname'), | |||||
TextField::new('lastname'), | |||||
EmailField::new('email'), | |||||
ArrayField::new('roles'), | |||||
ChoiceField::new('roles') | |||||
->allowMultipleChoices() | |||||
->autocomplete() | |||||
->setChoices(["Utilisateur" => "ROLE_USER", "Animateur" => "ROLE_ANIMATOR", "Admin" => "ROLE_ADMIN"]), | |||||
]; | |||||
} | |||||
public function persistEntity(EntityManagerInterface $entityManager, $entityInstance): void | |||||
{ | |||||
// @TODO : gérer avec UserManager | |||||
$plainPassword = $this->generatePassword(12, 'azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN123456789#!?+=-/%'); | |||||
$newPasswordEncoded = $this->passwordEncoder->encodePassword($entityInstance, $plainPassword); | |||||
$entityInstance->setPassword($newPasswordEncoded); | |||||
$this->entityManager->create($entityInstance); | |||||
$this->entityManager->flush(); | |||||
$email = (new Email()) | |||||
->from('contact@laclic.fr') | |||||
->to('charly@laclic.fr') | |||||
->subject('Password') | |||||
->html($plainPassword); | |||||
$this->mailerInterface->send($email); | |||||
parent::persistEntity($entityManager, $entityInstance); // TODO: Change the autogenerated stub | |||||
} | |||||
function generatePassword($caracteres = 12, $chaine = 'azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN123456789#!?+=-/%') | |||||
{ | |||||
$nb_lettres = strlen($chaine) - 1; | |||||
$generation = ''; | |||||
for ($i = 0; $i < $caracteres; $i++) { | |||||
$pos = mt_rand(0, $nb_lettres); | |||||
$car = $chaine[$pos]; | |||||
$generation .= $car; | |||||
} | } | ||||
return $generation; | |||||
} | |||||
} | } |
$this->projectsInspiring = new ArrayCollection(); | $this->projectsInspiring = new ArrayCollection(); | ||||
} | } | ||||
public function __toString() | |||||
{ | |||||
return $this->nbParticipant; | |||||
} | |||||
public function getId(): ?int | public function getId(): ?int | ||||
{ | { | ||||
return $this->id; | return $this->id; |
*/ | */ | ||||
private $value; | private $value; | ||||
public function __toString() | |||||
{ | |||||
return $this->value; | |||||
} | |||||
public function getId(): ?int | public function getId(): ?int | ||||
{ | { | ||||
return $this->id; | return $this->id; |
$this->territory = new ArrayCollection(); | $this->territory = new ArrayCollection(); | ||||
} | } | ||||
public function __toString() | |||||
{ | |||||
return $this->firstname . " " . $this->lastname; | |||||
} | |||||
public function getId(): ?int | public function getId(): ?int | ||||
{ | { | ||||
return $this->id; | return $this->id; |
use Doctrine\Common\Collections\Collection; | use Doctrine\Common\Collections\Collection; | ||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\SovBundle\Doctrine\EntityInterface; | use Lc\SovBundle\Doctrine\EntityInterface; | ||||
use Lc\SovBundle\Doctrine\Extension\DevAliasInterface; | |||||
use Lc\SovBundle\Doctrine\Extension\DevAliasTrait; | |||||
/** | /** | ||||
* @ORM\Entity(repositoryClass=TerritoryRepository::class) | * @ORM\Entity(repositoryClass=TerritoryRepository::class) | ||||
*/ | */ | ||||
class Territory implements EntityInterface | |||||
class Territory implements EntityInterface, DevAliasInterface | |||||
{ | { | ||||
use DevAliasTrait; | |||||
/** | /** | ||||
* @ORM\Id | * @ORM\Id | ||||
* @ORM\GeneratedValue | * @ORM\GeneratedValue | ||||
$this->collectifData = new ArrayCollection(); | $this->collectifData = new ArrayCollection(); | ||||
} | } | ||||
public function __toString() | |||||
{ | |||||
return $this->name; | |||||
} | |||||
public function getId(): ?int | public function getId(): ?int | ||||
{ | { | ||||
return $this->id; | return $this->id; |
*/ | */ | ||||
class User extends SovUserModel implements UserInterface | class User extends SovUserModel implements UserInterface | ||||
{ | { | ||||
/** | |||||
* @ORM\Id | |||||
* @ORM\GeneratedValue | |||||
* @ORM\Column(type="integer") | |||||
*/ | |||||
private $id; | |||||
/** | |||||
* @ORM\Id | |||||
* @ORM\GeneratedValue | |||||
* @ORM\Column(type="integer") | |||||
*/ | |||||
private $id; | |||||
/** | |||||
* @ORM\OneToMany(targetEntity=CollectifData::class, mappedBy="user") | |||||
*/ | |||||
private $collectifData; | |||||
/** | |||||
* @ORM\OneToMany(targetEntity=CollectifData::class, mappedBy="user") | |||||
*/ | |||||
private $collectifData; | |||||
public function __construct() | |||||
{ | |||||
$this->collectifData = new ArrayCollection(); | |||||
} | |||||
public function __construct() | |||||
{ | |||||
$this->collectifData = new ArrayCollection(); | |||||
} | |||||
public function getId(): ?int | |||||
{ | |||||
return $this->id; | |||||
} | |||||
public function __toString() | |||||
{ | |||||
return $this->firstname . " " . $this->lastname; | |||||
} | |||||
/** | |||||
* @return Collection|CollectifData[] | |||||
*/ | |||||
public function getCollectifData(): Collection | |||||
{ | |||||
return $this->collectifData; | |||||
} | |||||
public function getId(): ?int | |||||
{ | |||||
return $this->id; | |||||
} | |||||
public function addCollectifData(CollectifData $collectifData): self | |||||
{ | |||||
if (!$this->collectifData->contains($collectifData)) { | |||||
$this->collectifData[] = $collectifData; | |||||
$collectifData->setUser($this); | |||||
} | |||||
/** | |||||
* @return Collection|CollectifData[] | |||||
*/ | |||||
public function getCollectifData(): Collection | |||||
{ | |||||
return $this->collectifData; | |||||
} | |||||
return $this; | |||||
public function addCollectifData(CollectifData $collectifData): self | |||||
{ | |||||
if (!$this->collectifData->contains($collectifData)) { | |||||
$this->collectifData[] = $collectifData; | |||||
$collectifData->setUser($this); | |||||
} | } | ||||
public function removeCollectifData(CollectifData $collectifData): self | |||||
{ | |||||
if ($this->collectifData->removeElement($collectifData)) { | |||||
// set the owning side to null (unless already changed) | |||||
if ($collectifData->getUser() === $this) { | |||||
$collectifData->setUser(null); | |||||
} | |||||
} | |||||
return $this; | |||||
} | |||||
return $this; | |||||
public function removeCollectifData(CollectifData $collectifData): self | |||||
{ | |||||
if ($this->collectifData->removeElement($collectifData)) { | |||||
// set the owning side to null (unless already changed) | |||||
if ($collectifData->getUser() === $this) { | |||||
$collectifData->setUser(null); | |||||
} | |||||
} | } | ||||
return $this; | |||||
} | |||||
} | } |
data_collectif: Formulaire collectif | data_collectif: Formulaire collectif | ||||
data_collectif_validate: Données validées | data_collectif_validate: Données validées | ||||
data_collectif_waiting: Données en attente de validation | data_collectif_waiting: Données en attente de validation | ||||
data_collectif_create: Formulaire collectif | |||||
territory: Territoires | territory: Territoires | ||||
thematic: Thématiques | thematic: Thématiques | ||||
configuration: Configuration question Intro |