Browse Source

transfo en bundle; répo; model; controller; form

develop
charly 3 years ago
parent
commit
a7086dc30a
47 changed files with 77 additions and 1463 deletions
  1. +3
    -3
      src/Controller/Admin/DashboardController.php
  2. +15
    -0
      src/Controller/Admin/IndividualData/IndividualDataAdminController.php
  3. +0
    -219
      src/Controller/Admin/IndividualDataCrudController.php
  4. +14
    -0
      src/Controller/Admin/Subthematic/ThematicAdminController.php
  5. +0
    -26
      src/Controller/Admin/SubthematicCrudController.php
  6. +14
    -0
      src/Controller/Admin/Territory/TerritoryAdminController.php
  7. +0
    -23
      src/Controller/Admin/TerritoryCrudController.php
  8. +14
    -0
      src/Controller/Admin/Thematic/ThematicAdminController.php
  9. +0
    -23
      src/Controller/Admin/ThematicCrudController.php
  10. +7
    -7
      src/Controller/Frontend/CartoController.php
  11. +0
    -48
      src/Entity/AbstractData.php
  12. +2
    -1
      src/Entity/CollectifData.php
  13. +1
    -1
      src/Entity/Dream.php
  14. +1
    -1
      src/Entity/IndividualData.php
  15. +1
    -1
      src/Entity/ProjectBoost.php
  16. +1
    -1
      src/Entity/ProjectInspiring.php
  17. +1
    -1
      src/Entity/Revolt.php
  18. +1
    -1
      src/Entity/Subthematic.php
  19. +1
    -1
      src/Entity/Territory.php
  20. +1
    -1
      src/Entity/Thematic.php
  21. +0
    -29
      src/Repository/ConfigurationRepository.php
  22. +0
    -21
      src/Repository/DreamRepository.php
  23. +0
    -13
      src/Repository/DreamRepositoryQuery.php
  24. +0
    -14
      src/Repository/DreamStore.php
  25. +0
    -50
      src/Repository/IndividualDataRepository.php
  26. +0
    -50
      src/Repository/ProjectBoostRepository.php
  27. +0
    -13
      src/Repository/ProjectBoostRepositoryQuery.php
  28. +0
    -14
      src/Repository/ProjectBoostStore.php
  29. +0
    -50
      src/Repository/ProjectInspiringRepository.php
  30. +0
    -13
      src/Repository/ProjectInspiringRepositoryQuery.php
  31. +0
    -14
      src/Repository/ProjectInspiringStore.php
  32. +0
    -21
      src/Repository/RevoltRepository.php
  33. +0
    -13
      src/Repository/RevoltRepositoryQuery.php
  34. +0
    -14
      src/Repository/RevoltStore.php
  35. +0
    -96
      src/Repository/SearchRepositoryQuery.php
  36. +0
    -66
      src/Repository/SearchStore.php
  37. +0
    -50
      src/Repository/SubthematicRepository.php
  38. +0
    -50
      src/Repository/TerritoryRepository.php
  39. +0
    -15
      src/Repository/TerritoryRepositoryQuery.php
  40. +0
    -34
      src/Repository/TerritoryStore.php
  41. +0
    -50
      src/Repository/ThematicRepository.php
  42. +0
    -15
      src/Repository/ThematicRepositoryQuery.php
  43. +0
    -34
      src/Repository/ThematicStore.php
  44. +0
    -91
      src/Type/DreamType.php
  45. +0
    -92
      src/Type/ProjectBoostType.php
  46. +0
    -91
      src/Type/ProjectInspiringType.php
  47. +0
    -92
      src/Type/RevoltType.php

+ 3
- 3
src/Controller/Admin/DashboardController.php View File

@@ -108,7 +108,7 @@ class DashboardController extends SovDashboardController

$urlNewIndividuel = $this->adminUrlGenerator
->unsetAll()
->setController(IndividualDataCrudController::class)
->setController(IndividualDataAdminController::class)
->setAction(Action::NEW)
->set('menuIndex', 3)
->set('submenuIndex', 0)
@@ -116,7 +116,7 @@ class DashboardController extends SovDashboardController

$urlOfflineIndividuel = $this->adminUrlGenerator
->unsetAll()
->setController(IndividualDataCrudController::class)
->setController(IndividualDataAdminController::class)
->setAction(Action::INDEX)
->set('status', 0)
->set('menuIndex', 3)
@@ -125,7 +125,7 @@ class DashboardController extends SovDashboardController

$urlOnlineIndividuel = $this->adminUrlGenerator
->unsetAll()
->setController(IndividualDataCrudController::class)
->setController(IndividualDataAdminController::class)
->setAction(Action::INDEX)
->set('status', 1)
->set('menuIndex', 3)

+ 15
- 0
src/Controller/Admin/IndividualData/IndividualDataAdminController.php View File

@@ -0,0 +1,15 @@
<?php

namespace App\Controller\Admin\IndividualData;

use Lc\PietroBundle\Model\IndividualData;
use Lc\PietroBundle\Controller\IndividualData\IndividualDataAdminController as PietroIndividualDataAdminController;

