Bläddra i källkod

[Backend] Ateliers

develop
Guillaume 2 år sedan
förälder
incheckning
b6f36aa007
39 ändrade filer med 1293 tillägg och 0 borttagningar
  1. +48
    -0
      Container/Workshop/EntryContainer.php
  2. +48
    -0
      Container/Workshop/TypeContainer.php
  3. +57
    -0
      Container/Workshop/WorkshopContainer.php
  4. +48
    -0
      Container/Workshop/WorkshopThematicContainer.php
  5. +28
    -0
      Controller/ControllerTrait.php
  6. +24
    -0
      Controller/Workshop/EntryAdminController.php
  7. +24
    -0
      Controller/Workshop/TypeAdminController.php
  8. +100
    -0
      Controller/Workshop/WorkshopAdminController.php
  9. +24
    -0
      Controller/Workshop/WorkshopThematicAdminController.php
  10. +52
    -0
      Definition/Field/Workshop/EntryFieldDefinition.php
  11. +28
    -0
      Definition/Field/Workshop/TypeFieldDefinition.php
  12. +59
    -0
      Definition/Field/Workshop/WorkshopFieldDefinition.php
  13. +30
    -0
      Definition/Field/Workshop/WorkshopThematicFieldDefinition.php
  14. +16
    -0
      Factory/Workshop/EntryFactory.php
  15. +16
    -0
      Factory/Workshop/TypeFactory.php
  16. +18
    -0
      Factory/Workshop/WorkshopFactory.php
  17. +18
    -0
      Factory/Workshop/WorkshopThematicFactory.php
  18. +137
    -0
      Model/Workshop/Entry.php
  19. +8
    -0
      Model/Workshop/EntryInterface.php
  20. +34
    -0
      Model/Workshop/Type.php
  21. +8
    -0
      Model/Workshop/TypeInterface.php
  22. +90
    -0
      Model/Workshop/Workshop.php
  23. +8
    -0
      Model/Workshop/WorkshopInterface.php
  24. +74
    -0
      Model/Workshop/WorkshopThematic.php
  25. +8
    -0
      Model/Workshop/WorkshopThematicInterface.php
  26. +15
    -0
      Repository/Workshop/EntryRepository.php
  27. +14
    -0
      Repository/Workshop/EntryRepositoryQuery.php
  28. +32
    -0
      Repository/Workshop/EntryStore.php
  29. +15
    -0
      Repository/Workshop/TypeRepository.php
  30. +14
    -0
      Repository/Workshop/TypeRepositoryQuery.php
  31. +32
    -0
      Repository/Workshop/TypeStore.php
  32. +15
    -0
      Repository/Workshop/WorkshopRepository.php
  33. +14
    -0
      Repository/Workshop/WorkshopRepositoryQuery.php
  34. +32
    -0
      Repository/Workshop/WorkshopStore.php
  35. +15
    -0
      Repository/Workshop/WorkshopThematicRepository.php
  36. +14
    -0
      Repository/Workshop/WorkshopThematicRepositoryQuery.php
  37. +32
    -0
      Repository/Workshop/WorkshopThematicStore.php
  38. +3
    -0
      Resources/views/admin/workshop/field/entries.html.twig
  39. +41
    -0
      Solver/Workshop/WorkshopSolver.php

+ 48
- 0
Container/Workshop/EntryContainer.php Visa fil

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

namespace Lc\PietroBundle\Container\Workshop;

use Lc\PietroBundle\Definition\Field\Workshop\EntryFieldDefinition;
use Lc\PietroBundle\Factory\Workshop\EntryFactory;
use Lc\PietroBundle\Repository\Workshop\EntryRepositoryQuery;
use Lc\PietroBundle\Repository\Workshop\EntryStore;

