<?phpnamespace App\Entity\Cvs;use Doctrine\ORM\Mapping as ORM;/** * Liens vers les stores (App Store / Google Play) par pays. * * Affichage : * - Version FR du site → 1 seul lien (countryCode=FR, isPrimary=true) * - Version EN du site → bouton avec dropdown listant tous les pays actifs * (isPrimary=true en haut, puis les autres triés par position) * * Règle : si une ligne n'existe pas en BDD, le pays ne s'affiche pas. * La table peut être pré-remplie avec ~150 pays (isActive=false par défaut), * puis on active au fur et à mesure que les apps sont publiées. * * @ORM\Table("cvs_app_store_links", indexes={ * @ORM\Index(name="idx_appstore_platform_active", columns={"platform", "is_active"}), * @ORM\Index(name="idx_appstore_country", columns={"country_code"}), * @ORM\Index(name="idx_appstore_position", columns={"position"}) * }, * uniqueConstraints={ * @ORM\UniqueConstraint(name="uniq_appstore_platform_country", columns={"platform", "country_code"}) * }) * @ORM\Entity(repositoryClass="App\Repository\Cvs\AppStoreLinkRepository") * @ORM\HasLifecycleCallbacks() */class AppStoreLink{ public const PLATFORM_IOS = 'ios'; public const PLATFORM_ANDROID = 'android'; /** * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * Plateforme : 'ios' ou 'android'. * * @ORM\Column(name="platform", type="string", length=16) */ protected $platform; /** * Code pays ISO 3166-1 alpha-2 (US, FR, GB, DE, ES, IT, CA...). * * @ORM\Column(name="country_code", type="string", length=2) */ protected $countryCode; /** * Nom du pays affiché (en anglais par défaut, ex: "United States", "France"). * * @ORM\Column(name="country_label", type="string", length=100) */ protected $countryLabel; /** * Emoji du drapeau (🇺🇸, 🇫🇷, 🇬🇧...). * Optionnel mais sympa pour l'UI. * * @ORM\Column(name="country_flag", type="string", length=16, nullable=true) */ protected $countryFlag; /** * URL vers le store du pays. * Si null → on n'affiche pas, même si isActive=true. * * @ORM\Column(name="url", type="string", length=500, nullable=true) */ protected $url; /** * Si true → le pays est mis en avant (en haut du dropdown, gros bouton sur la version FR). * * @ORM\Column(name="is_primary", type="boolean", options={"default":false}) */ protected $isPrimary = false; /** * Si true → on affiche ce lien. * Permet d'avoir tous les pays en BDD mais d'activer au fur et à mesure. * * @ORM\Column(name="is_active", type="boolean", options={"default":false}) */ protected $isActive = false; /** * Ordre d'affichage dans le dropdown (croissant). * * @ORM\Column(name="position", type="integer", options={"default":100}) */ protected $position = 100; /** * @ORM\Column(name="created_at", type="datetime", nullable=true) */ protected $createdAt; /** * @ORM\Column(name="updated_at", type="datetime", nullable=true) */ protected $updatedAt; /** * @ORM\PrePersist */ public function onPrePersist(): void { $now = new \DateTime(); if (!$this->createdAt) { $this->createdAt = $now; } $this->updatedAt = $now; } /** * @ORM\PreUpdate */ public function onPreUpdate(): void { $this->updatedAt = new \DateTime(); } public function getId(): ?int { return $this->id; } public function getPlatform(): ?string { return $this->platform; } public function setPlatform(string $platform): self { $this->platform = $platform; return $this; } public function getCountryCode(): ?string { return $this->countryCode; } public function setCountryCode(string $code): self { $this->countryCode = strtoupper($code); return $this; } public function getCountryLabel(): ?string { return $this->countryLabel; } public function setCountryLabel(string $label): self { $this->countryLabel = $label; return $this; } public function getCountryFlag(): ?string { return $this->countryFlag; } public function setCountryFlag(?string $flag): self { $this->countryFlag = $flag; return $this; } public function getUrl(): ?string { return $this->url; } public function setUrl(?string $url): self { $this->url = $url; return $this; } public function getIsPrimary(): bool { return (bool) $this->isPrimary; } public function setIsPrimary(bool $v): self { $this->isPrimary = $v; return $this; } public function getIsActive(): bool { return (bool) $this->isActive; } public function setIsActive(bool $v): self { $this->isActive = $v; return $this; } public function getPosition(): int { return $this->position ?? 100; } public function setPosition(int $p): self { $this->position = $p; return $this; } public function getCreatedAt(): ?\DateTime { return $this->createdAt; } public function setCreatedAt(?\DateTime $d): self { $this->createdAt = $d; return $this; } public function getUpdatedAt(): ?\DateTime { return $this->updatedAt; } public function setUpdatedAt(?\DateTime $d): self { $this->updatedAt = $d; return $this; } /** * Helper : un lien est affichable si il est actif ET a une URL. */ public function isDisplayable(): bool { return $this->getIsActive() && !empty($this->getUrl()); }}