class IndividualDataAdminController extends PietroIndividualDataAdminController
{
public static function getEntityFqcn(): string
{
return IndividualData::class;
}

}

+ 0
- 219
src/Controller/Admin/IndividualDataCrudController.php View File

@@ -1,219 +0,0 @@
<?php

namespace App\Controller\Admin;

use App\Entity\Configuration;
use App\Entity\IndividualData;
use App\Repository\DreamStore;
use App\Repository\ProjectBoostStore;
use App\Repository\ProjectInspiringStore;
use App\Repository\RevoltStore;
use App\Type\DreamType;
use App\Type\ProjectBoostType;
use App\Type\ProjectInspiringType;
use App\Type\RevoltType;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\QueryBuilder;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection;
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\HiddenField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use Symfony\Component\HttpFoundation\Request;
use Lc\SovBundle\Controller\AbstractAdminController as AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\EmailField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Field\CollectionField;
use Lc\SovBundle\Field\StatusField;
use Lc\SovBundle\Generator\CsvGenerator;

class IndividualDataCrudController extends AbstractCrudController
{
protected DreamStore $dreamStore;
protected RevoltStore $revoltStore;
protected ProjectBoostStore $projectBoostStore;
protected ProjectInspiringStore $projectInspiringStore;

public function __construct(
DreamStore $dreamStore,
RevoltStore $revoltStore,
ProjectBoostStore $projectBoostStore,
ProjectInspiringStore $projectInspiringStore
) {
$this->dreamStore = $dreamStore;
$this->revoltStore = $revoltStore;
$this->projectBoostStore = $projectBoostStore;
$this->projectInspiringStore = $projectInspiringStore;
}

public static function getEntityFqcn(): string
{
return IndividualData::class;
}

public function configureFields(string $pageName): iterable
{
// TextField::new('firstname'),
// TextField::new('lastname'),
// EmailField::new('email'),
// TextField::new('introAnswer'),
$fields = array();

$fields[] = AssociationField::new('territory')
->setTemplatePath('crud/field/association.html.twig');
$fields[] = TextField::new('nbDream')
->onlyOnIndex();
$fields[] = TextField::new('nbRevolt')
->onlyOnIndex();
$fields[] = TextField::new('nbProjectBoost')
->onlyOnIndex();
$fields[] = TextField::new('nbProjectInspiring')
->onlyOnIndex();
$fields[] = CollectionField::new('revolt')
->setFormTypeOption('entry_type', RevoltType::class)
->setFormTypeOption('by_reference', false)
->setRequired(false)
->hideOnIndex();
$fields[] = CollectionField::new('dream')
->setFormTypeOption('entry_type', DreamType::class)
->setFormTypeOption('by_reference', false)
->setRequired(false)
->hideOnIndex();
$fields[] = CollectionField::new('projectBoost')
->setFormTypeOption('entry_type', ProjectBoostType::class)
->setFormTypeOption('by_reference', false)
->setRequired(false)
->hideOnIndex();
$fields[] = CollectionField::new('projectinspiring')
->setFormTypeOption('entry_type', ProjectInspiringType::class)
->setFormTypeOption('by_reference', false)
->setRequired(false)
->hideOnIndex();
$hasAccess = $this->isGranted('ROLE_ADMIN');
if ($hasAccess) {
$fields[] = StatusField::new('status')
->setFormTypeOption('data', 0)
->setFormTypeOption('choices', ['Validé' => 1, 'En attente' => 0])
->setCustomOption('toggle_label', 'Valider')
->hideOnIndex();
} else {
$fields[] = HiddenField::new('status')
->setFormTypeOption('data', 0)
->hideOnIndex();
}


return $fields;
}

// 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);
// }

public function createIndexQueryBuilder(
SearchDto $searchDto,
EntityDto $entityDto,
FieldCollection $fields,
FilterCollection $filters
): QueryBuilder {
$queryBuilder = parent::createIndexQueryBuilder(
$searchDto,
$entityDto,
$fields,
$filters
);

$queryBuilder->andWhere('entity.status = ' . $searchDto->getRequest()->get('status'));

return $queryBuilder;
}

public function configureActions(Actions $actions): Actions
{
parent::configureActions($actions);

$export = Action::new('export', 'actions.export')
->setIcon('fa fa-download')
->linkToCrudAction('exportCsv')
->setCssClass('btn btn-primary')
->createAsGlobalAction();

return $actions->add(Crud::PAGE_INDEX, $export);
}

public function exportCsv(Request $request)
{
$csv = new CsvGenerator();
$csv->enableConvertEncoding('ISO-8859-1');
$csv->setTitle('Export_Liste', true);

$columns = [
'category' => 'Catégorie',
'thematic' => 'Thématique',
'subthematic' => 'Contribution',
'territory' => 'Lieu',
'description' => 'Description'
];
$csv->setColumns($columns);

$resultArray = $this->generateAllResultArray();

$csv = $this->generateCsvData($csv, $resultArray);

return $csv->getReponse();
}

private function generateAllResultArray(): array
{
$dreamArray = $this->dreamStore->get();
$revoltArray = $this->revoltStore->get();
$projectBoostArray = $this->projectBoostStore->get();
$projectInspiringArray = $this->projectInspiringStore->get();

return array_merge($dreamArray, $revoltArray, $projectBoostArray, $projectInspiringArray);
}

private function generateCsvData($csv, $resultArray)
{
foreach ($resultArray as $result) {
$territory = $subthematic = $thematic = "";
if ($result->getIndividualData()) {
$territory = $result->getIndividualData()->getTerritory()->getName();


if ($result->getSubthematic()) {
$subthematic = $result->getSubthematic()->getName();
}

if ($result->getThematic()) {
$thematic = $result->getThematic()->getName();
}

$data = [
'category' => $result->__toString(),
'thematic' => $thematic,
'subthematic' => $subthematic,
'territory' => $territory,
'description' => $result->getDescription()
];

$csv->row($data);
}
}

return $csv;
}
}