class EntryContainer
{
protected EntryFactory $factory;
protected EntryRepositoryQuery $repositoryQuery;
protected EntryStore $store;
protected EntryFieldDefinition $fieldDefinition;

public function __construct(
EntryFactory $factory,
EntryRepositoryQuery $repositoryQuery,
EntryStore $store,
EntryFieldDefinition $fieldDefinition
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->fieldDefinition = $fieldDefinition;
}

public function getFactory(): EntryFactory
{
return $this->factory;
}

public function getRepositoryQuery(): EntryRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): EntryStore
{
return $this->store;
}

public function getFieldDefinition(): EntryFieldDefinition
{
return $this->fieldDefinition;
}
}

+ 48
- 0
Container/Workshop/TypeContainer.php Visa fil

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

namespace Lc\PietroBundle\Container\Workshop;

use Lc\PietroBundle\Definition\Field\Workshop\TypeFieldDefinition;
use Lc\PietroBundle\Factory\Workshop\TypeFactory;
use Lc\PietroBundle\Repository\Workshop\TypeRepositoryQuery;
use Lc\PietroBundle\Repository\Workshop\TypeStore;

class TypeContainer
{
protected TypeFactory $factory;
protected TypeRepositoryQuery $repositoryQuery;
protected TypeStore $store;
protected TypeFieldDefinition $fieldDefinition;

public function __construct(
TypeFactory $factory,
TypeRepositoryQuery $repositoryQuery,
TypeStore $store,
TypeFieldDefinition $fieldDefinition
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->fieldDefinition = $fieldDefinition;
}

public function getFactory(): TypeFactory
{
return $this->factory;
}

public function getRepositoryQuery(): TypeRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): TypeStore
{
return $this->store;
}

public function getFieldDefinition(): TypeFieldDefinition
{
return $this->fieldDefinition;
}
}

+ 57
- 0
Container/Workshop/WorkshopContainer.php Visa fil

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

namespace Lc\PietroBundle\Container\Workshop;

use Lc\PietroBundle\Definition\Field\Workshop\WorkshopFieldDefinition;
use Lc\PietroBundle\Factory\Workshop\WorkshopFactory;
use Lc\PietroBundle\Repository\Workshop\WorkshopRepositoryQuery;
use Lc\PietroBundle\Repository\Workshop\WorkshopStore;
use Lc\PietroBundle\Solver\Workshop\WorkshopSolver;

class WorkshopContainer
{
protected WorkshopFactory $factory;
protected WorkshopRepositoryQuery $repositoryQuery;
protected WorkshopStore $store;
protected WorkshopFieldDefinition $fieldDefinition;
protected WorkshopSolver $solver;

public function __construct(
WorkshopFactory $factory,
WorkshopRepositoryQuery $repositoryQuery,
WorkshopStore $store,
WorkshopFieldDefinition $fieldDefinition,
WorkshopSolver $solver
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->fieldDefinition = $fieldDefinition;
$this->solver = $solver;
}

public function getFactory(): WorkshopFactory
{
return $this->factory;
}

public function getRepositoryQuery(): WorkshopRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): WorkshopStore
{
return $this->store;
}

public function getFieldDefinition(): WorkshopFieldDefinition
{
return $this->fieldDefinition;
}

public function getSolver(): WorkshopSolver
{
return $this->solver;
}
}

+ 48
- 0
Container/Workshop/WorkshopThematicContainer.php Visa fil

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

namespace Lc\PietroBundle\Container\Workshop;

use Lc\PietroBundle\Definition\Field\Workshop\WorkshopThematicFieldDefinition;
use Lc\PietroBundle\Factory\Workshop\WorkshopThematicFactory;
use Lc\PietroBundle\Repository\Workshop\WorkshopThematicRepositoryQuery;
use Lc\PietroBundle\Repository\Workshop\WorkshopThematicStore;

