src/Entity/Olympiad/Olympiad.php line 26
<?php
namespace App\Entity\Olympiad;
use App\Entity\Common\DateInterval;
use App\Entity\Common\File;
use App\Entity\Organisation\Organisation;
use App\Entity\Organisation\SuccessHistory;
use App\Entity\Organisation\University\OlympPrivilegy;
use App\Entity\Scholar\Profile;
use App\Entity\Traits\ActiveTrait;
use App\Entity\Traits\TrackerFields;
use App\Entity\Traits\UserCreatedInterface;
use App\Entity\Traits\UserUpdatedInterface;
use App\Entity\UUID\HaveUuidInterface;
use App\Entity\UUID\UuidTrait;
use App\Model\Translation\TranslatableTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
#[ORM\Table(name: 'olympiad')]
#[ORM\Entity(repositoryClass: \App\Repository\Olympiad\OlympiadRepository::class)]
#[ORM\HasLifecycleCallbacks]
class Olympiad implements UserCreatedInterface, UserUpdatedInterface,
HaveUuidInterface, TranslatableInterface
{
use TrackerFields;
use ActiveTrait;
use UuidTrait;
use TranslatableTrait;
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
/**
* @var string|null
*/
#[ORM\Column(type: 'string', nullable: true)]
private $caption;
/**
* @var string|null
*/
#[ORM\Column(type: 'string', nullable: true)]
private $subtitle;
/**
* @var bool
*/
#[ORM\Column(type: 'boolean', options: ['default' => 0])]
private $mainpage = false;
/**
* @var Collection|Discipline[]
*/
#[ORM\JoinTable(name: 'olympiad_discipline_relation')]
#[ORM\ManyToMany(targetEntity: 'App\Entity\Olympiad\Discipline', inversedBy: 'olympiads')]
private $disciplines;
/**
* @var Collection|Grade[]
*
*/
#[ORM\JoinTable(name: 'olympiad_grade_relation')]
#[ORM\ManyToMany(targetEntity: 'App\Entity\Olympiad\Grade', inversedBy: 'olympiads')]
private $grades;
/**
* @var Collection|Stage[]
*
*/
#[ORM\OneToMany(targetEntity: 'App\Entity\Olympiad\Stage', mappedBy: 'olympiad')]
private $stages;
/**
* @var Level|null
*/
#[ORM\ManyToOne(targetEntity: 'App\Entity\Olympiad\Level', inversedBy: 'olympiads')]
#[ORM\JoinColumn(nullable: false)]
private $level;
/**
* @var string|null
*/
#[ORM\Column(type: 'text', nullable: true)]
private ?string $description = null;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $results = null;
/**
* @var Collection|Organisation
*/
#[ORM\JoinTable(name: 'olympiad_organisation_relation')]
#[ORM\ManyToMany(targetEntity: 'App\Entity\Organisation\Organisation', inversedBy: 'olympiads')]
private $organisations;
/**
* @var DateInterval
*/
#[ORM\Embedded(class: \App\Entity\Common\DateInterval::class)]
private $interval;
/**
* @var File|null
*/
#[ORM\ManyToOne(targetEntity: 'App\Entity\Common\File', cascade: ['remove', 'persist'])]
private $logo;
/**
* @var ArrayCollection|OlympPrivilegy[]
*
*/
#[ORM\OneToMany(targetEntity: 'App\Entity\Organisation\University\OlympPrivilegy', mappedBy: 'olympiad')]
private $privileges;
/**
* @var ArrayCollection|Profile[]
*/
#[ORM\ManyToMany(targetEntity: 'App\Entity\Scholar\Profile', mappedBy: 'olympiads')]
private $scholar_profiles;
/**
* @var ArrayCollection|SuccessHistory[]
*/
#[ORM\ManyToMany(targetEntity: 'App\Entity\Organisation\SuccessHistory', mappedBy: 'olympiads')]
private $success_history;
public function __construct()
{
$this->interval = new DateInterval();
$this->disciplines = new ArrayCollection();
$this->stages = new ArrayCollection();
$this->grades = new ArrayCollection();
$this->scholar_profiles = new ArrayCollection();
}
/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @param int|null $id
*/
public function setId(?int $id): void
{
$this->id = $id;
}
/**
* @return string|null
*/
/* public function getCaption(): ?string
{
return $this->caption;
}*/
/**
* @param string|null $caption
*/
/* public function setCaption(?string $caption): void
{
$this->caption = $caption;
}*/
public function getElasticCategory()
{
$res = [];
foreach ($this->getDisciplines() as $disc) {
$res[] = $disc->getCategory()->getId();
}
return $res;
}
/**
* @return Discipline[]|Collection
*/
public function getDisciplines()
{
return $this->disciplines;
}
/**
* @param Discipline[]|Collection $disciplines
*/
public function setDisciplines(Collection $disciplines): void
{
// $this->disciplines->clear();
// dump($this->disciplines, $disciplines);
// $this->disciplines->clear();
if (!$this->disciplines) {
$this->disciplines = new ArrayCollection();
}
foreach ($this->disciplines as $d) {
if ($disciplines->contains($d)) {
continue;
}
$this->disciplines->removeElement($d);
// $d->getOlympiads()->removeElement($this);
}
foreach ($disciplines as $d) {
if ($this->disciplines->contains($d)) {
continue;
}
$this->disciplines->add($d);
}
}
/**
* @return Grade[]|Collection
*/
public function getGrades()
{
return $this->grades;
}
/**
* @param Grade[]|Collection $grades
*/
public function setGrades($grades): void
{
$this->grades = $grades;
}
/**
* @return Level|null
*/
public function getLevel(): ?Level
{
return $this->level;
}
/**
* @param Level|null $level
*/
public function setLevel(?Level $level): void
{
$this->level = $level;
}
/**
* @return string|null
*/
/* public function getDescription(): ?string
{
return $this->description;
}*/
/**
* @param string|null $description
*/
/* public function setDescription(?string $description): void
{
$this->description = $description;
}*/
/**
* @return string|null
*/
/* public function getResults(): ?string
{
return $this->results;
}*/
/**
* @param string|null $results
*/
/* public function setResults(?string $results): void
{
$this->results = $results;
}*/
public function getInterval(): DateInterval
{
return $this->interval;
}
public function setInterval(DateInterval $interval): void
{
$this->interval = $interval;
}
/**
* @return File|null
*/
public function getLogo(): ?File
{
return $this->logo;
}
/**
* @param File|null $logo
*/
public function setLogo(?File $logo): void
{
$this->logo = $logo;
}
/**
* @return Stage[]|Collection
*/
public function getStages()
{
return $this->stages;
}
/**
* @param Stage[]|Collection $stages
*/
public function setStages($stages): void
{
$this->stages = $stages;
}
/**
* @return Profile[]|ArrayCollection
*/
public function getScholarProfiles()
{
return $this->scholar_profiles;
}
/**
* @param Profile[]|ArrayCollection $scholar_profiles
*/
public function setScholarProfiles($scholar_profiles): void
{
$this->scholar_profiles = $scholar_profiles;
}
/**
* @return Organisation|Collection
*/
public function getOrganisations()
{
return $this->organisations;
}
/**
* @param Organisation|Collection $organisations
*/
public function setOrganisations($organisations): void
{
$this->organisations = $organisations;
}
/**
* @return bool
*/
public function isMainpage(): bool
{
return $this->mainpage;
}
/**
* @param bool $mainpage
*/
public function setMainpage(bool $mainpage): void
{
$this->mainpage = $mainpage;
}
}