Bladeren bron

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

develop
charly 3 jaren geleden
bovenliggende
commit
38f3feee69
35 gewijzigde bestanden met toevoegingen van 1257 en 0 verwijderingen
  1. +219
    -0
      Controller/IndividualData/IndividualDataAdminController.php
  2. +26
    -0
      Controller/Subthematic/SubthematicAdminController.php
  3. +23
    -0
      Controller/Territory/TerritoryAdminController.php
  4. +23
    -0
      Controller/Thematic/ThematicAdminController.php
  5. +91
    -0
      Form/Dream/DreamType.php
  6. +92
    -0
      Form/ProjectBoost/ProjectBoostType.php
  7. +91
    -0
      Form/ProjectInspiring/ProjectInspiringType.php
  8. +92
    -0
      Form/Revolt/RevoltType.php
  9. +7
    -0
      Model/AbstractData.php
  10. +15
    -0
      Repository/Dream/DreamRepository.php
  11. +14
    -0
      Repository/Dream/DreamRepositoryQuery.php
  12. +15
    -0
      Repository/Dream/DreamStore.php
  13. +15
    -0
      Repository/IndividualData/IndividualDataRepository.php
  14. +15
    -0
      Repository/IndividualData/IndividualDataRepositoryQuery.php
  15. +33
    -0
      Repository/IndividualData/IndividualDataStore.php
  16. +15
    -0
      Repository/ProjectBoost/ProjectBoostRepository.php
  17. +14
    -0
      Repository/ProjectBoost/ProjectBoostRepositoryQuery.php
  18. +16
    -0
      Repository/ProjectBoost/ProjectBoostStore.php
  19. +15
    -0
      Repository/ProjectInspiring/ProjectInspiringRepository.php
  20. +14
    -0
      Repository/ProjectInspiring/ProjectInspiringRepositoryQuery.php
  21. +15
    -0
      Repository/ProjectInspiring/ProjectInspiringStore.php
  22. +15
    -0
      Repository/Revolt/RevoltRepository.php
  23. +14
    -0
      Repository/Revolt/RevoltRepositoryQuery.php
  24. +15
    -0
      Repository/Revolt/RevoltStore.php
  25. +96
    -0
      Repository/Search/SearchRepositoryQuery.php
  26. +66
    -0
      Repository/Search/SearchStore.php
  27. +15
    -0
      Repository/Subthematic/SubthematicRepository.php
  28. +15
    -0
      Repository/Subthematic/SubthematicRepositoryQuery.php
  29. +34
    -0
      Repository/Subthematic/SubthematicStore.php
  30. +15
    -0
      Repository/Territory/TerritoryRepository.php
  31. +15
    -0
      Repository/Territory/TerritoryRepositoryQuery.php
  32. +34
    -0
      Repository/Territory/TerritoryStore.php
  33. +15
    -0
      Repository/Thematic/ThematicRepository.php
  34. +15
    -0
      Repository/Thematic/ThematicRepositoryQuery.php
  35. +33
    -0
      Repository/Thematic/ThematicStore.php

+ 219
- 0
Controller/IndividualData/IndividualDataAdminController.php Bestand weergeven

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

namespace Lc\PietroBundle\Controller\IndividualData;

use App\Entity\Configuration;
use App\Entity\IndividualData;
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 Lc\PietroBundle\Repository\Dream\DreamStore;
use Lc\PietroBundle\Repository\ProjectBoost\ProjectBoostStore;
use Lc\PietroBundle\Repository\ProjectInspiring\ProjectInspiringStore;
use Lc\PietroBundle\Repository\Revolt\RevoltStore;
use Symfony\Component\HttpFoundation\Request;
use Lc\SovBundle\Controller\AbstractAdminController;
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;

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

+ 26
- 0
Controller/Subthematic/SubthematicAdminController.php Bestand weergeven

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

namespace Lc\PietroBundle\Controller\Subthematic;

use Lc\PietroBundle\Model\Subthematic;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Controller\AbstractAdminController;

class SubthematicAdminController extends AbstractAdminController
{
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')
];
}

}

+ 23
- 0
Controller/Territory/TerritoryAdminController.php Bestand weergeven

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

