<?php
namespace App\Entity\Media;
use App\Entity\Media\Document;
use App\Entity\Site\AccessSite;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\Media\ShareCartRepository")
* @ORM\Table(name="shares_carts")
* @ORM\HasLifecycleCallbacks
*/
class ShareCart
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Site\AccessSite", inversedBy="shareCarts")
*/
private $accessSite;
/**
* @ORM\Column(type="string", length=255, nullable=false)
* @Assert\NotBlank()
*/
private $name;
/**
* @ORM\Column(type="string", length=255, nullable=false)
* @Assert\NotBlank()
*/
private $token;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $comment;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Media\Document")
*/
private $documents;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Media\Quality", inversedBy="documents")
* @ORM\JoinColumn(name="quality_id", referencedColumnName="id")
*/
private $quality;
/**
* @ORM\Column(type="array", nullable=true, name="recipients")
*/
private $recipients;
/**
* @ORM\Column(type="datetime", nullable=false, name="expiration_date")
* @Assert\NotBlank()
*/
private $expirationDate;
/**
* @ORM\Column(type="integer", nullable=false, name="copyright_type")
* @Assert\NotBlank()
*/
private $copyrightType = 0;
/**
* @ORM\Column(type="integer", nullable=false, name="flicker_share")
* @Assert\NotBlank()
*/
private $flickerShare = 0;
/**
* @ORM\Column(type="array", nullable=true, name="flicker_album")
*/
private $flickerAlbum;
/**
* @ORM\Column(type="datetime", nullable=false, name="created_date")
* @Gedmo\Timestampable(on="create")
*/
private $createdDate;
/**
* @ORM\Column(type="datetime", nullable=true, name="updated_date")
* @Gedmo\Timestampable(on="update")
*/
private $updatedDate;
/**
* @ORM\Column(type="integer", nullable=true, name="status")
*/
private $status = 1;
public function __construct()
{
$this->documents = new ArrayCollection();
$expirationDate = new \DateTime();
$expirationDate->modify("+1 month");
$this->setExpirationDate($expirationDate);
if(!$this->getId())
$this->setToken(bin2hex(random_bytes(15)));
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getToken(): ?string
{
return $this->token;
}
public function setToken(string $token): self
{
$this->token = $token;
return $this;
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(string $comment): self
{
$this->comment = $comment;
return $this;
}
public function getAccessSite(): ?AccessSite
{
return $this->accessSite;
}
public function setAccessSite(AccessSite $accessSite): self
{
$this->accessSite = $accessSite;
return $this;
}
public function getExpirationDate(): ?\DateTimeInterface
{
return $this->expirationDate;
}
public function setExpirationDate(\DateTimeInterface $expirationDate = null): self
{
$this->expirationDate = $expirationDate;
return $this;
}
public function getUpdatedDate(): ?\DateTimeInterface
{
return $this->updatedDate;
}
public function getCreatedDate(): ?\DateTimeInterface
{
return $this->createdDate;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(?int $status): self
{
$this->status = $status;
return $this;
}
public function getCopyrightType(): ?int
{
return $this->copyrightType;
}
public function setCopyrightType(?int $copyrightType): self
{
$this->copyrightType = $copyrightType;
return $this;
}
public function getFlickerShare(): ?int
{
return $this->flickerShare;
}
public function setFlickerShare(?int $flickerShare): self
{
$this->flickerShare = $flickerShare;
return $this;
}
/**
* @return Collection|Document[]
*/
public function getDocuments(): Collection
{
return $this->documents;
}
public function addDocument(Document $document): self
{
if (!$this->documents->contains($document)) {
$this->documents[] = $document;
}
return $this;
}
public function removeDocument(Document $document): self
{
if ($this->documents->contains($document)) {
$this->documents->removeElement($document);
}
return $this;
}
public function getQuality(): ?Quality
{
return $this->quality;
}
public function setQuality(?Quality $quality): self
{
$this->quality = $quality;
return $this;
}
public function getFlickerAlbum(): ?array
{
return $this->flickerAlbum;
}
public function setFlickerAlbum(?array $flickerAlbum): self
{
$this->flickerAlbum = $flickerAlbum;
return $this;
}
public function getRecipients(): ?array
{
return $this->recipients;
}
public function setRecipients(?array $recipients): self
{
$this->recipients = $recipients;
return $this;
}
}