src/Entity/Organisation/Organisation.php line 23

  1. <?php
  2. namespace App\Entity\Organisation;
  3. use App\Entity\Common\Coord;
  4. use App\Entity\Common\File;
  5. use App\Entity\Geo\Region;
  6. use App\Entity\Olympiad\Olympiad;
  7. use App\Entity\Organisation\University\OlympPrivilegy;
  8. use App\Entity\Traits\ActiveTrait;
  9. use App\Entity\Traits\TrackerFields;
  10. use App\Entity\Traits\UserCreatedInterface;
  11. use App\Entity\Traits\UserUpdatedInterface;
  12. use App\Entity\UUID\HaveUuidInterface;
  13. use App\Entity\UUID\UuidTrait;
  14. use Doctrine\Common\Collections\ArrayCollection;
  15. use Doctrine\Common\Collections\Collection;
  16. use Doctrine\ORM\Mapping as ORM;
  17. #[ORM\Table(name'organisation')]
  18. #[ORM\Entity(repositoryClass'App\Repository\Organisation\OrganisationRepository')]
  19. #[ORM\HasLifecycleCallbacks]
  20. class Organisation implements UserCreatedInterfaceUserUpdatedInterfaceHaveUuidInterface
  21. {
  22.     use TrackerFields;
  23.     use ActiveTrait;
  24.     use UuidTrait;
  25.     public const TYPE_VUZ 'vuz';
  26.     public const TYPE_OLYMP_CENTER 'olymp-center';
  27.     /**
  28.      * @var int|null
  29.      */
  30.     #[ORM\Id]
  31.     #[ORM\GeneratedValue(strategy'AUTO')]
  32.     #[ORM\Column(type'integer')]
  33.     private $id;
  34.     /**
  35.      * @var string|null
  36.      */
  37.     #[ORM\Column(type'string')]
  38.     private $caption;
  39.     /**
  40.      * @var string|null
  41.      */
  42.     #[ORM\Column(type'text'nullabletrue)]
  43.     private $description;
  44.     /**
  45.      * @var Collection
  46.      */
  47.     #[ORM\OneToMany(targetEntity'App\Entity\Organisation\Organisation'mappedBy'parent')]
  48.     private $children;
  49.     /**
  50.      * @var Collection
  51.      */
  52.     #[ORM\OneToMany(targetEntity'App\Entity\Organisation\User'mappedBy'organisation')]
  53.     private $users;
  54.     /**
  55.      * @var self|null
  56.      */
  57.     #[ORM\ManyToOne(targetEntity'App\Entity\Organisation\Organisation'inversedBy'children')]
  58.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  59.     private $parent;
  60.     /**
  61.      * @var Type|null
  62.      */
  63.     #[ORM\ManyToOne(targetEntity'App\Entity\Organisation\Type'inversedBy'organisations')]
  64.     #[ORM\JoinColumn(nullablefalse)]
  65.     private $type;
  66.     /**
  67.      * @var Region|null
  68.      *
  69.      */
  70.     #[ORM\ManyToOne(targetEntity'App\Entity\Geo\Region')]
  71.     private $region;
  72.     /**
  73.      * @var Collection|Page[]
  74.      *
  75.      */
  76.     #[ORM\OneToMany(targetEntity'App\Entity\Organisation\Page'mappedBy'organisation')]
  77.     private $pages;
  78.     /**
  79.      * @var File|null
  80.      */
  81.     #[ORM\ManyToOne(targetEntity'App\Entity\Common\File'cascade: ['remove''persist'])]
  82.     private $logo;
  83.     /**
  84.      * @var Coord
  85.      */
  86.     #[ORM\Embedded(class: 'App\Entity\Common\Coord')]
  87.     private $coord;
  88.     /**
  89.      * @var ?string
  90.      */
  91.     #[ORM\Column(type'text'nullabletrue)]
  92.     private $address;
  93.     /**
  94.      * @var  Collection|Olympiad[]
  95.      *
  96.      */
  97.     #[ORM\ManyToMany(targetEntity'App\Entity\Olympiad\Olympiad'mappedBy'organisations')]
  98.     private $olympiads;
  99.     /**
  100.      * @var ArrayCollection|OlympPrivilegy[]
  101.      *
  102.      */
  103.     #[ORM\OneToMany(targetEntity'App\Entity\Organisation\University\OlympPrivilegy'mappedBy'organisation')]
  104.     private $olymp_privileges;
  105.     public function __construct()
  106.     {
  107.         $this->coord = new Coord();
  108.     }
  109.     /**
  110.      * @return int|null
  111.      */
  112.     public function getId(): ?int
  113.     {
  114.         return $this->id;
  115.     }
  116.     /**
  117.      * @param int|null $id
  118.      */
  119.     public function setId(?int $id): void
  120.     {
  121.         $this->id $id;
  122.     }
  123.     /**
  124.      * @return string|null
  125.      */
  126.     public function getCaption(): ?string
  127.     {
  128.         return $this->caption;
  129.     }
  130.     /**
  131.      * @param string|null $caption
  132.      */
  133.     public function setCaption(?string $caption): void
  134.     {
  135.         $this->caption $caption;
  136.     }
  137.     /**
  138.      * @return string|null
  139.      */
  140.     public function getDescription(): ?string
  141.     {
  142.         return $this->description;
  143.     }
  144.     /**
  145.      * @param string|null $description
  146.      */
  147.     public function setDescription(?string $description): void
  148.     {
  149.         $this->description $description;
  150.     }
  151.     /**
  152.      * @return Collection
  153.      */
  154.     public function getChildren(): Collection
  155.     {
  156.         return $this->children;
  157.     }
  158.     /**
  159.      * @param Collection $children
  160.      */
  161.     public function setChildren(Collection $children): void
  162.     {
  163.         $this->children $children;
  164.     }
  165.     /**
  166.      * @return Organisation|null
  167.      */
  168.     public function getParent(): ?Organisation
  169.     {
  170.         return $this->parent;
  171.     }
  172.     /**
  173.      * @param Organisation|null $parent
  174.      */
  175.     public function setParent(?Organisation $parent): void
  176.     {
  177.         $this->parent $parent;
  178.     }
  179.     /**
  180.      * @return Type|null
  181.      */
  182.     public function getType(): ?Type
  183.     {
  184.         return $this->type;
  185.     }
  186.     /**
  187.      * @return string
  188.      */
  189.     public function getTypeString(): ?string
  190.     {
  191.         return $this->getType()->getSlug();
  192.     }
  193.     /**
  194.      * @param Type|null $type
  195.      */
  196.     public function setType(?Type $type): void
  197.     {
  198.         $this->type $type;
  199.     }
  200.     /**
  201.      * @return Page[]|Collection
  202.      */
  203.     public function getPages()
  204.     {
  205.         return $this->pages;
  206.     }
  207.     /**
  208.      * @param Page[]|Collection $pages
  209.      */
  210.     public function setPages($pages): void
  211.     {
  212.         $this->pages $pages;
  213.     }
  214.     /**
  215.      * @return File|null
  216.      */
  217.     public function getLogo(): ?File
  218.     {
  219.         return $this->logo;
  220.     }
  221.     /**
  222.      * @param File|null $logo
  223.      */
  224.     public function setLogo(?File $logo): void
  225.     {
  226.         $this->logo $logo;
  227. //        if($logo instanceof Image){
  228. //            $owner = new Owner();
  229. //            $owner->setType($logo::TYPE_ORGANISATION);
  230. //            $owner->setId($this->id);
  231. //        }
  232.     }
  233.     /**
  234.      * @return Coord
  235.      */
  236.     public function getCoord(): Coord
  237.     {
  238.         return $this->coord;
  239.     }
  240.     /**
  241.      * @param Coord $coord
  242.      */
  243.     public function setCoord(Coord $coord): void
  244.     {
  245.         $this->coord $coord;
  246.     }
  247.     /**
  248.      * @return string|null
  249.      */
  250.     public function getAddress(): ?string
  251.     {
  252.         return $this->address;
  253.     }
  254.     /**
  255.      * @param string|null $address
  256.      */
  257.     public function setAddress(?string $address): void
  258.     {
  259.         $this->address $address;
  260.     }
  261.     public function isTypeVuz()
  262.     {
  263.         return $this->type->getSlug() == self::TYPE_VUZ;
  264.     }
  265.     public function isTypeOc()
  266.     {
  267.         return $this->type->getSlug() == self::TYPE_OLYMP_CENTER;
  268.     }
  269.     /**
  270.      * @return OlympPrivilegy[]|ArrayCollection
  271.      */
  272.     public function getOlympPrivileges()
  273.     {
  274.         return $this->olymp_privileges;
  275.     }
  276.     /**
  277.      * @param OlympPrivilegy[]|ArrayCollection $olymp_privileges
  278.      */
  279.     public function setOlympPrivileges($olymp_privileges): void
  280.     {
  281.         $this->olymp_privileges $olymp_privileges;
  282.     }
  283.     /**
  284.      * @return Olympiad[]|Collection
  285.      */
  286.     public function getOlympiads()
  287.     {
  288.         return $this->olympiads;
  289.     }
  290.     /**
  291.      * @param Olympiad[]|Collection $olympiads
  292.      */
  293.     public function setOlympiads($olympiads): void
  294.     {
  295.         $this->olympiads $olympiads;
  296.     }
  297.     public function getElasticDistrict()
  298.     {
  299.         return $this->getRegion() ? $this->getRegion()->getDistrict()->getId() : null;
  300.     }
  301.     /**
  302.      * @return Region|null
  303.      */
  304.     public function getRegion(): ?Region
  305.     {
  306.         return $this->region;
  307.     }
  308.     /**
  309.      * @param Region|null $region
  310.      */
  311.     public function setRegion(?Region $region): void
  312.     {
  313.         $this->region $region;
  314.     }
  315.     public function isIndexable()
  316.     {
  317.         return false===$this->isDeleted();
  318.     }
  319. }