瀏覽代碼

Correctifs Workshop

develop
Guillaume 2 年之前
父節點
當前提交
dff2bed758
共有 8 個文件被更改,包括 95 次插入3 次删除
  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 查看文件

{ {
return [ return [
'image', 'image',
'title'
'title',
'color',
]; ];
} }


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

+ 11
- 0
Definition/Field/Workshop/WorkshopThematicFieldDefinition.php 查看文件

]; ];
} }


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

public function configureFields(): array public function configureFields(): array
{ {
return [ return [

+ 17
- 0
Model/Workshop/Type.php 查看文件

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

+ 2
- 1
Model/Workshop/WorkshopThematic.php 查看文件

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;



+ 12
- 0
Repository/Workshop/EntryRepositoryQuery.php 查看文件

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

+ 9
- 0
Repository/Workshop/EntryStore.php 查看文件



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

+ 1
- 1
Repository/Workshop/WorkshopThematicStore.php 查看文件



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



+ 40
- 0
Solver/Workshop/WorkshopSolver.php 查看文件

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 = [];

Loading…
取消
儲存