Browse Source

Correctifs Workshop

develop
Guillaume 2 years ago
parent
commit
dff2bed758
8 changed files with 95 additions and 3 deletions
  1. +3
    -1
      Definition/Field/Workshop/TypeFieldDefinition.php
  2. +11
    -0
      Definition/Field/Workshop/WorkshopThematicFieldDefinition.php
  3. +17
    -0
      Model/Workshop/Type.php
  4. +2
    -1
      Model/Workshop/WorkshopThematic.php
  5. +12
    -0
      Repository/Workshop/EntryRepositoryQuery.php
  6. +9
    -0
      Repository/Workshop/EntryStore.php
  7. +1
    -1
      Repository/Workshop/WorkshopThematicStore.php
  8. +40
    -0
      Solver/Workshop/WorkshopSolver.php

+ 3
- 1
Definition/Field/Workshop/TypeFieldDefinition.php View File

@@ -24,13 +24,15 @@ class TypeFieldDefinition extends AbstractFieldDefinition
{
return [
'image',
'title'
'title',
'color',
];
}

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

+ 11
- 0
Definition/Field/Workshop/WorkshopThematicFieldDefinition.php View File

@@ -19,6 +19,17 @@ class WorkshopThematicFieldDefinition extends AbstractFieldDefinition
];
}

public function configureForm(): array
{
return [
'image',
'title',
'description',
'color',
'devAlias',
];
}

public function configureFields(): array
{
return [

+ 17
- 0
Model/Workshop/Type.php View File

@@ -18,6 +18,11 @@ abstract class Type implements TypeInterface, EntityInterface
*/
protected $title;

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

public function __toString()
{
return $this->getTitle();
@@ -34,4 +39,16 @@ abstract class Type implements TypeInterface, EntityInterface

return $this;
}

public function getColor(): ?string
{
return $this->color;
}

public function setColor(string $color): self
{
$this->color = $color;

return $this;
}
}

+ 2
- 1
Model/Workshop/WorkshopThematic.php View File

@@ -18,7 +18,8 @@ abstract class WorkshopThematic extends AbstractFullEntity implements WorkshopTh
use ImageTrait;

/**
* @ORM\OneToMany(targetEntity="Lc\PietroBundle\Model\Workshop\WorkshopInterface", mappedBy="thematic", cascade={"persist", "remove"})
* @ORM\OneToMany(targetEntity="Lc\PietroBundle\Model\Workshop\WorkshopInterface", mappedBy="workshopThematic", cascade={"persist", "remove"}, fetch="EAGER")
* @ORM\OrderBy({"position" = "ASC"})
*/
protected $workshops;


+ 12
- 0
Repository/Workshop/EntryRepositoryQuery.php View File

@@ -3,6 +3,7 @@
namespace Lc\PietroBundle\Repository\Workshop;

use Knp\Component\Pager\PaginatorInterface;
use Lc\PietroBundle\Model\Workshop\WorkshopInterface;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class EntryRepositoryQuery extends AbstractRepositoryQuery
@@ -11,4 +12,15 @@ class EntryRepositoryQuery extends AbstractRepositoryQuery
{
parent::__construct($repository, 'workshopEntry', $paginator);
}

public function filterByEmail(string $email)
{
return $this->andWhere('.email LIKE :email')
->setParameter('email', $email);
}

public function filterByWorkshop(WorkshopInterface $workshop)
{
return $this->andWhereEqual('workshop', $workshop);
}
}

+ 9
- 0
Repository/Workshop/EntryStore.php View File

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

namespace Lc\PietroBundle\Repository\Workshop;

use Lc\PietroBundle\Model\Workshop\WorkshopInterface;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

@@ -29,4 +30,12 @@ class EntryStore extends AbstractStore
{
return $query;
}

public function getOneByEmailAndWorkshop(string $email, WorkshopInterface $workshop, $query = null)
{
$query = $this->createDefaultQuery($query);
$query->filterByEmail($email);
$query->filterByWorkshop($workshop);
return $query->findOne();
}
}

+ 1
- 1
Repository/Workshop/WorkshopThematicStore.php View File

@@ -16,7 +16,7 @@ class WorkshopThematicStore extends AbstractStore

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


+ 40
- 0
Solver/Workshop/WorkshopSolver.php View File

@@ -3,9 +3,33 @@
namespace Lc\PietroBundle\Solver\Workshop;

use Lc\PietroBundle\Model\Workshop\WorkshopInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;

class WorkshopSolver
{
protected ParameterBagInterface $parameterBag;

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

public function isComplete(WorkshopInterface $workshop): bool
{
$gauge = $this->parameterBag->get('app.workshop.gauge');
$countEntriesRegistered = $this->countEntriesRegistered($workshop);

return $countEntriesRegistered >= $gauge;
}

public function getRemainingPlaces(WorkshopInterface $workshop)
{
$gauge = $this->parameterBag->get('app.workshop.gauge');
$countEntriesRegistered = $this->countEntriesRegistered($workshop);

return $gauge - $countEntriesRegistered;
}

public function countEntriesAnimators(WorkshopInterface $workshop): int
{
return count($this->getEntriesByIsAnimator($workshop, true));
@@ -21,11 +45,27 @@ class WorkshopSolver
return $this->getEntriesByIsAnimator($workshop, false);
}

public function hasEntryAnimator(WorkshopInterface $workshop): bool
{
return $this->countEntriesAnimators($workshop) > 0;
}

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

public function getOneEntryAnimator(WorkshopInterface $workshop)
{
$entriesAnimatorArray = $this->getEntriesByIsAnimator($workshop, true);

if($entriesAnimatorArray && count($entriesAnimatorArray) > 0) {
return $entriesAnimatorArray[0];
}

return false;
}

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

Loading…
Cancel
Save