{ | { | ||||
return [ | return [ | ||||
'image', | 'image', | ||||
'title' | |||||
'title', | |||||
'color', | |||||
]; | ]; | ||||
} | } | ||||
public function configureFields(): array | public function configureFields(): array | ||||
{ | { | ||||
return [ | return [ | ||||
'color' => TextField::new('color'), | |||||
]; | ]; | ||||
} | } | ||||
} | } |
]; | ]; | ||||
} | } | ||||
public function configureForm(): array | |||||
{ | |||||
return [ | |||||
'image', | |||||
'title', | |||||
'description', | |||||
'color', | |||||
'devAlias', | |||||
]; | |||||
} | |||||
public function configureFields(): array | public function configureFields(): array | ||||
{ | { | ||||
return [ | return [ |
*/ | */ | ||||
protected $title; | protected $title; | ||||
/** | |||||
* @ORM\Column(type="string", length=255, nullable=true) | |||||
*/ | |||||
protected $color; | |||||
public function __toString() | public function __toString() | ||||
{ | { | ||||
return $this->getTitle(); | return $this->getTitle(); | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getColor(): ?string | |||||
{ | |||||
return $this->color; | |||||
} | |||||
public function setColor(string $color): self | |||||
{ | |||||
$this->color = $color; | |||||
return $this; | |||||
} | |||||
} | } |
use ImageTrait; | 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; | protected $workshops; | ||||
namespace Lc\PietroBundle\Repository\Workshop; | namespace Lc\PietroBundle\Repository\Workshop; | ||||
use Knp\Component\Pager\PaginatorInterface; | use Knp\Component\Pager\PaginatorInterface; | ||||
use Lc\PietroBundle\Model\Workshop\WorkshopInterface; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | use Lc\SovBundle\Repository\AbstractRepositoryQuery; | ||||
class EntryRepositoryQuery extends AbstractRepositoryQuery | class EntryRepositoryQuery extends AbstractRepositoryQuery | ||||
{ | { | ||||
parent::__construct($repository, 'workshopEntry', $paginator); | 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); | |||||
} | |||||
} | } |
namespace Lc\PietroBundle\Repository\Workshop; | namespace Lc\PietroBundle\Repository\Workshop; | ||||
use Lc\PietroBundle\Model\Workshop\WorkshopInterface; | |||||
use Lc\SovBundle\Repository\AbstractStore; | use Lc\SovBundle\Repository\AbstractStore; | ||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | use Lc\SovBundle\Repository\RepositoryQueryInterface; | ||||
{ | { | ||||
return $query; | return $query; | ||||
} | } | ||||
public function getOneByEmailAndWorkshop(string $email, WorkshopInterface $workshop, $query = null) | |||||
{ | |||||
$query = $this->createDefaultQuery($query); | |||||
$query->filterByEmail($email); | |||||
$query->filterByWorkshop($workshop); | |||||
return $query->findOne(); | |||||
} | |||||
} | } |
public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | ||||
{ | { | ||||
$query->orderBy('id'); | |||||
$query->orderBy('position'); | |||||
return $query; | return $query; | ||||
} | } | ||||
namespace Lc\PietroBundle\Solver\Workshop; | namespace Lc\PietroBundle\Solver\Workshop; | ||||
use Lc\PietroBundle\Model\Workshop\WorkshopInterface; | use Lc\PietroBundle\Model\Workshop\WorkshopInterface; | ||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | |||||
class WorkshopSolver | 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 | public function countEntriesAnimators(WorkshopInterface $workshop): int | ||||
{ | { | ||||
return count($this->getEntriesByIsAnimator($workshop, true)); | return count($this->getEntriesByIsAnimator($workshop, true)); | ||||
return $this->getEntriesByIsAnimator($workshop, false); | return $this->getEntriesByIsAnimator($workshop, false); | ||||
} | } | ||||
public function hasEntryAnimator(WorkshopInterface $workshop): bool | |||||
{ | |||||
return $this->countEntriesAnimators($workshop) > 0; | |||||
} | |||||
public function getEntriesAnimators(WorkshopInterface $workshop) | public function getEntriesAnimators(WorkshopInterface $workshop) | ||||
{ | { | ||||
return $this->getEntriesByIsAnimator($workshop, true); | 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 | public function getEntriesByIsAnimator(WorkshopInterface $workshop, bool $isAnimator): array | ||||
{ | { | ||||
$entryArray = []; | $entryArray = []; |