src/Entity/Organisation/Organisation.php line 23
<?php
namespace App\Entity\Organisation;
use App\Entity\Common\Coord;
use App\Entity\Common\File;
use App\Entity\Geo\Region;
use App\Entity\Olympiad\Olympiad;
use App\Entity\Organisation\University\OlympPrivilegy;
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 Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Table(name: 'organisation')]
#[ORM\Entity(repositoryClass: 'App\Repository\Organisation\OrganisationRepository')]
#[ORM\HasLifecycleCallbacks]
class Organisation implements UserCreatedInterface, UserUpdatedInterface, HaveUuidInterface
{
use TrackerFields;
use ActiveTrait;
use UuidTrait;
public const TYPE_VUZ = 'vuz';
public const TYPE_OLYMP_CENTER = 'olymp-center';
/**
* @var int|null
*/
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
#[ORM\Column(type: 'integer')]
private $id;
/**
* @var string|null
*/
#[ORM\Column(type: 'string')]
private $caption;
/**
* @var string|null
*/
#[ORM\Column(type: 'text', nullable: true)]
private $description;
/**
* @var Collection
*/
#[ORM\OneToMany(targetEntity: 'App\Entity\Organisation\Organisation', mappedBy: 'parent')]
private $children;
/**
* @var Collection
*/
#[ORM\OneToMany(targetEntity: 'App\Entity\Organisation\User', mappedBy: 'organisation')]
private $users;
/**
* @var self|null
*/
#[ORM\ManyToOne(targetEntity: 'App\Entity\Organisation\Organisation', inversedBy: 'children')]
#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
private $parent;
/**
* @var Type|null
*/
#[ORM\ManyToOne(targetEntity: 'App\Entity\Organisation\Type', inversedBy: 'organisations')]
#[ORM\JoinColumn(nullable: false)]
private $type;
/**
* @var Region|null
*
*/
#[ORM\ManyToOne(targetEntity: 'App\Entity\Geo\Region')]
private $region;
/**
* @var Collection|Page[]
*
*/
#[ORM\OneToMany(targetEntity: 'App\Entity\Organisation\Page', mappedBy: 'organisation')]
private $pages;
/**
* @var File|null
*/
#[ORM\ManyToOne(targetEntity: 'App\Entity\Common\File', cascade: ['remove', 'persist'])]
private $logo;
/**
* @var Coord
*/
#[ORM\Embedded(class: 'App\Entity\Common\Coord')]
private $coord;
/**
* @var ?string
*/
#[ORM\Column(type: 'text', nullable: true)]
private $address;
/**
* @var Collection|Olympiad[]
*
*/
#[ORM\ManyToMany(targetEntity: 'App\Entity\Olympiad\Olympiad', mappedBy: 'organisations')]
private $olympiads;
/**
* @var ArrayCollection|OlympPrivilegy[]
*
*/
#[ORM\OneToMany(targetEntity: 'App\Entity\Organisation\University\OlympPrivilegy', mappedBy: 'organisation')]
private $olymp_privileges;
public function __construct()
{
$this->coord = new Coord();
}
/**
* @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;
}
/**
* @return string|null
*/
public function getDescription(): ?string
{
return $this->description;
}
/**
* @param string|null $description
*/
public function setDescription(?string $description): void
{
$this->description = $description;
}
/**
* @return Collection
*/
public function getChildren(): Collection
{
return $this->children;
}
/**
* @param Collection $children
*/
public function setChildren(Collection $children): void
{
$this->children = $children;
}
/**
* @return Organisation|null
*/
public function getParent(): ?Organisation
{
return $this->parent;
}
/**
* @param Organisation|null $parent
*/
public function setParent(?Organisation $parent): void
{
$this->parent = $parent;
}
/**
* @return Type|null
*/
public function getType(): ?Type
{
return $this->type;
}
/**
* @return string
*/
public function getTypeString(): ?string
{
return $this->getType()->getSlug();
}
/**
* @param Type|null $type
*/
public function setType(?Type $type): void
{
$this->type = $type;
}
/**
* @return Page[]|Collection
*/
public function getPages()
{
return $this->pages;
}
/**
* @param Page[]|Collection $pages
*/
public function setPages($pages): void
{
$this->pages = $pages;
}
/**
* @return File|null
*/
public function getLogo(): ?File
{
return $this->logo;
}
/**
* @param File|null $logo
*/
public function setLogo(?File $logo): void
{
$this->logo = $logo;
// if($logo instanceof Image){
// $owner = new Owner();
// $owner->setType($logo::TYPE_ORGANISATION);
// $owner->setId($this->id);
// }
}
/**
* @return Coord
*/
public function getCoord(): Coord
{
return $this->coord;
}
/**
* @param Coord $coord
*/
public function setCoord(Coord $coord): void
{
$this->coord = $coord;
}
/**
* @return string|null
*/
public function getAddress(): ?string
{
return $this->address;
}
/**
* @param string|null $address
*/
public function setAddress(?string $address): void
{
$this->address = $address;
}
public function isTypeVuz()
{
return $this->type->getSlug() == self::TYPE_VUZ;
}
public function isTypeOc()
{
return $this->type->getSlug() == self::TYPE_OLYMP_CENTER;
}
/**
* @return OlympPrivilegy[]|ArrayCollection
*/
public function getOlympPrivileges()
{
return $this->olymp_privileges;
}
/**
* @param OlympPrivilegy[]|ArrayCollection $olymp_privileges
*/
public function setOlympPrivileges($olymp_privileges): void
{
$this->olymp_privileges = $olymp_privileges;
}
/**
* @return Olympiad[]|Collection
*/
public function getOlympiads()
{
return $this->olympiads;
}
/**
* @param Olympiad[]|Collection $olympiads
*/
public function setOlympiads($olympiads): void
{
$this->olympiads = $olympiads;
}
public function getElasticDistrict()
{
return $this->getRegion() ? $this->getRegion()->getDistrict()->getId() : null;
}
/**
* @return Region|null
*/
public function getRegion(): ?Region
{
return $this->region;
}
/**
* @param Region|null $region
*/
public function setRegion(?Region $region): void
{
$this->region = $region;
}
public function isIndexable()
{
return false===$this->isDeleted();
}
}