<?php | |||||
namespace Lc\PietroBundle\Container\Dream; | |||||
use Lc\PietroBundle\Factory\Dream\DreamFactory; | |||||
use Lc\PietroBundle\Repository\Dream\DreamRepositoryQuery; | |||||
use Lc\PietroBundle\Repository\Dream\DreamStore; | |||||
class DreamContainer | |||||
{ | |||||
protected DreamFactory $factory; | |||||
protected DreamRepositoryQuery $repositoryQuery; | |||||
protected DreamStore $store; | |||||
public function __construct( | |||||
DreamFactory $factory, | |||||
DreamRepositoryQuery $repositoryQuery, | |||||
DreamStore $store | |||||
) { | |||||
$this->factory = $factory; | |||||
$this->repositoryQuery = $repositoryQuery; | |||||
$this->store = $store; | |||||
} | |||||
public function getFactory(): DreamFactory | |||||
{ | |||||
return $this->factory; | |||||
} | |||||
public function getRepositoryQuery(): DreamRepositoryQuery | |||||
{ | |||||
return $this->repositoryQuery; | |||||
} | |||||
public function getStore(): DreamStore | |||||
{ | |||||
return $this->store; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Container\IndividualData; | |||||
use Lc\PietroBundle\Definition\Field\IndividualData\IndividualDataFieldDefinition; | |||||
use Lc\PietroBundle\Factory\IndividualData\IndividualDataFactory; | |||||
use Lc\PietroBundle\Repository\IndividualData\IndividualDataRepositoryQuery; | |||||
use Lc\PietroBundle\Repository\IndividualData\IndividualDataStore; | |||||
class IndividualDataContainer | |||||
{ | |||||
protected IndividualDataFactory $factory; | |||||
protected IndividualDataRepositoryQuery $repositoryQuery; | |||||
protected IndividualDataStore $store; | |||||
protected IndividualDataFieldDefinition $fieldDefinition; | |||||
public function __construct( | |||||
IndividualDataFactory $factory, | |||||
IndividualDataRepositoryQuery $repositoryQuery, | |||||
IndividualDataStore $store, | |||||
IndividualDataFieldDefinition $fieldDefinition | |||||
) { | |||||
$this->factory = $factory; | |||||
$this->repositoryQuery = $repositoryQuery; | |||||
$this->store = $store; | |||||
$this->fieldDefinition = $fieldDefinition; | |||||
} | |||||
public function getFactory(): IndividualDataFactory | |||||
{ | |||||
return $this->factory; | |||||
} | |||||
public function getRepositoryQuery(): IndividualDataRepositoryQuery | |||||
{ | |||||
return $this->repositoryQuery; | |||||
} | |||||
public function getStore(): IndividualDataStore | |||||
{ | |||||
return $this->store; | |||||
} | |||||
public function getFieldDefinition(): IndividualDataFieldDefinition | |||||
{ | |||||
return $this->fieldDefinition; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Container\ProjectBoost; | |||||
use Lc\PietroBundle\Factory\ProjectBoost\ProjectBoostFactory; | |||||
use Lc\PietroBundle\Repository\ProjectBoost\ProjectBoostRepositoryQuery; | |||||
use Lc\PietroBundle\Repository\ProjectBoost\ProjectBoostStore; | |||||
class ProjectBoostContainer | |||||
{ | |||||
protected ProjectBoostFactory $factory; | |||||
protected ProjectBoostRepositoryQuery $repositoryQuery; | |||||
protected ProjectBoostStore $store; | |||||
public function __construct( | |||||
ProjectBoostFactory $factory, | |||||
ProjectBoostRepositoryQuery $repositoryQuery, | |||||
ProjectBoostStore $store | |||||
) { | |||||
$this->factory = $factory; | |||||
$this->repositoryQuery = $repositoryQuery; | |||||
$this->store = $store; | |||||
} | |||||
public function getFactory(): ProjectBoostFactory | |||||
{ | |||||
return $this->factory; | |||||
} | |||||
public function getRepositoryQuery(): ProjectBoostRepositoryQuery | |||||
{ | |||||
return $this->repositoryQuery; | |||||
} | |||||
public function getStore(): ProjectBoostStore | |||||
{ | |||||
return $this->store; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Container\ProjectInspiring; | |||||
use Lc\PietroBundle\Factory\ProjectInspiring\ProjectInspiringFactory; | |||||
use Lc\PietroBundle\Repository\ProjectInspiring\ProjectInspiringRepositoryQuery; | |||||
use Lc\PietroBundle\Repository\ProjectInspiring\ProjectInspiringStore; | |||||
class ProjectInspiringContainer | |||||
{ | |||||
protected ProjectInspiringFactory $factory; | |||||
protected ProjectInspiringRepositoryQuery $repositoryQuery; | |||||
protected ProjectInspiringStore $store; | |||||
public function __construct( | |||||
ProjectInspiringFactory $factory, | |||||
ProjectInspiringRepositoryQuery $repositoryQuery, | |||||
ProjectInspiringStore $store | |||||
) { | |||||
$this->factory = $factory; | |||||
$this->repositoryQuery = $repositoryQuery; | |||||
$this->store = $store; | |||||
} | |||||
public function getFactory(): ProjectInspiringFactory | |||||
{ | |||||
return $this->factory; | |||||
} | |||||
public function getRepositoryQuery(): ProjectInspiringRepositoryQuery | |||||
{ | |||||
return $this->repositoryQuery; | |||||
} | |||||
public function getStore(): ProjectInspiringStore | |||||
{ | |||||
return $this->store; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Container\Revolt; | |||||
use Lc\PietroBundle\Factory\Revolt\RevoltFactory; | |||||
use Lc\PietroBundle\Repository\Revolt\RevoltRepositoryQuery; | |||||
use Lc\PietroBundle\Repository\Revolt\RevoltStore; | |||||
class RevoltContainer | |||||
{ | |||||
protected RevoltFactory $factory; | |||||
protected RevoltRepositoryQuery $repositoryQuery; | |||||
protected RevoltStore $store; | |||||
public function __construct( | |||||
RevoltFactory $factory, | |||||
RevoltRepositoryQuery $repositoryQuery, | |||||
RevoltStore $store | |||||
) { | |||||
$this->factory = $factory; | |||||
$this->repositoryQuery = $repositoryQuery; | |||||
$this->store = $store; | |||||
} | |||||
public function getFactory(): RevoltFactory | |||||
{ | |||||
return $this->factory; | |||||
} | |||||
public function getRepositoryQuery(): RevoltRepositoryQuery | |||||
{ | |||||
return $this->repositoryQuery; | |||||
} | |||||
public function getStore(): RevoltStore | |||||
{ | |||||
return $this->store; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Container\Subthematic; | |||||
use Lc\PietroBundle\Factory\Subthematic\SubthematicFactory; | |||||
use Lc\PietroBundle\Repository\Subthematic\SubthematicRepositoryQuery; | |||||
use Lc\PietroBundle\Repository\Subthematic\SubthematicStore; | |||||
class SubthematicContainer | |||||
{ | |||||
protected SubthematicFactory $factory; | |||||
protected SubthematicRepositoryQuery $repositoryQuery; | |||||
protected SubthematicStore $store; | |||||
public function __construct( | |||||
SubthematicFactory $factory, | |||||
SubthematicRepositoryQuery $repositoryQuery, | |||||
SubthematicStore $store | |||||
) { | |||||
$this->factory = $factory; | |||||
$this->repositoryQuery = $repositoryQuery; | |||||
$this->store = $store; | |||||
} | |||||
public function getFactory(): SubthematicFactory | |||||
{ | |||||
return $this->factory; | |||||
} | |||||
public function getRepositoryQuery(): SubthematicRepositoryQuery | |||||
{ | |||||
return $this->repositoryQuery; | |||||
} | |||||
public function getStore(): SubthematicStore | |||||
{ | |||||
return $this->store; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Container\Territory; | |||||
use Lc\PietroBundle\Factory\Territory\TerritoryFactory; | |||||
use Lc\PietroBundle\Repository\Territory\TerritoryRepositoryQuery; | |||||
use Lc\PietroBundle\Repository\Territory\TerritoryStore; | |||||
class TerritoryContainer | |||||
{ | |||||
protected TerritoryFactory $factory; | |||||
protected TerritoryRepositoryQuery $repositoryQuery; | |||||
protected TerritoryStore $store; | |||||
public function __construct( | |||||
TerritoryFactory $factory, | |||||
TerritoryRepositoryQuery $repositoryQuery, | |||||
TerritoryStore $store | |||||
) { | |||||
$this->factory = $factory; | |||||
$this->repositoryQuery = $repositoryQuery; | |||||
$this->store = $store; | |||||
} | |||||
public function getFactory(): TerritoryFactory | |||||
{ | |||||
return $this->factory; | |||||
} | |||||
public function getRepositoryQuery(): TerritoryRepositoryQuery | |||||
{ | |||||
return $this->repositoryQuery; | |||||
} | |||||
public function getStore(): TerritoryStore | |||||
{ | |||||
return $this->store; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Container\Thematic; | |||||
use Lc\PietroBundle\Factory\Thematic\ThematicFactory; | |||||
use Lc\PietroBundle\Repository\Thematic\ThematicRepositoryQuery; | |||||
use Lc\PietroBundle\Repository\Thematic\ThematicStore; | |||||
class ThematicContainer | |||||
{ | |||||
protected ThematicFactory $factory; | |||||
protected ThematicRepositoryQuery $repositoryQuery; | |||||
protected ThematicStore $store; | |||||
public function __construct( | |||||
ThematicFactory $factory, | |||||
ThematicRepositoryQuery $repositoryQuery, | |||||
ThematicStore $store | |||||
) { | |||||
$this->factory = $factory; | |||||
$this->repositoryQuery = $repositoryQuery; | |||||
$this->store = $store; | |||||
} | |||||
public function getFactory(): ThematicFactory | |||||
{ | |||||
return $this->factory; | |||||
} | |||||
public function getRepositoryQuery(): ThematicRepositoryQuery | |||||
{ | |||||
return $this->repositoryQuery; | |||||
} | |||||
public function getStore(): ThematicStore | |||||
{ | |||||
return $this->store; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Controller; | |||||
use Lc\SovBundle\Controller\AbstractAdminController as SovAbstractAdminController; | |||||
abstract class AbstractAdminController extends SovAbstractAdminController | |||||
{ | |||||
use ControllerTrait; | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Controller; | |||||
use Lc\SovBundle\Controller\AbstractController as SovAbstractController; | |||||
abstract class AbstractController extends SovAbstractController | |||||
{ | |||||
use ControllerTrait; | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Controller; | |||||
use Lc\PietroBundle\Container\Dream\DreamContainer; | |||||
use Lc\PietroBundle\Container\IndividualData\IndividualDataContainer; | |||||
use Lc\PietroBundle\Container\ProjectBoost\ProjectBoostContainer; | |||||
use Lc\PietroBundle\Container\ProjectInspiring\ProjectInspiringContainer; | |||||
use Lc\PietroBundle\Container\Revolt\RevoltContainer; | |||||
use Lc\PietroBundle\Container\Subthematic\SubthematicContainer; | |||||
use Lc\PietroBundle\Container\Territory\TerritoryContainer; | |||||
use Lc\PietroBundle\Container\Thematic\ThematicContainer; | |||||
trait ControllerTrait | |||||
{ | |||||
public static function getSubscribedServices() | |||||
{ | |||||
return array_merge( | |||||
parent::getSubscribedServices(), | |||||
[ | |||||
DreamContainer::class => DreamContainer::class, | |||||
IndividualDataContainer::class => IndividualDataContainer::class, | |||||
ProjectBoostContainer::class => ProjectBoostContainer::class, | |||||
ProjectInspiringContainer::class => ProjectInspiringContainer::class, | |||||
RevoltContainer::class => RevoltContainer::class, | |||||
SubthematicContainer::class => SubthematicContainer::class, | |||||
TerritoryContainer::class => TerritoryContainer::class, | |||||
ThematicContainer::class => ThematicContainer::class, | |||||
] | |||||
); | |||||
} | |||||
public function getDreamContainer(): DreamContainer | |||||
{ | |||||
return $this->get(DreamContainer::class); | |||||
} | |||||
public function getIndividualDataContainer(): IndividualDataContainer | |||||
{ | |||||
return $this->get(IndividualDataContainer::class); | |||||
} | |||||
public function getProjectBoostContainer(): ProjectBoostContainer | |||||
{ | |||||
return $this->get(ProjectBoostContainer::class); | |||||
} | |||||
public function getProjectInspiringContainer(): ProjectInspiringContainer | |||||
{ | |||||
return $this->get(ProjectInspiringContainer::class); | |||||
} | |||||
public function getRevoltContainer(): RevoltContainer | |||||
{ | |||||
return $this->get(RevoltContainer::class); | |||||
} | |||||
public function getSubthematicContainer(): SubthematicContainer | |||||
{ | |||||
return $this->get(SubthematicContainer::class); | |||||
} | |||||
public function getTerritoryContainer(): TerritoryContainer | |||||
{ | |||||
return $this->get(TerritoryContainer::class); | |||||
} | |||||
public function getThematicContainer(): ThematicContainer | |||||
{ | |||||
return $this->get(ThematicContainer::class); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Controller\IndividualData; | |||||
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 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\Controller\AbstractAdminController; | |||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||||
use Symfony\Component\HttpFoundation\Request; | |||||
use Lc\SovBundle\Generator\CsvGenerator; | |||||
abstract class IndividualDataAdminController extends AbstractAdminController | |||||
{ | |||||
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 function createEntity(string $entityFqcn) | |||||
{ | |||||
return $this->getIndividualDataContainer()->getFactory()->create(); | |||||
} | |||||
public function configureFields(string $pageName): iterable | |||||
{ | |||||
return $this->getIndividualDataContainer() | |||||
->getFieldDefinition() | |||||
->getFields($pageName); | |||||
} | |||||
public function getRepositoryQuery(): RepositoryQueryInterface | |||||
{ | |||||
return $this->getIndividualDataContainer()->getRepositoryQuery(); | |||||
} | |||||
public function createIndexRepositoryQuery( | |||||
SearchDto $searchDto, | |||||
EntityDto $entityDto, | |||||
FieldCollection $fields, | |||||
FilterCollection $filters | |||||
): RepositoryQueryInterface { | |||||
$repositoryQuery = parent::createIndexRepositoryQuery($searchDto, $entityDto, $fields, $filters); | |||||
$status = $searchDto->getRequest()->get('status'); | |||||
if ($status || $status === 0) { | |||||
$repositoryQuery->filterByStatus($searchDto->getRequest()->get('status')); | |||||
} | |||||
return $repositoryQuery; | |||||
} | |||||
public function configureActions(Actions $actions): Actions | |||||
{ | |||||
parent::configureActions($actions); | |||||
$export = Action::new('export', 'actions.export') | |||||
->setIcon('fa fa-download') | |||||
->linkToCrudAction('exportCsv') | |||||
->setCssClass('btn btn-sm btn-primary export-csv') | |||||
->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_Individuel', 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; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Controller\Subthematic; | |||||
use Lc\PietroBundle\Container\Subthematic\SubthematicContainer; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||||
use Lc\PietroBundle\Controller\AbstractAdminController; | |||||
abstract class SubthematicAdminController extends AbstractAdminController | |||||
{ | |||||
public function createEntity(string $entityFqcn) | |||||
{ | |||||
return $this->getSubthematicContainer()->getFactory()->create(); | |||||
} | |||||
public function configureFields(string $pageName): iterable | |||||
{ | |||||
return [ | |||||
TextField::new('name'), | |||||
AssociationField::new('thematic') | |||||
->setTemplatePath('crud/field/association.html.twig') | |||||
]; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Controller\Territory; | |||||
use Lc\PietroBundle\Container\Territory\TerritoryContainer; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||||
use Lc\PietroBundle\Controller\AbstractAdminController; | |||||
abstract class TerritoryAdminController extends AbstractAdminController | |||||
{ | |||||
public function createEntity(string $entityFqcn) | |||||
{ | |||||
return $this->getTerritoryContainer()->getFactory()->create(); | |||||
} | |||||
public function configureFields(string $pageName): iterable | |||||
{ | |||||
return [ | |||||
TextField::new('devAlias'), | |||||
TextField::new('name'), | |||||
]; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Controller\Thematic; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||||
use Lc\PietroBundle\Controller\AbstractAdminController; | |||||
abstract class ThematicAdminController extends AbstractAdminController | |||||
{ | |||||
public function createEntity(string $entityFqcn) | |||||
{ | |||||
return $this->getThematicContainer()->getFactory()->create(); | |||||
} | |||||
public function configureFields(string $pageName): iterable | |||||
{ | |||||
return [ | |||||
TextField::new('name') | |||||
]; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Definition\Field\IndividualData; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\EmailField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\HiddenField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||||
use Lc\PietroBundle\Controller\IndividualData\IndividualDataAdminController; | |||||
use Lc\PietroBundle\Form\Dream\DreamType; | |||||
use Lc\PietroBundle\Form\ProjectBoost\ProjectBoostType; | |||||
use Lc\PietroBundle\Form\ProjectInspiring\ProjectInspiringType; | |||||
use Lc\PietroBundle\Form\Revolt\RevoltType; | |||||
use Lc\PietroBundle\Repository\Territory\TerritoryStore; | |||||
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition; | |||||
use Lc\SovBundle\Field\CollectionField; | |||||
use Lc\SovBundle\Field\StatusField; | |||||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; | |||||
class IndividualDataFieldDefinition extends AbstractFieldDefinition | |||||
{ | |||||
protected AuthorizationCheckerInterface $authorizationChecker; | |||||
protected TerritoryStore $territoryStore; | |||||
public function __construct(TranslatorAdmin $translatorAdmin, AuthorizationCheckerInterface $authorizationChecker, TerritoryStore $territoryStore) | |||||
{ | |||||
$this->authorizationChecker = $authorizationChecker; | |||||
$this->territoryStore = $territoryStore; | |||||
parent::__construct($translatorAdmin); | |||||
} | |||||
public function configureIndex(): array | |||||
{ | |||||
return [ | |||||
'firstname', | |||||
'lastname', | |||||
'territory', | |||||
'nbDream', | |||||
'nbRevolt', | |||||
'nbProjectBoost', | |||||
'nbProjectInspiring', | |||||
]; | |||||
} | |||||
public function configureFields(): array | |||||
{ | |||||
$fields = array(); | |||||
$territoryArray = $this->territoryStore->get(); | |||||
$fields['firstname'] = TextField::new('firstname'); | |||||
$fields['lastname'] = TextField::new('lastname'); | |||||
$fields['email'] = EmailField::new('email'); | |||||
$fields['territory'] = AssociationField::new('territory')->setFormTypeOption('choices', $territoryArray); | |||||
$fields['nbDream'] = TextField::new('nbDream'); | |||||
$fields['nbRevolt'] = TextField::new('nbRevolt'); | |||||
$fields['nbProjectBoost'] = TextField::new('nbProjectBoost'); | |||||
$fields['nbProjectInspiring'] = TextField::new('nbProjectInspiring'); | |||||
$fields['revolt'] = CollectionField::new('revolt') | |||||
->setFormTypeOption('entry_type', RevoltType::class) | |||||
->setFormTypeOption('by_reference', false) | |||||
->setRequired(false); | |||||
$fields['dream'] = CollectionField::new('dream') | |||||
->setFormTypeOption('entry_type', DreamType::class) | |||||
->setFormTypeOption('by_reference', false) | |||||
->setRequired(false); | |||||
$fields['projectBoost'] = CollectionField::new('projectBoost') | |||||
->setFormTypeOption('entry_type', ProjectBoostType::class) | |||||
->setFormTypeOption('by_reference', false) | |||||
->setRequired(false); | |||||
$fields['projectInspiring'] = CollectionField::new('projectinspiring') | |||||
->setFormTypeOption('entry_type', ProjectInspiringType::class) | |||||
->setFormTypeOption('by_reference', false) | |||||
->setRequired(false); | |||||
$hasAccess = $this->authorizationChecker->isGranted('ROLE_ADMIN'); | |||||
if ($hasAccess) { | |||||
$fields['status'] = StatusField::new('status') | |||||
->setFormTypeOption('data', 0) | |||||
->setFormTypeOption('choices', ['Validé' => 1, 'En attente' => 0]) | |||||
->setCustomOption('toggle_label', 'Valider'); | |||||
} else { | |||||
$fields['status'] = HiddenField::new('status') | |||||
->setFormTypeOption('data', 0); | |||||
} | |||||
return $fields; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Doctrine\Extension; | |||||
interface DescriptionProjectInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Doctrine\Extension; | |||||
use Lc\PietroBundle\Model\Thematic\ThematicInterface; | |||||
use Lc\PietroBundle\Model\Subthematic\SubthematicInterface; | |||||
use Doctrine\ORM\Mapping as ORM; | |||||
trait DescriptionProjectTrait | |||||
{ | |||||
/** | |||||
* @ORM\Column(type="text") | |||||
*/ | |||||
protected $description; | |||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\PietroBundle\Model\Thematic\ThematicInterface") | |||||
*/ | |||||
protected $thematic; | |||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\PietroBundle\Model\Subthematic\SubthematicInterface") | |||||
*/ | |||||
protected $subthematic; | |||||
public function getDescription(): ?string | |||||
{ | |||||
return $this->description; | |||||
} | |||||
public function setDescription(string $description): self | |||||
{ | |||||
$this->description = $description; | |||||
return $this; | |||||
} | |||||
public function getThematic(): ?ThematicInterface | |||||
{ | |||||
return $this->thematic; | |||||
} | |||||
public function setThematic(?ThematicInterface $thematic): self | |||||
{ | |||||
$this->thematic = $thematic; | |||||
return $this; | |||||
} | |||||
public function getSubthematic(): ?SubthematicInterface | |||||
{ | |||||
return $this->subthematic; | |||||
} | |||||
public function setSubthematic(?SubthematicInterface $subthematic): self | |||||
{ | |||||
$this->subthematic = $subthematic; | |||||
return $this; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Factory\Dream; | |||||
use App\Entity\Dream\Dream; | |||||
use Lc\PietroBundle\Model\Dream\DreamInterface; | |||||
class DreamFactory | |||||
{ | |||||
public function create(): DreamInterface | |||||
{ | |||||
$dream = new Dream(); | |||||
return $dream; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Factory\IndividualData; | |||||
use App\Entity\IndividualData\IndividualData; | |||||
use Lc\PietroBundle\Model\IndividualData\IndividualDataInterface; | |||||
class IndividualDataFactory | |||||
{ | |||||
public function create(): IndividualDataInterface | |||||
{ | |||||
$individualData = new IndividualData(); | |||||
return $individualData; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Factory\ProjectBoost; | |||||
use App\Entity\ProjectBoost\ProjectBoost; | |||||
use Lc\PietroBundle\Model\ProjectBoost\ProjectBoostInterface; | |||||
class ProjectBoostFactory | |||||
{ | |||||
public function create(): ProjectBoostInterface | |||||
{ | |||||
$projectBoost = new ProjectBoost(); | |||||
return $projectBoost; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Factory\ProjectInspiring; | |||||
use App\Entity\ProjectInspiring\ProjectInspiring; | |||||
use Lc\PietroBundle\Model\ProjectInspiring\ProjectInspiringInterface; | |||||
class ProjectInspiringFactory | |||||
{ | |||||
public function create(): ProjectInspiringInterface | |||||
{ | |||||
$projectInspiring = new ProjectInspiring(); | |||||
return $projectInspiring; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Factory\Revolt; | |||||
use App\Entity\Revolt\Revolt; | |||||
use Lc\PietroBundle\Model\Revolt\RevoltInterface; | |||||
class RevoltFactory | |||||
{ | |||||
public function create(): RevoltInterface | |||||
{ | |||||
$revolt = new Revolt(); | |||||
return $revolt; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Factory\Subthematic; | |||||
use App\Entity\Thematic\Subthematic; | |||||
use Lc\PietroBundle\Model\Subthematic\SubthematicInterface; | |||||
class SubthematicFactory | |||||
{ | |||||
public function create(): SubthematicInterface | |||||
{ | |||||
$subthematic = new Subthematic(); | |||||
return $subthematic; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Factory\Territory; | |||||
use App\Entity\Territory\Territory; | |||||
use Lc\PietroBundle\Model\Territory\TerritoryInterface; | |||||
class TerritoryFactory | |||||
{ | |||||
public function create(): TerritoryInterface | |||||
{ | |||||
$territory = new Territory(); | |||||
return $territory; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Factory\Thematic; | |||||
use App\Entity\Thematic\Thematic; | |||||
use Lc\PietroBundle\Model\Thematic\ThematicInterface; | |||||
class ThematicFactory | |||||
{ | |||||
public function create(): ThematicInterface | |||||
{ | |||||
$thematic = new Thematic(); | |||||
return $thematic; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Form\Dream; | |||||
use Lc\PietroBundle\Model\Dream\DreamInterface; | |||||
use Lc\PietroBundle\Model\Subthematic\SubthematicInterface; | |||||
use Lc\PietroBundle\Model\Thematic\ThematicInterface; | |||||
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) | |||||
{ | |||||
$placeholder = ""; | |||||
if (isset($options['placeholder_description'])) { | |||||
$placeholder = $options['placeholder_description']; | |||||
} | |||||
$builder->add( | |||||
'description', | |||||
TextareaType::class, | |||||
[ | |||||
'label' => 'form.field.dream.description', | |||||
'constraints' => [ | |||||
new NotBlank(), | |||||
], | |||||
'attr' => [ | |||||
"placeholder" => $placeholder | |||||
] | |||||
] | |||||
); | |||||
if ($options['thematic'] == true) { | |||||
$builder->add( | |||||
'thematic', | |||||
EntityType::class, | |||||
[ | |||||
'label' => 'form.field.dream.thematic', | |||||
'class' => $this->em->getEntityName(ThematicInterface::class), | |||||
'required' => false, | |||||
'choice_attr' => function ($choice, $key, $value) { | |||||
return ['data-class' => 'theme' . strtolower($value)]; | |||||
}, | |||||
'attr' => [ | |||||
'class' => 'theme' | |||||
] | |||||
] | |||||
); | |||||
} | |||||
if ($options['context'] == "backend" && $options['thematic'] == true) { | |||||
$builder->add( | |||||
'subthematic', | |||||
EntityType::class, | |||||
[ | |||||
'label' => 'form.field.dream.subthematic', | |||||
'class' => $this->em->getEntityName(SubthematicInterface::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(DreamInterface::class), | |||||
'context' => 'backend', | |||||
'thematic' => true, | |||||
'placeholder_description' => false | |||||
] | |||||
); | |||||
} | |||||
} | |||||
<?php | |||||
namespace Lc\PietroBundle\Form\ProjectBoost; | |||||
use Lc\PietroBundle\Model\ProjectBoost\ProjectBoostInterface; | |||||
use Lc\PietroBundle\Model\Subthematic\SubthematicInterface; | |||||
use Lc\PietroBundle\Model\Thematic\ThematicInterface; | |||||
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(), | |||||
], | |||||
] | |||||
); | |||||
if ($options['thematic'] == true) { | |||||
$builder->add( | |||||
'thematic', | |||||
EntityType::class, | |||||
[ | |||||
'label' => 'form.field.projectBoost.thematic', | |||||
'class' => $this->em->getEntityName(ThematicInterface::class), | |||||
'required' => false, | |||||
'choice_attr' => function ($choice, $key, $value) { | |||||
return ['data-class' => 'theme' . strtolower($value)]; | |||||
}, | |||||
'attr' => [ | |||||
'class' => 'theme' | |||||
] | |||||
] | |||||
); | |||||
} | |||||
if ($options['context'] == "backend" && $options['thematic'] == true) { | |||||
$builder->add( | |||||
'subthematic', | |||||
EntityType::class, | |||||
[ | |||||
'label' => 'form.field.projectBoost.subthematic', | |||||
'class' => $this->em->getEntityName(SubthematicInterface::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(ProjectBoostInterface::class), | |||||
'context' => 'backend', | |||||
'thematic' => true, | |||||
] | |||||
); | |||||
} | |||||
} | |||||
<?php | |||||
namespace Lc\PietroBundle\Form\ProjectInspiring; | |||||
use Lc\PietroBundle\Model\ProjectInspiring\ProjectInspiringInterface; | |||||
use Lc\PietroBundle\Model\Subthematic\SubthematicInterface; | |||||
use Lc\PietroBundle\Model\Thematic\ThematicInterface; | |||||
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) | |||||
{ | |||||
$placeholder = ""; | |||||
if (isset($options['placeholder_description'])) { | |||||
$placeholder = $options['placeholder_description']; | |||||
} | |||||
$builder->add( | |||||
'description', | |||||
TextareaType::class, | |||||
[ | |||||
'label' => 'form.field.projectinspiring.description', | |||||
'constraints' => [ | |||||
new NotBlank(), | |||||
], | |||||
'attr' => [ | |||||
"placeholder" => $placeholder | |||||
] | |||||
] | |||||
); | |||||
if ($options['thematic'] == true) { | |||||
$builder->add( | |||||
'thematic', | |||||
EntityType::class, | |||||
[ | |||||
'label' => 'form.field.projectinspiring.thematic', | |||||
'class' => $this->em->getEntityName(ThematicInterface::class), | |||||
'required' => false, | |||||
'choice_attr' => function ($choice, $key, $value) { | |||||
return ['data-class' => 'theme' . strtolower($value)]; | |||||
}, | |||||
'attr' => [ | |||||
'class' => 'theme' | |||||
] | |||||
] | |||||
); | |||||
} | |||||
if ($options['context'] == "backend" && $options['thematic'] == true) { | |||||
$builder->add( | |||||
'subthematic', | |||||
EntityType::class, | |||||
[ | |||||
'label' => 'form.field.projectinspiring.subthematic', | |||||
'class' => $this->em->getEntityName(SubthematicInterface::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(ProjectInspiringInterface::class), | |||||
'context' => 'backend', | |||||
'thematic' => true, | |||||
'placeholder_description' => false | |||||
] | |||||
); | |||||
} | |||||
} | |||||
<?php | |||||
namespace Lc\PietroBundle\Form\Revolt; | |||||
use Lc\PietroBundle\Model\Revolt\RevoltInterface; | |||||
use Lc\PietroBundle\Model\Subthematic\SubthematicInterface; | |||||
use Lc\PietroBundle\Model\Thematic\ThematicInterface; | |||||
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(), | |||||
], | |||||
] | |||||
); | |||||
if ($options['thematic'] == true) { | |||||
$builder->add( | |||||
'thematic', | |||||
EntityType::class, | |||||
[ | |||||
'label' => 'form.field.revolt.thematic', | |||||
'class' => $this->em->getEntityName(ThematicInterface::class), | |||||
'required' => false, | |||||
'choice_attr' => function ($choice, $key, $value) { | |||||
return ['data-class' => 'theme' . strtolower($value)]; | |||||
}, | |||||
'attr' => [ | |||||
'class' => 'theme' | |||||
] | |||||
] | |||||
); | |||||
} | |||||
if ($options['context'] == "backend" && $options['thematic'] == true) { | |||||
$builder->add( | |||||
'subthematic', | |||||
EntityType::class, | |||||
[ | |||||
'label' => 'form.field.revolt.subthematic', | |||||
'class' => $this->em->getEntityName(SubthematicInterface::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(RevoltInterface::class), | |||||
'context' => 'backend', | |||||
'thematic' => true | |||||
] | |||||
); | |||||
} | |||||
} | |||||
class LcPietroBundle extends Bundle | class LcPietroBundle extends Bundle | ||||
{ | { | ||||
public function getContainerExtension() | |||||
{ | |||||
return new LcPietroExtension(); | |||||
} | |||||
public function getContainerExtension() | |||||
{ | |||||
return new LcPietroExtension(); | |||||
} | |||||
} | } |
<?php | |||||
namespace Lc\PietroBundle\Model; | |||||
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]; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Model\Dream; | |||||
use Doctrine\ORM\Mapping as ORM; | |||||
use Lc\PietroBundle\Doctrine\Extension\DescriptionProjectInterface; | |||||
use Lc\PietroBundle\Doctrine\Extension\DescriptionProjectTrait; | |||||
use Lc\PietroBundle\Model\IndividualData\IndividualDataInterface; | |||||
use Lc\SovBundle\Doctrine\EntityInterface; | |||||
/** | |||||
* @ORM\MappedSuperclass() | |||||
*/ | |||||
abstract class Dream implements DescriptionProjectInterface, DreamInterface, EntityInterface | |||||
{ | |||||
use DescriptionProjectTrait; | |||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\PietroBundle\Model\IndividualData\IndividualDataInterface", inversedBy="dream") | |||||
*/ | |||||
protected $individualData; | |||||
public function __toString() | |||||
{ | |||||
return "Nos rêves"; | |||||
} | |||||
public function getIndividualData(): ?IndividualDataInterface | |||||
{ | |||||
return $this->individualData; | |||||
} | |||||
public function setIndividualData(?IndividualDataInterface $individualData): self | |||||
{ | |||||
$this->individualData = $individualData; | |||||
return $this; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Model\Dream; | |||||
interface DreamInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Model\IndividualData; | |||||
use Doctrine\Common\Collections\ArrayCollection; | |||||
use Doctrine\Common\Collections\Collection; | |||||
use Doctrine\ORM\Mapping as ORM; | |||||
use Lc\PietroBundle\Model\AbstractData; | |||||
use Lc\PietroBundle\Model\Dream\DreamInterface; | |||||
use Lc\PietroBundle\Model\ProjectBoost\ProjectBoostInterface; | |||||
use Lc\PietroBundle\Model\ProjectInspiring\ProjectInspiringInterface; | |||||
use Lc\PietroBundle\Model\Revolt\RevoltInterface; | |||||
use Lc\PietroBundle\Model\Territory\TerritoryInterface; | |||||
/** | |||||
* @ORM\MappedSuperclass() | |||||
*/ | |||||
abstract class IndividualData extends AbstractData implements IndividualDataInterface | |||||
{ | |||||
/** | |||||
* @ORM\Column(type="string", length=255, nullable=true) | |||||
*/ | |||||
protected $firstname; | |||||
/** | |||||
* @ORM\Column(type="string", length=255, nullable=true) | |||||
*/ | |||||
protected $lastname; | |||||
/** | |||||
* @ORM\Column(type="string", length=255, nullable=true) | |||||
*/ | |||||
protected $email; | |||||
/** | |||||
* @ORM\Column(type="string", length=255, nullable=true) | |||||
*/ | |||||
protected $introQuestion; | |||||
/** | |||||
* @ORM\Column(type="string", length=255, nullable=true) | |||||
*/ | |||||
protected $introAnswer; | |||||
/** | |||||
* @ORM\OneToMany(targetEntity="Lc\PietroBundle\Model\Revolt\RevoltInterface", mappedBy="individualData", cascade={"persist", "remove"}) | |||||
*/ | |||||
protected $revolt; | |||||
/** | |||||
* @ORM\OneToMany(targetEntity="Lc\PietroBundle\Model\Dream\DreamInterface", mappedBy="individualData", cascade={"persist", "remove"}) | |||||
*/ | |||||
protected $dream; | |||||
/** | |||||
* @ORM\OneToMany(targetEntity="Lc\PietroBundle\Model\ProjectBoost\ProjectBoostInterface", mappedBy="individualData", cascade={"persist", "remove"}) | |||||
*/ | |||||
protected $projectBoost; | |||||
/** | |||||
* @ORM\OneToMany(targetEntity="Lc\PietroBundle\Model\ProjectInspiring\ProjectInspiringInterface", mappedBy="individualData", cascade={"persist", "remove"}) | |||||
*/ | |||||
protected $projectInspiring; | |||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\PietroBundle\Model\Territory\TerritoryInterface", inversedBy="individualData") | |||||
*/ | |||||
protected $territory; | |||||
public function __construct() | |||||
{ | |||||
$this->revolt = new ArrayCollection(); | |||||
$this->dream = new ArrayCollection(); | |||||
$this->projectBoost = new ArrayCollection(); | |||||
$this->projectInspiring = new ArrayCollection(); | |||||
} | |||||
public function getResume() | |||||
{ | |||||
return count($this->getRevolt()) . " révolte(s) - " . count($this->getDream()) . " rêve(s) - " . count( | |||||
$this->getProjectBoost() | |||||
) . " projet(s) boosté(s) - " . count($this->getProjectInspiring()) . " projets inspirants"; | |||||
} | |||||
public function __toString() | |||||
{ | |||||
return $this->firstname . " " . $this->lastname; | |||||
} | |||||
public function getNbDream(): string | |||||
{ | |||||
return count($this->getDream()); | |||||
} | |||||
public function getNbRevolt(): string | |||||
{ | |||||
return count($this->getRevolt()); | |||||
} | |||||
public function getNbProjectBoost(): string | |||||
{ | |||||
return count($this->getProjectBoost()); | |||||
} | |||||
public function getNbProjectInspiring(): string | |||||
{ | |||||
return count($this->getProjectInspiring()); | |||||
} | |||||
public function getFirstname(): ?string | |||||
{ | |||||
return $this->firstname; | |||||
} | |||||
public function setFirstname(string $firstname): self | |||||
{ | |||||
$this->firstname = $firstname; | |||||
return $this; | |||||
} | |||||
public function getLastname(): ?string | |||||
{ | |||||
return $this->lastname; | |||||
} | |||||
public function setLastname(string $lastname): self | |||||
{ | |||||
$this->lastname = $lastname; | |||||
return $this; | |||||
} | |||||
public function getEmail(): ?string | |||||
{ | |||||
return $this->email; | |||||
} | |||||
public function setEmail(string $email): self | |||||
{ | |||||
$this->email = $email; | |||||
return $this; | |||||
} | |||||
public function getIntroQuestion(): ?string | |||||
{ | |||||
return $this->introQuestion; | |||||
} | |||||
public function setIntroQuestion(string $introQuestion): self | |||||
{ | |||||
$this->introQuestion = $introQuestion; | |||||
return $this; | |||||
} | |||||
public function getIntroAnswer(): ?string | |||||
{ | |||||
return $this->introAnswer; | |||||
} | |||||
public function setIntroAnswer(?string $introAnswer): self | |||||
{ | |||||
$this->introAnswer = $introAnswer; | |||||
return $this; | |||||
} | |||||
/** | |||||
* @return Collection|RevoltInterface[] | |||||
*/ | |||||
public function getRevolt(): Collection | |||||
{ | |||||
return $this->revolt; | |||||
} | |||||
public function addRevolt(RevoltInterface $revolt): self | |||||
{ | |||||
if (!$this->revolt->contains($revolt)) { | |||||
$this->revolt[] = $revolt; | |||||
$revolt->setIndividualData($this); | |||||
} | |||||
return $this; | |||||
} | |||||
public function removeRevolt(RevoltInterface $revolt): self | |||||
{ | |||||
if ($this->revolt->removeElement($revolt)) { | |||||
// set the owning side to null (unless already changed) | |||||
if ($revolt->getIndividualData() === $this) { | |||||
$revolt->setIndividualData(null); | |||||
} | |||||
} | |||||
return $this; | |||||
} | |||||
/** | |||||
* @return Collection|DreamInterface[] | |||||
*/ | |||||
public function getDream(): Collection | |||||
{ | |||||
return $this->dream; | |||||
} | |||||
public function addDream(DreamInterface $dream): self | |||||
{ | |||||
if (!$this->dream->contains($dream)) { | |||||
$this->dream[] = $dream; | |||||
$dream->setIndividualData($this); | |||||
} | |||||
return $this; | |||||
} | |||||
public function removeDream(DreamInterface $dream): self | |||||
{ | |||||
if ($this->dream->removeElement($dream)) { | |||||
// set the owning side to null (unless already changed) | |||||
if ($dream->getIndividualData() === $this) { | |||||
$dream->setIndividualData(null); | |||||
} | |||||
} | |||||
return $this; | |||||
} | |||||
/** | |||||
* @return Collection|ProjectBoostInterface[] | |||||
*/ | |||||
public function getProjectBoost(): Collection | |||||
{ | |||||
return $this->projectBoost; | |||||
} | |||||
public function addProjectBoost(ProjectBoostInterface $projectBoost): self | |||||
{ | |||||
if (!$this->projectBoost->contains($projectBoost)) { | |||||
$this->projectBoost[] = $projectBoost; | |||||
$projectBoost->setIndividualData($this); | |||||
} | |||||
return $this; | |||||
} | |||||
public function removeProjectBoost(ProjectBoostInterface $projectBoost): self | |||||
{ | |||||
if ($this->projectBoost->removeElement($projectBoost)) { | |||||
// set the owning side to null (unless already changed) | |||||
if ($projectBoost->getIndividualData() === $this) { | |||||
$projectBoost->setIndividualData(null); | |||||
} | |||||
} | |||||
return $this; | |||||
} | |||||
/** | |||||
* @return Collection|ProjectInspiringInterface[] | |||||
*/ | |||||
public function getProjectInspiring(): Collection | |||||
{ | |||||
return $this->projectInspiring; | |||||
} | |||||
public function addProjectInspiring(ProjectInspiringInterface $projectInspiring): self | |||||
{ | |||||
if (!$this->projectInspiring->contains($projectInspiring)) { | |||||
$this->projectInspiring[] = $projectInspiring; | |||||
$projectInspiring->setIndividualData($this); | |||||
} | |||||
return $this; | |||||
} | |||||
public function removeProjectInspiring(ProjectInspiringInterface $projectInspiring): self | |||||
{ | |||||
if ($this->projectInspiring->removeElement($projectInspiring)) { | |||||
// set the owning side to null (unless already changed) | |||||
if ($projectInspiring->getIndividualData() === $this) { | |||||
$projectInspiring->setIndividualData(null); | |||||
} | |||||
} | |||||
return $this; | |||||
} | |||||
public function getTerritory(): ?TerritoryInterface | |||||
{ | |||||
return $this->territory; | |||||
} | |||||
public function setTerritory(?TerritoryInterface $territory): self | |||||
{ | |||||
$this->territory = $territory; | |||||
return $this; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Model\IndividualData; | |||||
interface IndividualDataInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Model\ProjectBoost; | |||||
use Doctrine\ORM\Mapping as ORM; | |||||
use Lc\PietroBundle\Doctrine\Extension\DescriptionProjectInterface; | |||||
use Lc\PietroBundle\Doctrine\Extension\DescriptionProjectTrait; | |||||
use Lc\PietroBundle\Model\IndividualData\IndividualData; | |||||
use Lc\SovBundle\Doctrine\EntityInterface; | |||||
/** | |||||
* @ORM\MappedSuperclass() | |||||
*/ | |||||
abstract class ProjectBoost implements DescriptionProjectInterface, ProjectBoostInterface, EntityInterface | |||||
{ | |||||
use DescriptionProjectTrait; | |||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\PietroBundle\Model\IndividualData\IndividualDataInterface", inversedBy="projectBoost") | |||||
*/ | |||||
protected $individualData; | |||||
public function __toString() | |||||
{ | |||||
return "Les actions à booster"; | |||||
} | |||||
public function getIndividualData(): ?IndividualData | |||||
{ | |||||
return $this->individualData; | |||||
} | |||||
public function setIndividualData(?IndividualData $individualData): self | |||||
{ | |||||
$this->individualData = $individualData; | |||||
return $this; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Model\ProjectBoost; | |||||
interface ProjectBoostInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Model\ProjectInspiring; | |||||
use Doctrine\ORM\Mapping as ORM; | |||||
use Lc\PietroBundle\Doctrine\Extension\DescriptionProjectInterface; | |||||
use Lc\PietroBundle\Doctrine\Extension\DescriptionProjectTrait; | |||||
use Lc\PietroBundle\Model\IndividualData\IndividualDataInterface; | |||||
use Lc\SovBundle\Doctrine\EntityInterface; | |||||
/** | |||||
* @ORM\MappedSuperclass() | |||||
*/ | |||||
abstract class ProjectInspiring implements DescriptionProjectInterface, ProjectInspiringInterface, EntityInterface | |||||
{ | |||||
use DescriptionProjectTrait; | |||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\PietroBundle\Model\IndividualData\IndividualDataInterface", inversedBy="projectInspiring") | |||||
*/ | |||||
protected $individualData; | |||||
public function __toString() | |||||
{ | |||||
return "Les actions inspirantes"; | |||||
} | |||||
public function getIndividualData(): ?IndividualDataInterface | |||||
{ | |||||
return $this->individualData; | |||||
} | |||||
public function setIndividualData(?IndividualDataInterface $individualData): self | |||||
{ | |||||
$this->individualData = $individualData; | |||||
return $this; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Model\ProjectInspiring; | |||||
interface ProjectInspiringInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Model\Revolt; | |||||
use Doctrine\ORM\Mapping as ORM; | |||||
use Lc\PietroBundle\Doctrine\Extension\DescriptionProjectInterface; | |||||
use Lc\PietroBundle\Doctrine\Extension\DescriptionProjectTrait; | |||||
use Lc\PietroBundle\Model\IndividualData\IndividualDataInterface; | |||||
use Lc\SovBundle\Doctrine\EntityInterface; | |||||
/** | |||||
* @ORM\MappedSuperclass() | |||||
*/ | |||||
abstract class Revolt implements DescriptionProjectInterface, RevoltInterface, EntityInterface | |||||
{ | |||||
use DescriptionProjectTrait; | |||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\PietroBundle\Model\IndividualData\IndividualDataInterface", inversedBy="revolt") | |||||
*/ | |||||
protected $individualData; | |||||
public function __toString() | |||||
{ | |||||
return "Nos révoltes"; | |||||
} | |||||
public function getIndividualData(): ?IndividualDataInterface | |||||
{ | |||||
return $this->individualData; | |||||
} | |||||
public function setIndividualData(?IndividualDataInterface $individualData): self | |||||
{ | |||||
$this->individualData = $individualData; | |||||
return $this; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Model\Revolt; | |||||
interface RevoltInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Model\Subthematic; | |||||
use Doctrine\ORM\Mapping as ORM; | |||||
use Lc\PietroBundle\Model\Thematic\ThematicInterface; | |||||
use Lc\SovBundle\Doctrine\EntityInterface; | |||||
/** | |||||
* @ORM\MappedSuperclass() | |||||
*/ | |||||
abstract class Subthematic implements SubthematicInterface, EntityInterface | |||||
{ | |||||
/** | |||||
* @ORM\Column(type="string", length=255) | |||||
*/ | |||||
protected $name; | |||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\PietroBundle\Model\Thematic\ThematicInterface", inversedBy="subthematic") | |||||
*/ | |||||
protected $thematic; | |||||
public function __toString() | |||||
{ | |||||
return $this->name; | |||||
} | |||||
public function getName(): ?string | |||||
{ | |||||
return $this->name; | |||||
} | |||||
public function setName(string $name): self | |||||
{ | |||||
$this->name = $name; | |||||
return $this; | |||||
} | |||||
public function getThematic(): ?ThematicInterface | |||||
{ | |||||
return $this->thematic; | |||||
} | |||||
public function setThematic(?ThematicInterface $thematic): self | |||||
{ | |||||
$this->thematic = $thematic; | |||||
return $this; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Model\Subthematic; | |||||
interface SubthematicInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Model\Territory; | |||||
use Doctrine\Common\Collections\ArrayCollection; | |||||
use Doctrine\Common\Collections\Collection; | |||||
use Doctrine\ORM\Mapping as ORM; | |||||
use Lc\PietroBundle\Model\IndividualData\IndividualDataInterface; | |||||
use Lc\SovBundle\Doctrine\EntityInterface; | |||||
use Lc\SovBundle\Doctrine\Extension\DevAliasInterface; | |||||
use Lc\SovBundle\Doctrine\Extension\DevAliasTrait; | |||||
/** | |||||
* @ORM\MappedSuperclass() | |||||
*/ | |||||
abstract class Territory implements TerritoryInterface, DevAliasInterface, EntityInterface | |||||
{ | |||||
use DevAliasTrait; | |||||
/** | |||||
* @ORM\Column(type="string", length=255) | |||||
*/ | |||||
protected $name; | |||||
/** | |||||
* @ORM\OneToMany(targetEntity="Lc\PietroBundle\Model\IndividualData\IndividualDataInterface", mappedBy="territory") | |||||
*/ | |||||
protected $individualData; | |||||
public function __construct() | |||||
{ | |||||
$this->individualData = new ArrayCollection(); | |||||
} | |||||
public function __toString() | |||||
{ | |||||
return $this->name; | |||||
} | |||||
public function getName(): ?string | |||||
{ | |||||
return $this->name; | |||||
} | |||||
public function setName(string $name): self | |||||
{ | |||||
$this->name = $name; | |||||
return $this; | |||||
} | |||||
public function getIndividualData(): ?Collection | |||||
{ | |||||
return $this->individualData; | |||||
} | |||||
public function setIndividualData(?IndividualDataInterface $individualData): self | |||||
{ | |||||
$this->individualData = $individualData; | |||||
return $this; | |||||
} | |||||
/** | |||||
* @return Collection|TerritoryInterface[] | |||||
*/ | |||||
public function getTerritory(): Collection | |||||
{ | |||||
return $this->territory; | |||||
} | |||||
public function addTerritory(TerritoryInterface $territory): self | |||||
{ | |||||
if (!$this->territory->contains($territory)) { | |||||
$this->territory[] = $territory; | |||||
$territory->setIndividualData($this); | |||||
} | |||||
return $this; | |||||
} | |||||
public function removeTerritory(TerritoryInterface $territory): self | |||||
{ | |||||
if ($this->territory->removeElement($territory)) { | |||||
// set the owning side to null (unless already changed) | |||||
if ($territory->getIndividualData() === $this) { | |||||
$territory->setIndividualData(null); | |||||
} | |||||
} | |||||
return $this; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Model\Territory; | |||||
interface TerritoryInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Model\Thematic; | |||||
use Doctrine\Common\Collections\ArrayCollection; | |||||
use Doctrine\Common\Collections\Collection; | |||||
use Doctrine\ORM\Mapping as ORM; | |||||
use Lc\PietroBundle\Model\Subthematic\SubthematicInterface; | |||||
use Lc\SovBundle\Doctrine\EntityInterface; | |||||
/** | |||||
* @ORM\MappedSuperclass() | |||||
*/ | |||||
abstract class Thematic implements ThematicInterface, EntityInterface | |||||
{ | |||||
/** | |||||
* @ORM\Column(type="string", length=255) | |||||
*/ | |||||
protected $name; | |||||
/** | |||||
* @ORM\OneToMany(targetEntity="Lc\PietroBundle\Model\Subthematic\SubthematicInterface", mappedBy="thematic", cascade={"persist", "remove"}) | |||||
*/ | |||||
protected $subthematic; | |||||
public function __construct() | |||||
{ | |||||
$this->subthematic = new ArrayCollection(); | |||||
} | |||||
public function __toString() | |||||
{ | |||||
return $this->name; | |||||
} | |||||
public function getName(): ?string | |||||
{ | |||||
return $this->name; | |||||
} | |||||
public function setName(string $name): self | |||||
{ | |||||
$this->name = $name; | |||||
return $this; | |||||
} | |||||
/** | |||||
* @return Collection|SubthematicInterface[] | |||||
*/ | |||||
public function getSubthematic(): Collection | |||||
{ | |||||
return $this->subthematic; | |||||
} | |||||
public function addSubthematic(SubthematicInterface $subthematic): self | |||||
{ | |||||
if (!$this->subthematic->contains($subthematic)) { | |||||
$this->subthematic[] = $subthematic; | |||||
$subthematic->setThematic($this); | |||||
} | |||||
return $this; | |||||
} | |||||
public function removeSubthematic(SubthematicInterface $subthematic): self | |||||
{ | |||||
if ($this->subthematic->removeElement($subthematic)) { | |||||
// set the owning side to null (unless already changed) | |||||
if ($subthematic->getThematic() === $this) { | |||||
$subthematic->setThematic(null); | |||||
} | |||||
} | |||||
return $this; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Model\Thematic; | |||||
interface ThematicInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\Dream; | |||||
use App\Entity\Dream\Dream; | |||||
use Lc\SovBundle\Repository\AbstractRepository; | |||||
use Doctrine\Persistence\ManagerRegistry; | |||||
class DreamRepository extends AbstractRepository | |||||
{ | |||||
public function __construct(ManagerRegistry $registry) | |||||
{ | |||||
parent::__construct($registry, Dream::class); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\Dream; | |||||
use Knp\Component\Pager\PaginatorInterface; | |||||
use Lc\PietroBundle\Repository\Search\SearchRepositoryQuery; | |||||
class DreamRepositoryQuery extends SearchRepositoryQuery | |||||
{ | |||||
public function __construct(DreamRepository $repository, PaginatorInterface $paginator) | |||||
{ | |||||
parent::__construct($repository, $paginator); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\Dream; | |||||
use Lc\PietroBundle\Repository\Search\SearchStore; | |||||
class DreamStore extends SearchStore | |||||
{ | |||||
protected $query; | |||||
public function __construct(DreamRepositoryQuery $query) | |||||
{ | |||||
$this->query = $query; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\IndividualData; | |||||
use App\Entity\IndividualData\IndividualData; | |||||
use Lc\SovBundle\Repository\AbstractRepository; | |||||
use Doctrine\Persistence\ManagerRegistry; | |||||
class IndividualDataRepository extends AbstractRepository | |||||
{ | |||||
public function __construct(ManagerRegistry $registry) | |||||
{ | |||||
parent::__construct($registry, IndividualData::class); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\IndividualData; | |||||
use Knp\Component\Pager\PaginatorInterface; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | |||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||||
class IndividualDataRepositoryQuery extends AbstractRepositoryQuery implements RepositoryQueryInterface | |||||
{ | |||||
public function __construct(IndividualDataRepository $repository, PaginatorInterface $paginator) | |||||
{ | |||||
parent::__construct($repository, 'r', $paginator); | |||||
} | |||||
public function filterByStatus($status) | |||||
{ | |||||
$this->andWhereEqual('status', $status); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\IndividualData; | |||||
use Lc\SovBundle\Repository\AbstractStore; | |||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||||
use Lc\SovBundle\Repository\StoreInterface; | |||||
class IndividualDataStore extends AbstractStore implements StoreInterface | |||||
{ | |||||
public function __construct(IndividualDataRepositoryQuery $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; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\ProjectBoost; | |||||
use App\Entity\ProjectBoost\ProjectBoost; | |||||
use Lc\SovBundle\Repository\AbstractRepository; | |||||
use Doctrine\Persistence\ManagerRegistry; | |||||
class ProjectBoostRepository extends AbstractRepository | |||||
{ | |||||
public function __construct(ManagerRegistry $registry) | |||||
{ | |||||
parent::__construct($registry, ProjectBoost::class); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\ProjectBoost; | |||||
use Knp\Component\Pager\PaginatorInterface; | |||||
use Lc\PietroBundle\Repository\Search\SearchRepositoryQuery; | |||||
class ProjectBoostRepositoryQuery extends SearchRepositoryQuery | |||||
{ | |||||
public function __construct(ProjectBoostRepository $repository, PaginatorInterface $paginator) | |||||
{ | |||||
parent::__construct($repository, $paginator); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\ProjectBoost; | |||||
use Lc\PietroBundle\Repository\Search\SearchStore; | |||||
class ProjectBoostStore extends SearchStore | |||||
{ | |||||
protected $query; | |||||
public function __construct(ProjectBoostRepositoryQuery $query) | |||||
{ | |||||
$this->query = $query; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\ProjectInspiring; | |||||
use App\Entity\ProjectInspiring\ProjectInspiring; | |||||
use Lc\SovBundle\Repository\AbstractRepository; | |||||
use Doctrine\Persistence\ManagerRegistry; | |||||
class ProjectInspiringRepository extends AbstractRepository | |||||
{ | |||||
public function __construct(ManagerRegistry $registry) | |||||
{ | |||||
parent::__construct($registry, ProjectInspiring::class); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\ProjectInspiring; | |||||
use Knp\Component\Pager\PaginatorInterface; | |||||
use Lc\PietroBundle\Repository\Search\SearchRepositoryQuery; | |||||
class ProjectInspiringRepositoryQuery extends SearchRepositoryQuery | |||||
{ | |||||
public function __construct(ProjectInspiringRepository $repository, PaginatorInterface $paginator) | |||||
{ | |||||
parent::__construct($repository, $paginator); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\ProjectInspiring; | |||||
use Lc\PietroBundle\Repository\Search\SearchStore; | |||||
class ProjectInspiringStore extends SearchStore | |||||
{ | |||||
protected $query; | |||||
public function __construct(ProjectInspiringRepositoryQuery $query) | |||||
{ | |||||
$this->query = $query; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\Revolt; | |||||
use App\Entity\Revolt\Revolt; | |||||
use Lc\SovBundle\Repository\AbstractRepository; | |||||
use Doctrine\Persistence\ManagerRegistry; | |||||
class RevoltRepository extends AbstractRepository | |||||
{ | |||||
public function __construct(ManagerRegistry $registry) | |||||
{ | |||||
parent::__construct($registry, Revolt::class); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\Revolt; | |||||
use Knp\Component\Pager\PaginatorInterface; | |||||
use Lc\PietroBundle\Repository\Search\SearchRepositoryQuery; | |||||
class RevoltRepositoryQuery extends SearchRepositoryQuery | |||||
{ | |||||
public function __construct(RevoltRepository $repository, PaginatorInterface $paginator) | |||||
{ | |||||
parent::__construct($repository, $paginator); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\Revolt; | |||||
use Lc\PietroBundle\Repository\Search\SearchStore; | |||||
class RevoltStore extends SearchStore | |||||
{ | |||||
protected $query; | |||||
public function __construct(RevoltRepositoryQuery $query) | |||||
{ | |||||
$this->query = $query; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\Search; | |||||
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; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\Search; | |||||
use Lc\PietroBundle\Model\Thematic\ThematicInterface; | |||||
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(ThematicInterface $thematic, $query = null) | |||||
{ | |||||
$query = $this->createDefaultQuery($query); | |||||
$query->filterByThematic(new ArrayCollection([$thematic])); | |||||
return $query->find(); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\Subthematic; | |||||
use App\Entity\Thematic\Subthematic; | |||||
use Lc\SovBundle\Repository\AbstractRepository; | |||||
use Doctrine\Persistence\ManagerRegistry; | |||||
class SubthematicRepository extends AbstractRepository | |||||
{ | |||||
public function __construct(ManagerRegistry $registry) | |||||
{ | |||||
parent::__construct($registry, Subthematic::class); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\Subthematic; | |||||
use Knp\Component\Pager\PaginatorInterface; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | |||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||||
class SubthematicRepositoryQuery extends AbstractRepositoryQuery implements RepositoryQueryInterface | |||||
{ | |||||
public function __construct(SubthematicRepository $repository, PaginatorInterface $paginator) | |||||
{ | |||||
parent::__construct($repository, 'r', $paginator); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\Subthematic; | |||||
use Lc\SovBundle\Repository\AbstractStore; | |||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||||
use Lc\SovBundle\Repository\StoreInterface; | |||||
class SubthematicStore extends AbstractStore implements StoreInterface | |||||
{ | |||||
public function __construct(SubthematicRepositoryQuery $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; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\Territory; | |||||
use App\Entity\Territory\Territory; | |||||
use Lc\SovBundle\Repository\AbstractRepository; | |||||
use Doctrine\Persistence\ManagerRegistry; | |||||
class TerritoryRepository extends AbstractRepository | |||||
{ | |||||
public function __construct(ManagerRegistry $registry) | |||||
{ | |||||
parent::__construct($registry, Territory::class); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\Territory; | |||||
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); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\Territory; | |||||
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; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\Thematic; | |||||
use App\Entity\Thematic\Thematic; | |||||
use Lc\SovBundle\Repository\AbstractRepository; | |||||
use Doctrine\Persistence\ManagerRegistry; | |||||
class ThematicRepository extends AbstractRepository | |||||
{ | |||||
public function __construct(ManagerRegistry $registry) | |||||
{ | |||||
parent::__construct($registry, Thematic::class); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\Thematic; | |||||
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); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\PietroBundle\Repository\Thematic; | |||||
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; | |||||
} | |||||
} |
services: | |||||
_defaults: | |||||
autowire: true # Automatically injects dependencies in your services. | |||||
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. | |||||
Lc\PietroBundle\: | |||||
resource: '../../' | |||||
exclude: | |||||
- '../../DependencyInjection/' | |||||
- '../../Entity/' | |||||
- '../../Kernel.php' | |||||
- '../../Tests/' | |||||
Lc\PietroBundle\Controller\: | |||||
resource: '../../Controller/' | |||||
tags: [ 'controller.service_arguments' ] |
menu: | |||||
data_individual: Formulaire individuel | |||||
data_individual_new: Créer | |||||
data_individual_validate: Données validées | |||||
data_individual_waiting: Données en attente | |||||
territory: Territoires | |||||
thematic: Thématiques | |||||
subthematic: Sous-thémes | |||||
entity: | |||||
IndividualData: | |||||
label: Données individuel | |||||
label_plurial: Données du formulaire individuel | |||||
fields: | |||||
firstname: Prénom | |||||
lastname: Nom | |||||
territory: Territoire | |||||
revolt: Les révoltes | |||||
dream: Les rêves | |||||
projectBoost: Les projets boostés | |||||
projectinspiring: Les projets inspirants | |||||
resume: Résumé | |||||
nbDream: Rêve(s) | |||||
nbRevolt: Révolte(s) | |||||
nbProjectBoost: Projet(s) boosté(s) | |||||
nbProjectInspiring: Projet(s) inspirant(s) | |||||
Thematic: | |||||
label_plurial: Les thémes | |||||
label: Thématique | |||||
fields: | |||||
name: Nom | |||||
Subthematic: | |||||
label_plurial: Les sous-thémes | |||||
label: Sous-théme | |||||
fields: | |||||
name: Nom | |||||
thematic: Théme | |||||
Territory: | |||||
label_plurial: Les territoires | |||||
label: Territoire | |||||
fields: | |||||
name: Nom | |||||
form: | |||||
field: | |||||
dream: | |||||
description: Description | |||||
thematic: Thématique | |||||
subthematic: Sous-thème | |||||
projectBoost: | |||||
description: Description | |||||
thematic: Thématique | |||||
subthematic: Sous-thème | |||||
projectinspiring: | |||||
description: Description | |||||
thematic: Thématique | |||||
subthematic: Sous-thème | |||||
revolt: | |||||
description: Description | |||||
thematic: Thématique | |||||
subthematic: Sous-thème | |||||
actions: | |||||
export: Export CSV |