class WorkshopThematicContainer
{
protected WorkshopThematicFactory $factory;
protected WorkshopThematicRepositoryQuery $repositoryQuery;
protected WorkshopThematicStore $store;
protected WorkshopThematicFieldDefinition $fieldDefinition;

public function __construct(
WorkshopThematicFactory $factory,
WorkshopThematicRepositoryQuery $repositoryQuery,
WorkshopThematicStore $store,
WorkshopThematicFieldDefinition $fieldDefinition
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->fieldDefinition = $fieldDefinition;
}

public function getFactory(): WorkshopThematicFactory
{
return $this->factory;
}

public function getRepositoryQuery(): WorkshopThematicRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): WorkshopThematicStore
{
return $this->store;
}

public function getFieldDefinition(): WorkshopThematicFieldDefinition
{
return $this->fieldDefinition;
}
}

+ 28
- 0
Controller/ControllerTrait.php Visa fil

@@ -10,6 +10,10 @@ use Lc\PietroBundle\Container\Revolt\RevoltContainer;
use Lc\PietroBundle\Container\Subthematic\SubthematicContainer;
use Lc\PietroBundle\Container\Territory\TerritoryContainer;
use Lc\PietroBundle\Container\Thematic\ThematicContainer;
use Lc\PietroBundle\Container\Workshop\EntryContainer;
use Lc\PietroBundle\Container\Workshop\TypeContainer;
use Lc\PietroBundle\Container\Workshop\WorkshopContainer;
use Lc\PietroBundle\Container\Workshop\WorkshopThematicContainer;

trait ControllerTrait
{
@@ -26,6 +30,10 @@ trait ControllerTrait
SubthematicContainer::class => SubthematicContainer::class,
TerritoryContainer::class => TerritoryContainer::class,
ThematicContainer::class => ThematicContainer::class,
WorkshopContainer::class => WorkshopContainer::class,
WorkshopThematicContainer::class => WorkshopThematicContainer::class,
EntryContainer::class => EntryContainer::class,
TypeContainer::class => TypeContainer::class
]
);
}
@@ -69,4 +77,24 @@ trait ControllerTrait
{
return $this->get(ThematicContainer::class);
}

public function getWorkshopContainer(): WorkshopContainer
{
return $this->get(WorkshopContainer::class);
}

public function getWorkshopThematicContainer(): WorkshopThematicContainer
{
return $this->get(WorkshopThematicContainer::class);
}

public function getEntryContainer(): EntryContainer
{
return $this->get(EntryContainer::class);
}

public function getTypeContainer(): TypeContainer
{
return $this->get(TypeContainer::class);
}
}

+ 24
- 0
Controller/Workshop/EntryAdminController.php Visa fil

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

namespace Lc\PietroBundle\Controller\Workshop;

use Lc\PietroBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class EntryAdminController extends AbstractAdminController
{
public function createEntity(string $entityFqcn)
{
return $this->getEntryContainer()->getFactory()->create();
}

public function getRepositoryQuery(): RepositoryQueryInterface
{
return $this->getEntryContainer()->getRepositoryQuery();
}

public function configureFields(string $pageName): iterable
{
return $this->getEntryContainer()->getFieldDefinition()->getFields($pageName);
}
}

+ 24
- 0
Controller/Workshop/TypeAdminController.php Visa fil

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

namespace Lc\PietroBundle\Controller\Workshop;

use Lc\PietroBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class TypeAdminController extends AbstractAdminController
{
public function createEntity(string $entityFqcn)
{
return $this->getTypeContainer()->getFactory()->create();
}

public function getRepositoryQuery(): RepositoryQueryInterface
{
return $this->getTypeContainer()->getRepositoryQuery();
}

public function configureFields(string $pageName): iterable
{
return $this->getTypeContainer()->getFieldDefinition()->getFields($pageName);
}
}

+ 100
- 0
Controller/Workshop/WorkshopAdminController.php Visa fil

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

namespace Lc\PietroBundle\Controller\Workshop;

