@@ -24,13 +24,15 @@ class TypeFieldDefinition extends AbstractFieldDefinition | |||
{ | |||
return [ | |||
'image', | |||
'title' | |||
'title', | |||
'color', | |||
]; | |||
} | |||
public function configureFields(): array | |||
{ | |||
return [ | |||
'color' => TextField::new('color'), | |||
]; | |||
} | |||
} |
@@ -19,6 +19,17 @@ class WorkshopThematicFieldDefinition extends AbstractFieldDefinition | |||
]; | |||
} | |||
public function configureForm(): array | |||
{ | |||
return [ | |||
'image', | |||
'title', | |||
'description', | |||
'color', | |||
'devAlias', | |||
]; | |||
} | |||
public function configureFields(): array | |||
{ | |||
return [ |
@@ -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; | |||
} | |||
} |
@@ -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; | |||
@@ -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); | |||
} | |||
} |
@@ -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(); | |||
} | |||
} |
@@ -16,7 +16,7 @@ class WorkshopThematicStore extends AbstractStore | |||
public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | |||
{ | |||
$query->orderBy('id'); | |||
$query->orderBy('position'); | |||
return $query; | |||
} | |||
@@ -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 = []; |