+ 14
- 0
src/Controller/Admin/Subthematic/ThematicAdminController.php View File

@@ -0,0 +1,14 @@
<?php

namespace App\Controller\Admin\Subthematic;

use App\Entity\Subthematic;
use Lc\PietroBundle\Controller\Subthematic\SubthematicAdminController as PietroSubthematicAdminController;

class ThematicAdminController extends PietroSubthematicAdminController
{
public static function getEntityFqcn(): string
{
return Subthematic::class;
}
}

+ 0
- 26
src/Controller/Admin/SubthematicCrudController.php View File

@@ -1,26 +0,0 @@
<?php

namespace App\Controller\Admin;

use App\Entity\Subthematic;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Controller\AbstractAdminController as AbstractCrudController;

class SubthematicCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return Subthematic::class;
}

public function configureFields(string $pageName): iterable
{
return [
TextField::new('name'),
AssociationField::new('thematic')
->setTemplatePath('crud/field/association.html.twig')
];
}

}

+ 14
- 0
src/Controller/Admin/Territory/TerritoryAdminController.php View File

@@ -0,0 +1,14 @@
<?php

namespace App\Controller\Admin\Territory;

use App\Entity\Territory;
use Lc\PietroBundle\Controller\Territory\TerritoryAdminController as PietroTerritoryAdminController;

class TerritoryAdminController extends PietroTerritoryAdminController
{
public static function getEntityFqcn(): string
{
return Territory::class;
}
}

+ 0
- 23
src/Controller/Admin/TerritoryCrudController.php View File

@@ -1,23 +0,0 @@
<?php

namespace App\Controller\Admin;

use App\Entity\Territory;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Controller\AbstractAdminController as AbstractCrudController;

class TerritoryCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return Territory::class;
}

public function configureFields(string $pageName): iterable
{
return [
TextField::new('devAlias'),
TextField::new('name'),
];
}
}

+ 14
- 0
src/Controller/Admin/Thematic/ThematicAdminController.php View File

@@ -0,0 +1,14 @@
<?php

namespace App\Controller\Admin\Thematic;

use App\Entity\Thematic;
use Lc\PietroBundle\Controller\Thematic\ThematicAdminController as PietroThematicAdminController;

class ThematicAdminController extends PietroThematicAdminController
{
public static function getEntityFqcn(): string
{
return Thematic::class;
}
}

+ 0
- 23
src/Controller/Admin/ThematicCrudController.php View File

@@ -1,23 +0,0 @@
<?php

namespace App\Controller\Admin;

use App\Entity\Thematic;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Controller\AbstractAdminController as AbstractCrudController;

class ThematicCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return Thematic::class;
}

public function configureFields(string $pageName): iterable
{
return [
TextField::new('name')
];
}

}

+ 7
- 7
src/Controller/Frontend/CartoController.php View File

@@ -2,20 +2,20 @@

namespace App\Controller\Frontend;

use App\Entity\AbstractData;
use App\Form\SearchListForm;
use App\Repository\BlockStore;
use App\Repository\DreamStore;
use App\Repository\ProjectBoostStore;
use App\Repository\ProjectInspiringStore;
use App\Repository\RevoltStore;
use App\Repository\TerritoryStore;
use App\Repository\ThematicStore;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityManagerInterface;
use Dompdf\Dompdf;
use Dompdf\Options;
use Knp\Component\Pager\PaginatorInterface;
use Lc\PietroBundle\Model\AbstractData;
use Lc\PietroBundle\Repository\Dream\DreamStore;
use Lc\PietroBundle\Repository\ProjectBoost\ProjectBoostStore;
use Lc\PietroBundle\Repository\ProjectInspiring\ProjectInspiringStore;
use Lc\PietroBundle\Repository\Revolt\RevoltStore;
use Lc\PietroBundle\Repository\Territory\TerritoryStore;
use Lc\PietroBundle\Repository\Thematic\ThematicStore;
use Lc\SovBundle\Generator\CsvGenerator;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\JsonResponse;

+ 0
- 48
src/Entity/AbstractData.php View File

@@ -1,48 +0,0 @@
<?php

