Add match call entity
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Entity\Accounting;
|
||||
|
||||
use App\Entity\Interface\AccountingOwnerInterface;
|
||||
use App\Entity\Matchfunding\MatchCall;
|
||||
use App\Entity\Project\Project;
|
||||
use App\Entity\Tipjar;
|
||||
use App\Entity\User\User;
|
||||
@@ -43,6 +44,9 @@ class Accounting
|
||||
#[ORM\OneToOne(mappedBy: 'accounting', cascade: ['persist'])]
|
||||
private ?Tipjar $tipjar = null;
|
||||
|
||||
#[ORM\OneToOne(mappedBy: 'accounting', cascade: ['persist'])]
|
||||
private ?MatchCall $matchCall = null;
|
||||
|
||||
/**
|
||||
* Create a new Accounting entity instance for the given owner.
|
||||
*/
|
||||
@@ -101,6 +105,8 @@ class Accounting
|
||||
return $this->getProject();
|
||||
case Tipjar::class:
|
||||
return $this->getTipjar();
|
||||
case MatchCall::class:
|
||||
return $this->getMatchCall();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -121,6 +127,8 @@ class Accounting
|
||||
return $this->setProject($owner);
|
||||
case Tipjar::class:
|
||||
return $this->setTipjar($owner);
|
||||
case MatchCall::class:
|
||||
return $this->setMatchCall($owner);
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -191,4 +199,21 @@ class Accounting
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMatchCall(): ?MatchCall
|
||||
{
|
||||
return $this->matchCall;
|
||||
}
|
||||
|
||||
public function setMatchCall(MatchCall $matchCall): static
|
||||
{
|
||||
// set the owning side of the relation if necessary
|
||||
if ($matchCall->getAccounting() !== $this) {
|
||||
$matchCall->setAccounting($this);
|
||||
}
|
||||
|
||||
$this->matchCall = $matchCall;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Matchfunding;
|
||||
|
||||
use App\Entity\Accounting\Accounting;
|
||||
use App\Entity\Interface\AccountingOwnerInterface;
|
||||
use App\Entity\User\User;
|
||||
use App\Repository\Matchfunding\MatchCallRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: MatchCallRepository::class)]
|
||||
class MatchCall implements AccountingOwnerInterface
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\OneToOne(inversedBy: 'matchCall', cascade: ['persist'])]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?Accounting $accounting = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, User>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: User::class)]
|
||||
private Collection $managers;
|
||||
|
||||
/**
|
||||
* @var Collection<int, MatchSubmission>
|
||||
*/
|
||||
#[ORM\OneToMany(mappedBy: 'matchCall', targetEntity: MatchSubmission::class)]
|
||||
private Collection $matchSubmissions;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $strategyName = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->accounting = Accounting::of($this);
|
||||
$this->managers = new ArrayCollection();
|
||||
$this->matchSubmissions = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getAccounting(): ?Accounting
|
||||
{
|
||||
return $this->accounting;
|
||||
}
|
||||
|
||||
public function setAccounting(Accounting $accounting): static
|
||||
{
|
||||
$this->accounting = $accounting;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, User>
|
||||
*/
|
||||
public function getManagers(): Collection
|
||||
{
|
||||
return $this->managers;
|
||||
}
|
||||
|
||||
public function addManager(User $manager): static
|
||||
{
|
||||
if (!$this->managers->contains($manager)) {
|
||||
$this->managers->add($manager);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeManager(User $manager): static
|
||||
{
|
||||
$this->managers->removeElement($manager);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, MatchSubmission>
|
||||
*/
|
||||
public function getMatchSubmissions(): Collection
|
||||
{
|
||||
return $this->matchSubmissions;
|
||||
}
|
||||
|
||||
public function addMatchSubmission(MatchSubmission $submission): static
|
||||
{
|
||||
if (!$this->matchSubmissions->contains($submission)) {
|
||||
$this->matchSubmissions->add($submission);
|
||||
$submission->setMatchCall($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeMatchSubmission(MatchSubmission $submission): static
|
||||
{
|
||||
if ($this->matchSubmissions->removeElement($submission)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($submission->getMatchCall() === $this) {
|
||||
$submission->setMatchCall(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStrategyName(): ?string
|
||||
{
|
||||
return $this->strategyName;
|
||||
}
|
||||
|
||||
public function setStrategyName(string $strategyName): static
|
||||
{
|
||||
$this->strategyName = $strategyName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Matchfunding\MatchStrategy;
|
||||
|
||||
use App\Entity\Matchfunding\MatchCall;
|
||||
|
||||
class MatchStrategyLocator
|
||||
{
|
||||
/** @var array<string, MatchStrategyInterface> */
|
||||
@@ -36,4 +38,9 @@ class MatchStrategyLocator
|
||||
|
||||
return $this->strategiesByName[$strategyName];
|
||||
}
|
||||
|
||||
public function getForCall(MatchCall $call): ?MatchStrategyInterface
|
||||
{
|
||||
return $this->get($call->getStrategyName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository\Matchfunding;
|
||||
|
||||
use App\Entity\Matchfunding\MatchCall;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<MatchCall>
|
||||
*/
|
||||
class MatchCallRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, MatchCall::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return MatchCall[] Returns an array of MatchCall objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('m')
|
||||
// ->andWhere('m.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('m.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?MatchCall
|
||||
// {
|
||||
// return $this->createQueryBuilder('m')
|
||||
// ->andWhere('m.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user