namespace Lc\PietroBundle\Controller\Territory;

use Lc\PietroBundle\Model\Territory;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Controller\AbstractAdminController;

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

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

+ 23
- 0
Controller/Thematic/ThematicAdminController.php Bestand weergeven

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

namespace Lc\PietroBundle\Controller\Thematic;

use Lc\PietroBundle\Model\Thematic;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Controller\AbstractAdminController as AbstractCrudController;

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

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

}

+ 91
- 0
Form/Dream/DreamType.php Bestand weergeven

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

namespace Lc\PietroBundle\Form\Dream;

use Lc\PietroBundle\Model\Dream;
use Lc\PietroBundle\Model\Subthematic;
use Lc\PietroBundle\Model\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'
]
);
}
}


+ 92
- 0
Form/ProjectBoost/ProjectBoostType.php Bestand weergeven

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

namespace Lc\PietroBundle\Form\ProjectBoost;

use Lc\PietroBundle\Model\ProjectBoost;
use Lc\PietroBundle\Model\Subthematic;
use Lc\PietroBundle\Model\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'
]
);
}
}


+ 91
- 0
Form/ProjectInspiring/ProjectInspiringType.php Bestand weergeven

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

namespace Lc\PietroBundle\Form\ProjectInspiring;

use Lc\PietroBundle\Model\ProjectInspiring;
use Lc\PietroBundle\Model\Subthematic;
use Lc\PietroBundle\Model\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'
]
);
}
}


+ 92
- 0
Form/Revolt/RevoltType.php Bestand weergeven

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

namespace Lc\PietroBundle\Form\Revolt;

use Lc\PietroBundle\Model\Revolt;
use Lc\PietroBundle\Model\Subthematic;
use Lc\PietroBundle\Model\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'
]
);
}
}


+ 7
- 0
Model/AbstractData.php Bestand weergeven

@@ -34,4 +34,11 @@ abstract class AbstractData implements StatusInterface, EntityInterface
self::CATEGORY_LABEL_PROJECTINSPIRING => self::CATEGORY_PROJECTINSPIRING,
];
}

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

return $categoryArray[$label];
}
}

+ 15
- 0
Repository/Dream/DreamRepository.php Bestand weergeven

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

namespace Lc\PietroBundle\Repository\Dream;

use Lc\PietroBundle\Model\Dream;
use Lc\SovBundle\Repository\AbstractRepository;
use Doctrine\Persistence\ManagerRegistry;

class DreamRepository extends AbstractRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Dream::class);
}
}

+ 14
- 0
Repository/Dream/DreamRepositoryQuery.php Bestand weergeven

@@ -0,0 +1,14 @@
<?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);
}
}

+ 15
- 0
Repository/Dream/DreamStore.php Bestand weergeven

@@ -0,0 +1,15 @@
<?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;
}
}

+ 15
- 0
Repository/IndividualData/IndividualDataRepository.php Bestand weergeven

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

namespace Lc\PietroBundle\Repository\IndividualData;

use Lc\PietroBundle\Model\IndividualData;
use Lc\SovBundle\Repository\AbstractRepository;
use Doctrine\Persistence\ManagerRegistry;

class IndividualDataRepository extends AbstractRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, IndividualData::class);
}
}

+ 15
- 0
Repository/IndividualData/IndividualDataRepositoryQuery.php Bestand weergeven

@@ -0,0 +1,15 @@
<?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);
}
}

+ 33
- 0
Repository/IndividualData/IndividualDataStore.php Bestand weergeven

@@ -0,0 +1,33 @@
<?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;
}

}

+ 15
- 0
Repository/ProjectBoost/ProjectBoostRepository.php Bestand weergeven

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

namespace Lc\PietroBundle\Repository\ProjectBoost;

use Lc\PietroBundle\Model\ProjectBoost;
use Lc\SovBundle\Repository\AbstractRepository;
use Doctrine\Persistence\ManagerRegistry;

class ProjectBoostRepository extends AbstractRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, ProjectBoost::class);
}
}

+ 14
- 0
Repository/ProjectBoost/ProjectBoostRepositoryQuery.php Bestand weergeven

@@ -0,0 +1,14 @@
<?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);
}
}