namespace App\Entity;

use App\Entity\User\User;
use App\Repository\AbstractDataRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Lc\SovBundle\Doctrine\EntityInterface;
use Lc\SovBundle\Doctrine\Extension\StatusInterface;
use Lc\SovBundle\Doctrine\Extension\StatusTrait;

/**
* @ORM\MappedSuperclass()
*/
abstract class AbstractData implements StatusInterface, EntityInterface
{
use StatusTrait;

const TERRITORY = "Territory";
const CATEGORY_REVOLT = "Revolt";
const CATEGORY_DREAM = "Dream";
const CATEGORY_PROJECTBOOST = "ProjectBoost";
const CATEGORY_PROJECTINSPIRING = "ProjectInspiring";

const CATEGORY_LABEL_REVOLT = "Nos révoltes";
const CATEGORY_LABEL_DREAM = "Nos rêves";
const CATEGORY_LABEL_PROJECTBOOST = "Les actions à booster";
const CATEGORY_LABEL_PROJECTINSPIRING = "Les actions inspirantes";

static function getCategory(): array
{
return [
self::CATEGORY_LABEL_REVOLT => self::CATEGORY_REVOLT,
self::CATEGORY_LABEL_DREAM => self::CATEGORY_DREAM,
self::CATEGORY_LABEL_PROJECTBOOST => self::CATEGORY_PROJECTBOOST,
self::CATEGORY_LABEL_PROJECTINSPIRING => self::CATEGORY_PROJECTINSPIRING,
];
}

static function getCategoryByLabel(string $label): string
{
$categoryArray = self::getCategory();

return $categoryArray[$label];
}
}

+ 2
- 1
src/Entity/CollectifData.php View File

@@ -10,11 +10,12 @@ use Doctrine\ORM\Mapping as ORM;
use Lc\SovBundle\Doctrine\EntityInterface;
use Lc\SovBundle\Doctrine\Extension\StatusInterface;
use Lc\SovBundle\Doctrine\Extension\StatusTrait;
use Lc\PietroBundle\Model\AbstractData as PietroAbstractData;