use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use Lc\PietroBundle\Controller\AbstractAdminController;
use Lc\PietroBundle\Model\Workshop\EntryInterface;
use Lc\SovBundle\Generator\CsvGenerator;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Symfony\Component\HttpFoundation\Request;

abstract class WorkshopAdminController extends AbstractAdminController
{
public function createEntity(string $entityFqcn)
{
return $this->getWorkshopContainer()->getFactory()->create();
}

public function getRepositoryQuery(): RepositoryQueryInterface
{
return $this->getWorkshopContainer()->getRepositoryQuery();
}

public function configureFields(string $pageName): iterable
{
return $this->getWorkshopContainer()->getFieldDefinition()->getFields($pageName);
}

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

$export = Action::new('export', 'actions.export')
->setIcon('fa fa-download')
->linkToCrudAction('exportCsv')
//->setCssClass('in-dropdown')
->setCssClass('btn btn-sm btn-secondary 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_Adresses_Email', false);

$columns = [
'lastname' => 'Nom',
'firstname' => 'Prénom',
'email' => 'Email',
'phone' => 'Téléphone',
'animator' => 'Animateur'
];
$csv->setColumns($columns);
$csv->emptyRow();

$workshopArray = $this->getWorkshopContainer()->getStore()->get();

foreach ($workshopArray as $workshop) {
$data = [
'lastname' => '> '.$workshop->getTitle(),
'firstname' => '',
'email' => '',
'phone' => '',
'animator' => ''
];
$csv->row($data);

foreach($this->getWorkshopContainer()->getSolver()->getEntriesAnimators($workshop) as $entry) {
$this->addEntryExportCsv($csv, $entry, true);
}

foreach($this->getWorkshopContainer()->getSolver()->getEntriesRegistered($workshop) as $entry) {
$this->addEntryExportCsv($csv, $entry, false);
}

$csv->emptyRow();
}

return $csv->getReponse();
}