+ 16
- 0
Repository/ProjectBoost/ProjectBoostStore.php Bestand weergeven

@@ -0,0 +1,16 @@
<?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;
}
}

+ 15
- 0
Repository/ProjectInspiring/ProjectInspiringRepository.php Bestand weergeven

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

namespace Lc\PietroBundle\Repository\ProjectInspiring;

use App\Entity\ProjectInspiring;
use Lc\SovBundle\Repository\AbstractRepository;
use Doctrine\Persistence\ManagerRegistry;

class ProjectInspiringRepository extends AbstractRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, ProjectInspiring::class);
}
}

+ 14
- 0
Repository/ProjectInspiring/ProjectInspiringRepositoryQuery.php Bestand weergeven

@@ -0,0 +1,14 @@
<?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);
}
}

+ 15
- 0
Repository/ProjectInspiring/ProjectInspiringStore.php Bestand weergeven

@@ -0,0 +1,15 @@
<?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;
}
}

+ 15
- 0
Repository/Revolt/RevoltRepository.php Bestand weergeven

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

namespace Lc\PietroBundle\Repository\Revolt;

use Lc\PietroBundle\Model\Revolt;
use Lc\SovBundle\Repository\AbstractRepository;
use Doctrine\Persistence\ManagerRegistry;

class RevoltRepository extends AbstractRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Revolt::class);
}
}

+ 14
- 0
Repository/Revolt/RevoltRepositoryQuery.php Bestand weergeven

@@ -0,0 +1,14 @@
<?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);
}
}

+ 15
- 0
Repository/Revolt/RevoltStore.php Bestand weergeven

@@ -0,0 +1,15 @@
<?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;
}
}

+ 96
- 0
Repository/Search/SearchRepositoryQuery.php Bestand weergeven

@@ -0,0 +1,96 @@
<?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;
}
}

+ 66
- 0
Repository/Search/SearchStore.php Bestand weergeven

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

namespace Lc\PietroBundle\Repository\Search;


use Lc\PietroBundle\Model\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();
}

}

+ 15
- 0
Repository/Subthematic/SubthematicRepository.php Bestand weergeven

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

namespace Lc\PietroBundle\Repository\Subthematic;

use Lc\PietroBundle\Model\Subthematic;
use Lc\SovBundle\Repository\AbstractRepository;
use Doctrine\Persistence\ManagerRegistry;

class SubthematicRepository extends AbstractRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Subthematic::class);
}
}

+ 15
- 0
Repository/Subthematic/SubthematicRepositoryQuery.php Bestand weergeven

@@ -0,0 +1,15 @@
<?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);
}
}

+ 34
- 0
Repository/Subthematic/SubthematicStore.php Bestand weergeven

@@ -0,0 +1,34 @@
<?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(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;
}

}

+ 15
- 0
Repository/Territory/TerritoryRepository.php Bestand weergeven

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

namespace Lc\PietroBundle\Repository\Territory;

use Lc\PietroBundle\Model\Territory;
use Lc\SovBundle\Repository\AbstractRepository;
use Doctrine\Persistence\ManagerRegistry;

class TerritoryRepository extends AbstractRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Territory::class);
}
}

+ 15
- 0
Repository/Territory/TerritoryRepositoryQuery.php Bestand weergeven

@@ -0,0 +1,15 @@
<?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);
}
}

+ 34
- 0
Repository/Territory/TerritoryStore.php Bestand weergeven

@@ -0,0 +1,34 @@
<?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;
}

}

+ 15
- 0
Repository/Thematic/ThematicRepository.php Bestand weergeven

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

namespace Lc\PietroBundle\Repository\Thematic;

use Lc\PietroBundle\Model\Thematic;
use Lc\SovBundle\Repository\AbstractRepository;
use Doctrine\Persistence\ManagerRegistry;

class ThematicRepository extends AbstractRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Thematic::class);
}
}

+ 15
- 0
Repository/Thematic/ThematicRepositoryQuery.php Bestand weergeven

@@ -0,0 +1,15 @@
<?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);
}
}

+ 33
- 0
Repository/Thematic/ThematicStore.php Bestand weergeven

@@ -0,0 +1,33 @@
<?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;
}

}

Laden…
Annuleren
Opslaan