/**
* @ORM\Entity(repositoryClass=CollectifDataRepository::class)
*/
class CollectifData extends AbstractData
class CollectifData extends PietroAbstractData
{
/**
* @ORM\Id

+ 1
- 1
src/Entity/Dream.php View File

@@ -2,7 +2,7 @@

namespace App\Entity;

use App\Repository\DreamRepository;
use Lc\PietroBundle\Repository\Dream\DreamRepository;
use Doctrine\ORM\Mapping as ORM;
use Lc\PietroBundle\Model\Dream as PietroDream;


+ 1
- 1
src/Entity/IndividualData.php View File

@@ -2,7 +2,7 @@

namespace App\Entity;

use App\Repository\IndividualDataRepository;
use Lc\PietroBundle\Repository\IndividualData\IndividualDataRepository;
use Doctrine\ORM\Mapping as ORM;
use Lc\PietroBundle\Model\IndividualData as PietroIndividualData;


+ 1
- 1
src/Entity/ProjectBoost.php View File

@@ -2,7 +2,7 @@

namespace App\Entity;

use App\Repository\ProjectBoostRepository;
use Lc\PietroBundle\Repository\ProjectBoost\ProjectBoostRepository;
use Doctrine\ORM\Mapping as ORM;
use Lc\PietroBundle\Model\ProjectBoost as PietroProjectBoost;


+ 1
- 1
src/Entity/ProjectInspiring.php View File

@@ -2,7 +2,7 @@

namespace App\Entity;

use App\Repository\ProjectInspiringRepository;
use Lc\PietroBundle\Repository\ProjectInspiring\ProjectInspiringRepository;
use Doctrine\ORM\Mapping as ORM;
use Lc\PietroBundle\Model\ProjectInspiring as PietroProjectInspiring;


+ 1
- 1
src/Entity/Revolt.php View File

@@ -2,7 +2,7 @@

namespace App\Entity;

use App\Repository\RevoltRepository;
use Lc\PietroBundle\Repository\Revolt\RevoltRepository;
use Doctrine\ORM\Mapping as ORM;
use Lc\PietroBundle\Model\Revolt as PietroRevolt;


+ 1
- 1
src/Entity/Subthematic.php View File

@@ -2,7 +2,7 @@

namespace App\Entity;

use App\Repository\SubthematicRepository;
use Lc\PietroBundle\Repository\Subthematic\SubthematicRepository;
use Doctrine\ORM\Mapping as ORM;
use Lc\PietroBundle\Model\Subthematic as PietroSubthematic;


+ 1
- 1
src/Entity/Territory.php View File

@@ -2,7 +2,7 @@

namespace App\Entity;

use App\Repository\TerritoryRepository;
use Lc\PietroBundle\Repository\Territory\TerritoryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

+ 1
- 1
src/Entity/Thematic.php View File

@@ -2,7 +2,7 @@

namespace App\Entity;

use App\Repository\ThematicRepository;
use Lc\PietroBundle\Repository\Thematic\ThematicRepository;
use Doctrine\ORM\Mapping as ORM;
use Lc\PietroBundle\Model\Thematic as PietroThematic;


+ 0
- 29
src/Repository/ConfigurationRepository.php View File

@@ -18,33 +18,4 @@ class ConfigurationRepository extends ServiceEntityRepository
{
parent::__construct($registry, Configuration::class);
}

// /**
// * @return Configuration[] Returns an array of Configuration objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('c')
->andWhere('c.exampleField = :val')
->setParameter('val', $value)
->orderBy('c.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/

/*
public function findOneBySomeField($value): ?Configuration
{
return $this->createQueryBuilder('c')
->andWhere('c.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}

+ 0
- 21
src/Repository/DreamRepository.php View File

@@ -1,21 +0,0 @@
<?php

namespace App\Repository;

use App\Entity\Dream;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
* @method Dream|null find($id, $lockMode = null, $lockVersion = null)
* @method Dream|null findOneBy(array $criteria, array $orderBy = null)
* @method Dream[] findAll()
* @method Dream[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class DreamRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Dream::class);
}
}

+ 0
- 13
src/Repository/DreamRepositoryQuery.php View File

@@ -1,13 +0,0 @@
<?php

namespace App\Repository;

use Knp\Component\Pager\PaginatorInterface;

class DreamRepositoryQuery extends SearchRepositoryQuery
{
public function __construct(DreamRepository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, $paginator);
}
}

+ 0
- 14
src/Repository/DreamStore.php View File

@@ -1,14 +0,0 @@
<?php

namespace App\Repository;


class DreamStore extends SearchStore
{
protected $query;

public function __construct(DreamRepositoryQuery $query)
{
$this->query = $query;
}
}

+ 0
- 50
src/Repository/IndividualDataRepository.php View File

@@ -1,50 +0,0 @@
<?php

namespace App\Repository;

use App\Entity\IndividualData;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
* @method IndividualData|null find($id, $lockMode = null, $lockVersion = null)
* @method IndividualData|null findOneBy(array $criteria, array $orderBy = null)
* @method IndividualData[] findAll()
* @method IndividualData[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class IndividualDataRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, IndividualData::class);
}

// /**
// * @return IndividualData[] Returns an array of IndividualData objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('i')
->andWhere('i.exampleField = :val')
->setParameter('val', $value)
->orderBy('i.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/

/*
public function findOneBySomeField($value): ?IndividualData
{
return $this->createQueryBuilder('i')
->andWhere('i.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}

+ 0
- 50
src/Repository/ProjectBoostRepository.php View File

@@ -1,50 +0,0 @@
<?php

namespace App\Repository;

use App\Entity\ProjectBoost;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
* @method ProjectBoost|null find($id, $lockMode = null, $lockVersion = null)
* @method ProjectBoost|null findOneBy(array $criteria, array $orderBy = null)
* @method ProjectBoost[] findAll()
* @method ProjectBoost[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ProjectBoostRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, ProjectBoost::class);
}

// /**
// * @return ProjectBoost[] Returns an array of ProjectBoost objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('p')
->andWhere('p.exampleField = :val')
->setParameter('val', $value)
->orderBy('p.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/

/*
public function findOneBySomeField($value): ?ProjectBoost
{
return $this->createQueryBuilder('p')
->andWhere('p.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}

+ 0
- 13
src/Repository/ProjectBoostRepositoryQuery.php View File

@@ -1,13 +0,0 @@
<?php

namespace App\Repository;

use Knp\Component\Pager\PaginatorInterface;

class ProjectBoostRepositoryQuery extends SearchRepositoryQuery
{
public function __construct(ProjectBoostRepository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, $paginator);
}
}

+ 0
- 14
src/Repository/ProjectBoostStore.php View File

@@ -1,14 +0,0 @@
<?php

namespace App\Repository;


class ProjectBoostStore extends SearchStore
{
protected $query;

public function __construct(ProjectBoostRepositoryQuery $query)
{
$this->query = $query;
}
}

+ 0
- 50
src/Repository/ProjectInspiringRepository.php View File

@@ -1,50 +0,0 @@
<?php

namespace App\Repository;

use App\Entity\ProjectInspiring;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
* @method ProjectInspiring|null find($id, $lockMode = null, $lockVersion = null)
* @method ProjectInspiring|null findOneBy(array $criteria, array $orderBy = null)
* @method ProjectInspiring[] findAll()
* @method ProjectInspiring[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ProjectInspiringRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, ProjectInspiring::class);
}

// /**
// * @return ProjectInspiring[] Returns an array of ProjectInspiring objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('p')
->andWhere('p.exampleField = :val')
->setParameter('val', $value)
->orderBy('p.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/

/*
public function findOneBySomeField($value): ?ProjectInspiring
{
return $this->createQueryBuilder('p')
->andWhere('p.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}

+ 0
- 13
src/Repository/ProjectInspiringRepositoryQuery.php View File

@@ -1,13 +0,0 @@
<?php

namespace App\Repository;

use Knp\Component\Pager\PaginatorInterface;

class ProjectInspiringRepositoryQuery extends SearchRepositoryQuery
{
public function __construct(ProjectInspiringRepository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, $paginator);
}
}

+ 0
- 14
src/Repository/ProjectInspiringStore.php View File

@@ -1,14 +0,0 @@
<?php

namespace App\Repository;


class ProjectInspiringStore extends SearchStore
{
protected $query;

public function __construct(ProjectInspiringRepositoryQuery $query)
{
$this->query = $query;
}
}

+ 0
- 21
src/Repository/RevoltRepository.php View File

@@ -1,21 +0,0 @@
<?php

namespace App\Repository;

use App\Entity\Revolt;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
* @method Revolt|null find($id, $lockMode = null, $lockVersion = null)
* @method Revolt|null findOneBy(array $criteria, array $orderBy = null)
* @method Revolt[] findAll()
* @method Revolt[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class RevoltRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Revolt::class);
}
}

+ 0
- 13
src/Repository/RevoltRepositoryQuery.php View File

@@ -1,13 +0,0 @@
<?php

namespace App\Repository;

use Knp\Component\Pager\PaginatorInterface;

class RevoltRepositoryQuery extends SearchRepositoryQuery
{
public function __construct(RevoltRepository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, $paginator);
}
}

+ 0
- 14
src/Repository/RevoltStore.php View File

@@ -1,14 +0,0 @@
<?php

namespace App\Repository;


class RevoltStore extends SearchStore
{
protected $query;

public function __construct(RevoltRepositoryQuery $query)
{
$this->query = $query;
}
}

+ 0
- 96
src/Repository/SearchRepositoryQuery.php View File

@@ -1,96 +0,0 @@
<?php

namespace App\Repository;

use Doctrine\Common\Collections\ArrayCollection;
use Gedmo\Tree\RepositoryInterface;
use Knp\Component\Pager\PaginatorInterface;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class SearchRepositoryQuery extends AbstractRepositoryQuery implements RepositoryQueryInterface
{
protected $isJoinCollectifData = false;
protected $isJoinIndividualData = false;
protected $isJoinSubthematic = false;

public function __construct($repository, PaginatorInterface $paginator)
{
parent::__construct($repository, 'r', $paginator);
}

public function filterIsValid()
{
$this->joinCollectifData();
$this->joinIndividualData();

return $this
->andWhere('colData.status = 1 OR indivData.status = 1');
}

public function filterByThematic(ArrayCollection $thematicArray): self
{
return $this
->andWhere('.thematic IN (:thematic)')
->setParameter(':thematic', $thematicArray);
}

public function filterBySubthematicName(string $subthematic): self
{
$this->joinSubthematic();

return $this
->andWhere('subT.name LIKE :subthematic')
->setParameter(':subthematic', '%' . $subthematic . '%');
}

public function filterByDescription(string $description): self
{
return $this
->andWhere('.description LIKE :description')
->setParameter(':description', '%' . $description . '%');
}

public function filterByTerritory(ArrayCollection $territoryArray): self
{
$this->joinCollectifData();
$this->joinIndividualData();

return $this
->andWhere('colData.territory IN (:territory) OR indivData.territory IN (:territory)')
->setParameter(':territory', $territoryArray);
}

public function joinSubthematic(): self
{
if (!$this->isJoinSubthematic) {
$this->isJoinSubthematic = true;

return $this
->leftJoin('.subthematic', 'subT');
}
return $this;
}

public function joinCollectifData(): self
{
if (!$this->isJoinCollectifData) {
$this->isJoinCollectifData = true;

return $this
->leftJoin('.collectifData', 'colData');
}
return $this;
}

public function joinIndividualData(): self
{
if (!$this->isJoinIndividualData) {
$this->isJoinIndividualData = true;

return $this
->leftJoin('.individualData', 'indivData');
}
return $this;
}
}

+ 0
- 66
src/Repository/SearchStore.php View File

@@ -1,66 +0,0 @@
<?php

namespace App\Repository;


use App\Entity\Thematic;
use Doctrine\Common\Collections\ArrayCollection;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Repository\StoreInterface;

class SearchStore extends AbstractStore implements StoreInterface
{

public function __construct($query)
{
$this->query = $query;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterIsValid();
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function filterSearch(
?string $subthematic,
ArrayCollection $territoryArray,
ArrayCollection $thematicArray,
$query = null
) {
$query = $this->createDefaultQuery($query);

if (!($thematicArray->isEmpty())) {
$query->filterByThematic($thematicArray);
}
if (!($territoryArray->isEmpty())) {
$query->filterByTerritory($territoryArray);
}
if (!empty($subthematic)) {
$query->filterBySubthematicName($subthematic);
}

return $query->find();
}

public function getByThematic(Thematic $thematic, $query = null)
{
$query = $this->createDefaultQuery($query);
$query->filterByThematic(new ArrayCollection([$thematic]));

return $query->find();
}

}

+ 0
- 50
src/Repository/SubthematicRepository.php View File

@@ -1,50 +0,0 @@
<?php

namespace App\Repository;

use App\Entity\Subthematic;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
* @method Subthematic|null find($id, $lockMode = null, $lockVersion = null)
* @method Subthematic|null findOneBy(array $criteria, array $orderBy = null)
* @method Subthematic[] findAll()
* @method Subthematic[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class SubthematicRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Subthematic::class);
}

// /**
// * @return Subthematic[] Returns an array of Subthematic objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('t')
->andWhere('t.exampleField = :val')
->setParameter('val', $value)
->orderBy('t.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/

/*
public function findOneBySomeField($value): ?Subthematic
{
return $this->createQueryBuilder('t')
->andWhere('t.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}

+ 0
- 50
src/Repository/TerritoryRepository.php View File

@@ -1,50 +0,0 @@
<?php

namespace App\Repository;

use App\Entity\Territory;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
* @method Territory|null find($id, $lockMode = null, $lockVersion = null)
* @method Territory|null findOneBy(array $criteria, array $orderBy = null)
* @method Territory[] findAll()
* @method Territory[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class TerritoryRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Territory::class);
}

// /**
// * @return Territory[] Returns an array of Territory objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('t')
->andWhere('t.exampleField = :val')
->setParameter('val', $value)
->orderBy('t.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/

/*
public function findOneBySomeField($value): ?Territory
{
return $this->createQueryBuilder('t')
->andWhere('t.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}

+ 0
- 15
src/Repository/TerritoryRepositoryQuery.php View File

@@ -1,15 +0,0 @@
<?php

namespace App\Repository;

use Knp\Component\Pager\PaginatorInterface;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class TerritoryRepositoryQuery extends AbstractRepositoryQuery implements RepositoryQueryInterface
{
public function __construct(TerritoryRepository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, 'r', $paginator);
}
}

+ 0
- 34
src/Repository/TerritoryStore.php View File

@@ -1,34 +0,0 @@
<?php

namespace App\Repository;


use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Repository\StoreInterface;

class TerritoryStore extends AbstractStore implements StoreInterface
{

public function __construct(TerritoryRepositoryQuery $query)
{
$this->query = $query;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

}

+ 0
- 50
src/Repository/ThematicRepository.php View File

@@ -1,50 +0,0 @@
<?php

namespace App\Repository;

use App\Entity\Thematic;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
* @method Thematic|null find($id, $lockMode = null, $lockVersion = null)
* @method Thematic|null findOneBy(array $criteria, array $orderBy = null)
* @method Thematic[] findAll()
* @method Thematic[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ThematicRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Thematic::class);
}

// /**
// * @return Thematic[] Returns an array of Thematic objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('t')
->andWhere('t.exampleField = :val')
->setParameter('val', $value)
->orderBy('t.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/

/*
public function findOneBySomeField($value): ?Thematic
{
return $this->createQueryBuilder('t')
->andWhere('t.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}

+ 0
- 15
src/Repository/ThematicRepositoryQuery.php View File

@@ -1,15 +0,0 @@
<?php

namespace App\Repository;

use Knp\Component\Pager\PaginatorInterface;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class ThematicRepositoryQuery extends AbstractRepositoryQuery implements RepositoryQueryInterface
{
public function __construct(ThematicRepository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, 'r', $paginator);
}
}

+ 0
- 34
src/Repository/ThematicStore.php View File

@@ -1,34 +0,0 @@
<?php

namespace App\Repository;


use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Repository\StoreInterface;

class ThematicStore extends AbstractStore implements StoreInterface
{

public function __construct(ThematicRepositoryQuery $query)
{
$this->query = $query;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

}

+ 0
- 91
src/Type/DreamType.php View File

@@ -1,91 +0,0 @@
<?php

namespace App\Type;

use App\Entity\Dream;
use App\Entity\Subthematic;
use App\Entity\Thematic;
use Lc\SovBundle\Doctrine\EntityManager;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\NotBlank;

class DreamType extends AbstractType
{

protected $em;
protected $translatorAdmin;

public function __construct(EntityManager $em, TranslatorAdmin $translatorAdmin)
{
$this->em = $em;
$this->translatorAdmin = $translatorAdmin;
}

/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add(
'description',
TextareaType::class,
[
'label' => 'form.field.dream.description',
'constraints' => [
new NotBlank(),
],
]
)
->add(
'thematic',
EntityType::class,
[
'label' => 'form.field.dream.thematic',
'class' => Thematic::class,
'required' => false,
'choice_attr' => function ($choice, $key, $value) {
return ['data-class' => 'theme' . strtolower($value)];
},
'attr' => [
'class' => 'theme'
]
]
);
if ($options['context'] == "backend") {
$builder->add(
'subthematic',
EntityType::class,
[
'label' => 'form.field.dream.subthematic',
'class' => Subthematic::class,
'required' => false,
'choice_attr' => function ($choice, $key, $value) {
return ['data-class' => 'theme' . strtolower($choice->getThematic()->getId())];
},
'attr' => [
'class' => 'subtheme'
]
]
);
}
}

/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(
[
'data_class' => $this->em->getEntityName(Dream::class),
'context' => 'backend'
]
);
}
}


+ 0
- 92
src/Type/ProjectBoostType.php View File

@@ -1,92 +0,0 @@
<?php

namespace App\Type;

use App\Entity\ProjectBoost;
use App\Entity\Subthematic;
use App\Entity\Thematic;
use Lc\SovBundle\Doctrine\EntityManager;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\NotBlank;

class ProjectBoostType extends AbstractType
{

protected $em;
protected $translatorAdmin;

public function __construct(EntityManager $em, TranslatorAdmin $translatorAdmin)
{
$this->em = $em;
$this->translatorAdmin = $translatorAdmin;
}

/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add(
'description',
TextareaType::class,
[
'label' => 'form.field.projectBoost.description',
'constraints' => [
new NotBlank(),
],
]
)
->add(
'thematic',
EntityType::class,
[
'label' => 'form.field.projectBoost.thematic',
'class' => Thematic::class,
'required' => false,
'choice_attr' => function ($choice, $key, $value) {
return ['data-class' => 'theme' . strtolower($value)];
},
'attr' => [
'class' => 'theme'
]
]
);

if ($options['context'] == "backend") {
$builder->add(
'subthematic',
EntityType::class,
[
'label' => 'form.field.projectBoost.subthematic',
'class' => Subthematic::class,
'required' => false,
'choice_attr' => function ($choice, $key, $value) {
return ['data-class' => 'theme' . strtolower($choice->getThematic()->getId())];
},
'attr' => [
'class' => 'subtheme'
]
]
);
}
}

/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(
[
'data_class' => $this->em->getEntityName(ProjectBoost::class),
'context' => 'backend'
]
);
}
}


+ 0
- 91
src/Type/ProjectInspiringType.php View File

@@ -1,91 +0,0 @@
<?php

namespace App\Type;

use App\Entity\ProjectInspiring;
use App\Entity\Subthematic;
use App\Entity\Thematic;
use Lc\SovBundle\Doctrine\EntityManager;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\NotBlank;

class ProjectInspiringType extends AbstractType
{

protected $em;
protected $translatorAdmin;

public function __construct(EntityManager $em, TranslatorAdmin $translatorAdmin)
{
$this->em = $em;
$this->translatorAdmin = $translatorAdmin;
}

/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add(
'description',
TextareaType::class,
[
'label' => 'form.field.projectinspiring.description',
'constraints' => [
new NotBlank(),
],
]
)
->add(
'thematic',
EntityType::class,
[
'label' => 'form.field.projectinspiring.thematic',
'class' => Thematic::class,
'required' => false,
'choice_attr' => function ($choice, $key, $value) {
return ['data-class' => 'theme' . strtolower($value)];
},
'attr' => [
'class' => 'theme'
]
]
);
if ($options['context'] == "backend") {
$builder->add(
'subthematic',
EntityType::class,
[
'label' => 'form.field.projectinspiring.subthematic',
'class' => Subthematic::class,
'required' => false,
'choice_attr' => function ($choice, $key, $value) {
return ['data-class' => 'theme' . strtolower($choice->getThematic()->getId())];
},
'attr' => [
'class' => 'subtheme'
]
]
);
}
}

/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(
[
'data_class' => $this->em->getEntityName(ProjectInspiring::class),
'context' => 'backend'
]
);
}
}


+ 0
- 92
src/Type/RevoltType.php View File

@@ -1,92 +0,0 @@
<?php

namespace App\Type;

use App\Entity\Revolt;
use App\Entity\Subthematic;
use App\Entity\Thematic;
use Lc\SovBundle\Doctrine\EntityManager;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\NotBlank;

class RevoltType extends AbstractType
{

protected $em;
protected $translatorAdmin;

public function __construct(EntityManager $em, TranslatorAdmin $translatorAdmin)
{
$this->em = $em;
$this->translatorAdmin = $translatorAdmin;
}

/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add(
'description',
TextareaType::class,
[
'label' => 'form.field.revolt.description',
'constraints' => [
new NotBlank(),
],
]
)
->add(
'thematic',
EntityType::class,
[
'label' => 'form.field.revolt.thematic',
'class' => Thematic::class,
'required' => false,
'choice_attr' => function ($choice, $key, $value) {
return ['data-class' => 'theme' . strtolower($value)];
},
'attr' => [
'class' => 'theme'
]
]
);
if ($options['context'] == "backend") {
$builder->add(
'subthematic',
EntityType::class,
[
'label' => 'form.field.revolt.subthematic',
'class' => Subthematic::class,
'required' => false,
'choice_attr' => function ($choice, $key, $value) {
return ['data-class' => 'theme' . strtolower($choice->getThematic()->getId())];
},
'attr' => [
'class' => 'subtheme'
]
]
);
}
}

/**
* {@inheritdoc}
*/
public function configureOptions(
OptionsResolver $resolver
) {
$resolver->setDefaults(
[
'data_class' => $this->em->getEntityName(Revolt::class),
'context' => 'backend'
]
);
}
}


Loading…
Cancel
Save