public function addEntryExportCsv($csv, EntryInterface $entry)
{
$data = [
'lastname' => $entry->getLastname(),
'firstname' => $entry->getFirstname(),
'email' => $entry->getEmail(),
'phone' => $entry->getPhone(),
'animator' => $entry->isAnimator() ? 'Oui' : ''
];

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

+ 24
- 0
Controller/Workshop/WorkshopThematicAdminController.php Visa fil

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

namespace Lc\PietroBundle\Controller\Workshop;

use Lc\PietroBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class WorkshopThematicAdminController extends AbstractAdminController
{
public function createEntity(string $entityFqcn)
{
return $this->getWorkshopThematicContainer()->getFactory()->create();
}

public function getRepositoryQuery(): RepositoryQueryInterface
{
return $this->getWorkshopThematicContainer()->getRepositoryQuery();
}

public function configureFields(string $pageName): iterable
{
return $this->getWorkshopThematicContainer()->getFieldDefinition()->getFields($pageName);
}
}

+ 52
- 0
Definition/Field/Workshop/EntryFieldDefinition.php Visa fil

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

namespace Lc\PietroBundle\Definition\Field\Workshop;

use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\EmailField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\PietroBundle\Repository\Workshop\EntryStore;
use Lc\PietroBundle\Repository\Workshop\WorkshopStore;
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;
use Lc\SovBundle\Field\BooleanField;
use Lc\SovBundle\Translation\TranslatorAdmin;

class EntryFieldDefinition extends AbstractFieldDefinition
{
protected WorkshopStore $workshopStore;

public function __construct(TranslatorAdmin $translatorAdmin, WorkshopStore $workshopStore)
{
parent::__construct($translatorAdmin);
$this->workshopStore = $workshopStore;
}

public function configureIndex(): array
{
return [
'workshop',
'firstname',
'lastname',
'city',
'email',
'phone',
'isAnimator'
];
}

public function configureFields(): array
{
$workshopArray = $this->workshopStore->get();

return [
'workshop' => AssociationField::new('workshop')
->setFormTypeOption('choices', $workshopArray),
'firstname' => TextField::new('firstname'),
'lastname' => TextField::new('lastname'),
'city' => TextField::new('city'),
'email' => EmailField::new('email'),
'phone' => TextField::new('phone'),
'isAnimator' => BooleanField::new('isAnimator'),
];
}
}

+ 28
- 0
Definition/Field/Workshop/TypeFieldDefinition.php Visa fil

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

namespace Lc\PietroBundle\Definition\Field\Workshop;

use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\EmailField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;
use Lc\SovBundle\Field\BooleanField;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\Filter\AssociationFilter;

class TypeFieldDefinition extends AbstractFieldDefinition
{
public function configureIndex(): array
{
return [
'title',
];
}

public function configureFields(): array
{
return [
'title' => TextField::new('title'),
];
}
}

+ 59
- 0
Definition/Field/Workshop/WorkshopFieldDefinition.php Visa fil

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

namespace Lc\PietroBundle\Definition\Field\Workshop;

use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\PietroBundle\Repository\Workshop\WorkshopThematicStore;
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Translation\TranslatorAdmin;

class WorkshopFieldDefinition extends AbstractFieldDefinition
{
protected WorkshopThematicStore $workshopThematicStore;

public function __construct(TranslatorAdmin $translatorAdmin, WorkshopThematicStore $workshopThematicStore)
{
parent::__construct($translatorAdmin);

$this->workshopThematicStore = $workshopThematicStore;
}

public function configureIndex(): array
{
return [
'workshopThematic',
'title',
'entries',
];
}

public function configureForm(): array
{
return [
'workshopThematic',
'type',
'title',
'description',
//'entries'
];
}

public function configureFields(): array
{
$workshopThematicArray = $this->workshopThematicStore->get();

return [
'workshopThematic' => AssociationField::new('workshopThematic')
->setFormTypeOption('choices', $workshopThematicArray),
'type' => AssociationField::new('type'),
'title' => TextField::new('title'),
'description' => TextareaField::new('description'),
'entries' => AssociationField::new('entries')
->setTemplatePath('@LcPietro/admin/workshop/field/entries.html.twig')
];
}
}

+ 30
- 0
Definition/Field/Workshop/WorkshopThematicFieldDefinition.php Visa fil

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

namespace Lc\PietroBundle\Definition\Field\Workshop;

use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\ImageManagerField;

class WorkshopThematicFieldDefinition extends AbstractFieldDefinition
{
public function configureIndex(): array
{
return [
'image',
'title',
];
}

public function configureFields(): array
{
return [
'image' => ImageManagerField::new('image'),
'title' => TextField::new('title'),
'description' => TextareaField::new('description'),
];
}
}

+ 16
- 0
Factory/Workshop/EntryFactory.php Visa fil

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

namespace Lc\PietroBundle\Factory\Workshop;

use App\Entity\Workshop\Entry;
use Lc\SovBundle\Factory\AbstractFactory;

class EntryFactory extends AbstractFactory
{
public function create(): Entry
{
$entry = new Entry();

return $entry;
}
}

+ 16
- 0
Factory/Workshop/TypeFactory.php Visa fil

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

namespace Lc\PietroBundle\Factory\Workshop;

use App\Entity\Workshop\Type;
use Lc\SovBundle\Factory\AbstractFactory;

class TypeFactory extends AbstractFactory
{
public function create(): Type
{
$type = new Type();

return $type;
}
}

+ 18
- 0
Factory/Workshop/WorkshopFactory.php Visa fil

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

namespace Lc\PietroBundle\Factory\Workshop;

use App\Entity\Workshop\Workshop;
use Lc\SovBundle\Factory\AbstractFactory;

class WorkshopFactory extends AbstractFactory
{
public function create(): Workshop
{
$workshop = new Workshop();

$workshop->setStatus(1);

return $workshop;
}
}

+ 18
- 0
Factory/Workshop/WorkshopThematicFactory.php Visa fil

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

namespace Lc\PietroBundle\Factory\Workshop;

use App\Entity\Workshop\WorkshopThematic;
use Lc\SovBundle\Factory\AbstractFactory;

class WorkshopThematicFactory extends AbstractFactory
{
public function create(): WorkshopThematic
{
$workshopThematic = new WorkshopThematic();

$workshopThematic->setStatus(1);

return $workshopThematic;
}
}

+ 137
- 0
Model/Workshop/Entry.php Visa fil

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

namespace Lc\PietroBundle\Model\Workshop;

use Doctrine\ORM\Mapping as ORM;
use Lc\SovBundle\Doctrine\EntityInterface;

/**
* @ORM\MappedSuperclass()
*/
abstract class Entry implements EntryInterface, EntityInterface
{
/**
* @ORM\ManyToOne(targetEntity="Lc\PietroBundle\Model\Workshop\WorkshopInterface", inversedBy="entries")
*/
protected $workshop;

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $lastname;

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $firstname;

/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
protected $city;

/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
protected $phone;

/**
* @ORM\Column(type="string", length=180)
*/
protected $email;

/**
* @ORM\Column(type="boolean")
*/
protected $isAnimator = false;

public function __toString()
{
return $this->getLastname().' '.$this->getFirstname();
}

public function getWorkshop(): ?WorkshopInterface
{
return $this->workshop;
}

public function setWorkshop(WorkshopInterface $workshop): self
{
$this->workshop = $workshop;

return $this;
}

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 getCity(): ?string
{
return $this->city;
}

public function setCity(?string $city): self
{
$this->city = $city;

return $this;
}

public function getEmail(): ?string
{
return $this->email;
}

public function setEmail(string $email): self
{
$this->email = $email;

return $this;
}

public function getPhone(): ?string
{
return $this->phone;
}

public function setPhone(?string $phone): self
{
$this->phone = $phone;

return $this;
}

public function isAnimator(): bool
{
return $this->isAnimator;
}

public function setIsAnimator(bool $isAnimator): self
{
$this->isAnimator = $isAnimator;

return $this;
}

}

+ 8
- 0
Model/Workshop/EntryInterface.php Visa fil

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

namespace Lc\PietroBundle\Model\Workshop;

interface EntryInterface
{

}

+ 34
- 0
Model/Workshop/Type.php Visa fil

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

namespace Lc\PietroBundle\Model\Workshop;

use Doctrine\ORM\Mapping as ORM;
use Lc\SovBundle\Doctrine\EntityInterface;

/**
* @ORM\MappedSuperclass()
*/
abstract class Type implements TypeInterface, EntityInterface
{
/**
* @ORM\Column(type="string", length=255)
*/
protected $title;

public function __toString()
{
return $this->getTitle();
}

public function getTitle(): ?string
{
return $this->title;
}

public function setTitle(string $title): self
{
$this->title = $title;

return $this;
}
}

+ 8
- 0
Model/Workshop/TypeInterface.php Visa fil

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

namespace Lc\PietroBundle\Model\Workshop;

interface TypeInterface
{

}

+ 90
- 0
Model/Workshop/Workshop.php Visa fil

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

namespace Lc\PietroBundle\Model\Workshop;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Lc\SovBundle\Doctrine\EntityInterface;
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;

/**
* @ORM\MappedSuperclass()
*/
abstract class Workshop extends AbstractFullEntity implements WorkshopInterface, EntityInterface
{
/**
* @ORM\ManyToOne(targetEntity="Lc\PietroBundle\Model\Workshop\WorkshopThematicInterface", inversedBy="workshops")
*/
protected $workshopThematic;

/**
* @ORM\ManyToOne(targetEntity="Lc\PietroBundle\Model\Workshop\TypeInterface", inversedBy="workshops")
*/
protected $type;

/**
* @ORM\OneToMany(targetEntity="Lc\PietroBundle\Model\Workshop\EntryInterface", mappedBy="workshop", cascade={"persist", "remove"})
*/
protected $entries;

public function __construct()
{
$this->entries = new ArrayCollection();
}

public function __toString()
{
return $this->getTitle();
}

public function getWorkshopThematic(): ?WorkshopThematicInterface
{
return $this->workshopThematic;
}

public function setWorkshopThematic(WorkshopThematicInterface $workshopThematic): self
{
$this->workshopThematic = $workshopThematic;

return $this;
}

public function getType(): ?TypeInterface
{
return $this->type;
}

public function setType(TypeInterface $type): self
{
$this->type = $type;

return $this;
}

/**
* @return Collection|EntryInterface[]
*/
public function getEntries(): Collection
{
return $this->entries;
}

public function addEntry(EntryInterface $entry): self
{
if (!$this->entries->contains($entry)) {
$this->entries[] = $entry;
}

return $this;
}

public function removeEntry(EntryInterface $entry): self
{
if ($this->entries->contains($entry)) {
$this->entries->removeElement($entry);
}

return $this;
}
}

+ 8
- 0
Model/Workshop/WorkshopInterface.php Visa fil

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

namespace Lc\PietroBundle\Model\Workshop;

interface WorkshopInterface
{

}

+ 74
- 0
Model/Workshop/WorkshopThematic.php Visa fil

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

namespace Lc\PietroBundle\Model\Workshop;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Lc\SovBundle\Doctrine\EntityInterface;
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
use Lc\SovBundle\Model\File\FileInterface;

/**
* @ORM\MappedSuperclass()
*/
abstract class WorkshopThematic extends AbstractFullEntity implements WorkshopThematicInterface, EntityInterface
{
/**
* @ORM\OneToMany(targetEntity="Lc\PietroBundle\Model\Workshop\WorkshopInterface", mappedBy="thematic", cascade={"persist", "remove"})
*/
protected $workshops;

/**
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\File\FileInterface", cascade={"persist", "remove"})
*/
protected $image;

public function __construct()
{
$this->workshops = new ArrayCollection();
}

public function __toString()
{
return $this->getTitle();
}

/**
* @return Collection|WorkshopInterface[]
*/
public function getWorkshops(): Collection
{
return $this->workshops;
}

public function addWorkshop(WorkshopInterface $workshop): self
{
if (!$this->workshops->contains($workshop)) {
$this->workshops[] = $workshop;
}

return $this;
}

public function removeWorkshop(WorkshopInterface $workshop): self
{
if ($this->workshops->contains($workshop)) {
$this->workshops->removeElement($workshop);
}

return $this;
}

public function getImage(): ?FileInterface
{
return $this->image;
}

public function setImage(?FileInterface $image): self
{
$this->image = $image;

return $this;
}
}

+ 8
- 0
Model/Workshop/WorkshopThematicInterface.php Visa fil

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

namespace Lc\PietroBundle\Model\Workshop;

interface WorkshopThematicInterface
{

}

+ 15
- 0
Repository/Workshop/EntryRepository.php Visa fil

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

namespace Lc\PietroBundle\Repository\Workshop;

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

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

+ 14
- 0
Repository/Workshop/EntryRepositoryQuery.php Visa fil

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

namespace Lc\PietroBundle\Repository\Workshop;

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

class EntryRepositoryQuery extends AbstractRepositoryQuery
{
public function __construct(EntryRepository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, 'workshopEntry', $paginator);
}
}

