src/Entity/Instance.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\InstanceRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * @ORM\Entity(repositoryClass=InstanceRepository::class)
  7.  * @ORM\Table(name="instance")
  8.  */
  9. class Instance
  10. {
  11.     /**
  12.      * @ORM\Id
  13.      * @ORM\GeneratedValue
  14.      * @ORM\Column(type="integer")
  15.      */
  16.     private $id;
  17.     /**
  18.      * @ORM\Column(type="string", length=180, unique=true)
  19.      */
  20.     private $name;
  21.     /**
  22.      * @ORM\Column(type="string", length=180, unique=true)
  23.      */
  24.     private $slug;
  25.     /**
  26.      * @ORM\Column(type="string", length=50)
  27.      */
  28.     private $type;
  29.     /**
  30.      * @ORM\Column(type="string", length=255)
  31.      */
  32.     private $baseUrl;
  33.     /**
  34.      * @ORM\Column(type="string", length=255, nullable=true)
  35.      */
  36.     private $parentName;
  37.     /**
  38.      * @ORM\Column(type="string", length=255, nullable=true)
  39.      */
  40.     private $token;
  41.     /**
  42.      * @ORM\Column(type="string", length=255, nullable=true)
  43.      */
  44.     private $projectId;
  45.     /**
  46.      * @ORM\Column(type="string", length=20, options={"default" = "normal"})
  47.      */
  48.     private $viewMode 'normal';
  49.     /**
  50.      * @ORM\Column(type="string", length=255, nullable=true)
  51.      */
  52.     private $displayTitle;
  53.     /**
  54.      * @ORM\Column(type="text", nullable=true)
  55.      */
  56.     private $displayDescription;
  57.     /**
  58.      * @ORM\Column(type="string", length=1024, nullable=true)
  59.      */
  60.     private $googleMapUrl;
  61.     /**
  62.      * @ORM\Column(type="string", length=1024, nullable=true)
  63.      */
  64.     private $videoUrl;
  65.     /**
  66.      * @ORM\Column(type="string", length=255, nullable=true)
  67.      */
  68.     private $logoPath;
  69.     /**
  70.      * @ORM\Column(type="json")
  71.      */
  72.     private $imageSizes = [];
  73.     /**
  74.      * @ORM\Column(type="datetime_immutable")
  75.      */
  76.     private $createdAt;
  77.     /**
  78.      * @ORM\Column(type="datetime_immutable")
  79.      */
  80.     private $updatedAt;
  81.     public function __construct()
  82.     {
  83.         $now = new \DateTimeImmutable();
  84.         $this->createdAt $now;
  85.         $this->updatedAt $now;
  86.         $this->imageSizes = [400019201366915];
  87.     }
  88.     public function getId(): ?int
  89.     {
  90.         return $this->id;
  91.     }
  92.     public function getName(): ?string
  93.     {
  94.         return $this->name;
  95.     }
  96.     public function setName(string $name): self
  97.     {
  98.         $this->name $name;
  99.         return $this;
  100.     }
  101.     public function getSlug(): ?string
  102.     {
  103.         return $this->slug;
  104.     }
  105.     public function setSlug(string $slug): self
  106.     {
  107.         $this->slug $slug;
  108.         return $this;
  109.     }
  110.     public function getType(): ?string
  111.     {
  112.         return $this->type;
  113.     }
  114.     public function setType(string $type): self
  115.     {
  116.         $this->type $type;
  117.         return $this;
  118.     }
  119.     public function getBaseUrl(): ?string
  120.     {
  121.         return $this->baseUrl;
  122.     }
  123.     public function setBaseUrl(string $baseUrl): self
  124.     {
  125.         $this->baseUrl $baseUrl;
  126.         return $this;
  127.     }
  128.     public function getParentName(): ?string
  129.     {
  130.         return $this->parentName;
  131.     }
  132.     public function setParentName(?string $parentName): self
  133.     {
  134.         $this->parentName $parentName;
  135.         return $this;
  136.     }
  137.     public function getToken(): ?string
  138.     {
  139.         return $this->token;
  140.     }
  141.     public function setToken(?string $token): self
  142.     {
  143.         $this->token $token;
  144.         return $this;
  145.     }
  146.     public function getProjectId(): ?string
  147.     {
  148.         return $this->projectId;
  149.     }
  150.     public function setProjectId(?string $projectId): self
  151.     {
  152.         $this->projectId $projectId;
  153.         return $this;
  154.     }
  155.     public function getViewMode(): string
  156.     {
  157.         return $this->viewMode ?: 'normal';
  158.     }
  159.     public function setViewMode(string $viewMode): self
  160.     {
  161.         if ($viewMode !== 'floor' && $viewMode !== 'normal') {
  162.             $viewMode 'normal';
  163.         }
  164.         $this->viewMode $viewMode;
  165.         return $this;
  166.     }
  167.     public function getDisplayTitle(): ?string
  168.     {
  169.         return $this->displayTitle;
  170.     }
  171.     public function setDisplayTitle(?string $displayTitle): self
  172.     {
  173.         $this->displayTitle $displayTitle;
  174.         return $this;
  175.     }
  176.     public function getDisplayDescription(): ?string
  177.     {
  178.         return $this->displayDescription;
  179.     }
  180.     public function setDisplayDescription(?string $displayDescription): self
  181.     {
  182.         $this->displayDescription $displayDescription;
  183.         return $this;
  184.     }
  185.     public function getGoogleMapUrl(): ?string
  186.     {
  187.         return $this->googleMapUrl;
  188.     }
  189.     public function setGoogleMapUrl(?string $googleMapUrl): self
  190.     {
  191.         $this->googleMapUrl $googleMapUrl;
  192.         return $this;
  193.     }
  194.     public function getVideoUrl(): ?string
  195.     {
  196.         return $this->videoUrl;
  197.     }
  198.     public function setVideoUrl(?string $videoUrl): self
  199.     {
  200.         $this->videoUrl $videoUrl;
  201.         return $this;
  202.     }
  203.     public function getVideoEmbedUrl(): ?string
  204.     {
  205.         $url trim((string) $this->videoUrl);
  206.         if ($url === '') {
  207.             return null;
  208.         }
  209.         $parts parse_url($url);
  210.         if (!\is_array($parts)) {
  211.             return $url;
  212.         }
  213.         $host strtolower((string) ($parts['host'] ?? ''));
  214.         $path = (string) ($parts['path'] ?? '');
  215.         $query = (string) ($parts['query'] ?? '');
  216.         $isYoutube str_contains($host'youtube.com') || str_contains($host'youtu.be');
  217.         if (!$isYoutube) {
  218.             return $url;
  219.         }
  220.         $videoId null;
  221.         if (str_contains($host'youtu.be')) {
  222.             $videoId ltrim($path'/');
  223.         }
  224.         if (!$videoId && str_contains($path'/watch')) {
  225.             parse_str($query$qs);
  226.             if (\is_array($qs) && isset($qs['v'])) {
  227.                 $videoId = (string) $qs['v'];
  228.             }
  229.         }
  230.         if (!$videoId && preg_match('~^/embed/([^/?#]+)~'$path$m)) {
  231.             $videoId = (string) $m[1];
  232.         }
  233.         if (!$videoId && preg_match('~^/shorts/([^/?#]+)~'$path$m)) {
  234.             $videoId = (string) $m[1];
  235.         }
  236.         $videoId $videoId preg_replace('~[^a-zA-Z0-9_-]~'''$videoId) : null;
  237.         if (!$videoId) {
  238.             return $url;
  239.         }
  240.         return 'https://www.youtube-nocookie.com/embed/' $videoId;
  241.     }
  242.     public function getLogoPath(): ?string
  243.     {
  244.         return $this->logoPath;
  245.     }
  246.     public function setLogoPath(?string $logoPath): self
  247.     {
  248.         $this->logoPath $logoPath;
  249.         return $this;
  250.     }
  251.     public function getImageSizes(): array
  252.     {
  253.         // Sizes are fixed and not configurable from the UI
  254.         return [400019201366915];
  255.     }
  256.     public function setImageSizes(array $imageSizes): self
  257.     {
  258.         // Ignore custom input and always keep the fixed set
  259.         $this->imageSizes = [400019201366915];
  260.         return $this;
  261.     }
  262.     public function getCreatedAt(): \DateTimeImmutable
  263.     {
  264.         return $this->createdAt;
  265.     }
  266.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  267.     {
  268.         $this->createdAt $createdAt;
  269.         return $this;
  270.     }
  271.     public function getUpdatedAt(): \DateTimeImmutable
  272.     {
  273.         return $this->updatedAt;
  274.     }
  275.     public function setUpdatedAt(\DateTimeImmutable $updatedAt): self
  276.     {
  277.         $this->updatedAt $updatedAt;
  278.         return $this;
  279.     }
  280. }