src/Entity/Adherent/MagasinUrl.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Adherent;
  3. use App\Repository\Adherent\MagasinUrlRepository;
  4. use DateTimeImmutable;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassMagasinUrlRepository::class)]
  9. #[ORM\UniqueConstraint(name'unique_url_type_magasin_value'fields: ['magasin''type'])]
  10. #[ORM\HasLifecycleCallbacks]
  11. class MagasinUrl
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type'integer')]
  16.     private $id;
  17.     #[ORM\Column(type'string'length255nullabletrue)]
  18.     private $type;
  19.     #[ORM\Column(type'text'nullabletrue)]
  20.     private $url;
  21.     #[ORM\Column(type'datetime_immutable'nullabletrue)]
  22.     private $updatedAt;
  23.     #[ORM\ManyToOne(targetEntityMagasin::class, cascade: ['persist'], inversedBy'magasinSocialMedia')]
  24.     #[ORM\JoinColumn(name'magasin'referencedColumnName'k_adherent'nullabletrue)]
  25.     private $magasin;
  26.     #[ORM\OneToMany(mappedBy'MagasinUrl'targetEntityMagasinUrlRedirect::class)]
  27.     private Collection $magasinUrlRedirects;
  28.     #[ORM\Column(nullabletrue)]
  29.     private ?float $avgPosition null;
  30.     #[ORM\Column(nullabletrue)]
  31.     private ?\DateTimeImmutable $positionAt null;
  32.     #[ORM\Column(nullabletrue)]
  33.     private ?float $prevPosition null;
  34.     #[ORM\Column(nullabletrue)]
  35.     private ?float $diffPosition null;
  36.     #[ORM\Column(type'datetime_immutable'nullablefalse)]
  37.     private $createdAt;
  38.     public function __construct()
  39.     {
  40.         $this->createdAt = new \DateTimeImmutable('now');
  41.         $this->magasinUrlRedirects = new ArrayCollection();
  42.     }
  43.     #[ORM\PreUpdate]
  44.     public function onPreUpdateEntity(): void
  45.     {
  46.         $this->updatedAt = new \DateTimeImmutable("now");
  47.     }
  48.     /**
  49.      * @return mixed
  50.      */
  51.     public function getId()
  52.     {
  53.         return $this->id;
  54.     }
  55.     public function setId(mixed $id): void
  56.     {
  57.         $this->id $id;
  58.     }
  59.     /**
  60.      * @return mixed
  61.      */
  62.     public function getType()
  63.     {
  64.         return $this->type;
  65.     }
  66.     public function setType(mixed $type): void
  67.     {
  68.         $this->type $type;
  69.     }
  70.     /**
  71.      * @return mixed
  72.      */
  73.     public function getUrl()
  74.     {
  75.         return $this->url;
  76.     }
  77.     public function setUrl(mixed $url): void
  78.     {
  79.         $this->url $url;
  80.     }
  81.     public function getUpdatedAt(): ?DateTimeImmutable
  82.     {
  83.         return $this->updatedAt;
  84.     }
  85.     public function setUpdatedAt(DateTimeImmutable $updatedAt): void
  86.     {
  87.         $this->updatedAt $updatedAt;
  88.     }
  89.     public function getMagasin(): ?Magasin
  90.     {
  91.         return $this->magasin;
  92.     }
  93.     public function setMagasin(?Magasin $magasin): self
  94.     {
  95.         $this->magasin $magasin;
  96.         return $this;
  97.     }
  98.     /**
  99.      * @return Collection<int, MagasinUrlRedirect>
  100.      */
  101.     public function getMagasinUrlRedirects(): Collection
  102.     {
  103.         return $this->magasinUrlRedirects;
  104.     }
  105.     public function addMagasinUrlRedirect(MagasinUrlRedirect $magasinUrlRedirect): self
  106.     {
  107.         if (!$this->magasinUrlRedirects->contains($magasinUrlRedirect)) {
  108.             $this->magasinUrlRedirects->add($magasinUrlRedirect);
  109.             $magasinUrlRedirect->setMagasinUrl($this);
  110.         }
  111.         return $this;
  112.     }
  113.     public function removeMagasinUrlRedirect(MagasinUrlRedirect $magasinUrlRedirect): self
  114.     {
  115.         if ($this->magasinUrlRedirects->removeElement($magasinUrlRedirect)) {
  116.             // set the owning side to null (unless already changed)
  117.             if ($magasinUrlRedirect->getMagasinUrl() === $this) {
  118.                 $magasinUrlRedirect->setMagasinUrl(null);
  119.             }
  120.         }
  121.         return $this;
  122.     }
  123.     public function getAvgPosition(): ?float
  124.     {
  125.         return $this->avgPosition;
  126.     }
  127.     public function setAvgPosition(?float $avgPosition): self
  128.     {
  129.         $this->avgPosition $avgPosition;
  130.         return $this;
  131.     }
  132.     public function getPositionAt(): ?\DateTimeImmutable
  133.     {
  134.         return $this->positionAt;
  135.     }
  136.     public function setPositionAt(?\DateTimeImmutable $positionAt): self
  137.     {
  138.         $this->positionAt $positionAt;
  139.         return $this;
  140.     }
  141.     public function getPrevPosition(): ?float
  142.     {
  143.         return $this->prevPosition;
  144.     }
  145.     public function setPrevPosition(?float $prevPosition): self
  146.     {
  147.         $this->prevPosition $prevPosition;
  148.         return $this;
  149.     }
  150.     public function getDiffPosition(): ?float
  151.     {
  152.         return $this->diffPosition;
  153.     }
  154.     public function setDiffPosition(?float $diffPosition): self
  155.     {
  156.         $this->diffPosition $diffPosition;
  157.         return $this;
  158.     }
  159.     public function getCreatedAt(): \DateTimeImmutable
  160.     {
  161.         return $this->createdAt;
  162.     }
  163.     public function setCreatedAt(\DateTimeImmutable $createdAt): void
  164.     {
  165.         $this->createdAt $createdAt;
  166.     }
  167. }