+ 32
- 0
Repository/Workshop/EntryStore.php Visa fil

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

namespace Lc\PietroBundle\Repository\Workshop;

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

class EntryStore extends AbstractStore
{
protected EntryRepositoryQuery $query;

public function __construct(EntryRepositoryQuery $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/Workshop/TypeRepository.php Visa fil

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

namespace Lc\PietroBundle\Repository\Workshop;

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

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

+ 14
- 0
Repository/Workshop/TypeRepositoryQuery.php Visa fil

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

namespace Lc\PietroBundle\Repository\Workshop;

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

class TypeRepositoryQuery extends AbstractRepositoryQuery
{
public function __construct(TypeRepository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, 'workshopType', $paginator);
}
}

+ 32
- 0
Repository/Workshop/TypeStore.php Visa fil

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

namespace Lc\PietroBundle\Repository\Workshop;

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

class TypeStore extends AbstractStore
{
protected TypeRepositoryQuery $query;

public function __construct(TypeRepositoryQuery $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/Workshop/WorkshopRepository.php Visa fil

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

namespace Lc\PietroBundle\Repository\Workshop;

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

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

+ 14
- 0
Repository/Workshop/WorkshopRepositoryQuery.php Visa fil

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

namespace Lc\PietroBundle\Repository\Workshop;

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

class WorkshopRepositoryQuery extends AbstractRepositoryQuery
{
public function __construct(WorkshopRepository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, 'workshop', $paginator);
}
}

+ 32
- 0
Repository/Workshop/WorkshopStore.php Visa fil

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

namespace Lc\PietroBundle\Repository\Workshop;

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

class WorkshopStore extends AbstractStore
{
protected WorkshopRepositoryQuery $query;

public function __construct(WorkshopRepositoryQuery $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/Workshop/WorkshopThematicRepository.php Visa fil

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

namespace Lc\PietroBundle\Repository\Workshop;

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

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

+ 14
- 0
Repository/Workshop/WorkshopThematicRepositoryQuery.php Visa fil

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

namespace Lc\PietroBundle\Repository\Workshop;

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

class WorkshopThematicRepositoryQuery extends AbstractRepositoryQuery
{
public function __construct(WorkshopThematicRepository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, 'workshopThematic', $paginator);
}
}

+ 32
- 0
Repository/Workshop/WorkshopThematicStore.php Visa fil

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

namespace Lc\PietroBundle\Repository\Workshop;

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

class WorkshopThematicStore extends AbstractStore
{
protected WorkshopThematicRepositoryQuery $query;

public function __construct(WorkshopThematicRepositoryQuery $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;
}
}

+ 3
- 0
Resources/views/admin/workshop/field/entries.html.twig Visa fil

@@ -0,0 +1,3 @@
{% set workshop = entity.getInstance() %}
{{ workshop_container.solver.countEntriesRegistered(workshop, false) }} Inscrit(s) <br />
{{ workshop_container.solver.countEntriesAnimators(workshop, true) }} Animateur(s)

+ 41
- 0
Solver/Workshop/WorkshopSolver.php Visa fil

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

namespace Lc\PietroBundle\Solver\Workshop;

use Lc\PietroBundle\Model\Workshop\WorkshopInterface;

class WorkshopSolver
{
public function countEntriesAnimators(WorkshopInterface $workshop): int
{
return count($this->getEntriesByIsAnimator($workshop, true));
}

public function countEntriesRegistered(WorkshopInterface $workshop): int
{
return count($this->getEntriesByIsAnimator($workshop, false));
}

public function getEntriesRegistered(WorkshopInterface $workshop)
{
return $this->getEntriesByIsAnimator($workshop, false);
}

public function getEntriesAnimators(WorkshopInterface $workshop)
{
return $this->getEntriesByIsAnimator($workshop, true);
}

public function getEntriesByIsAnimator(WorkshopInterface $workshop, bool $isAnimator): array
{
$entryArray = [];

foreach($workshop->getEntries() as $entry) {
if($entry->isAnimator() == $isAnimator) {
$entryArray[] = $entry;
}
}

return $entryArray;
}
}

Laddar…
Avbryt
Spara