src/Entity/Certificate.php line 22
<?php/** @author Guerby Duval <info@tranzaksyon.com>* @link https://tranzaksyon.com* @copyright You are not allowed to remove this author "Guerby Duval <info@tranzaksyon.com>", the link "https://tranzaksyon.com" neither this copyright.*/namespace App\Entity;use App\Repository\CertificateRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Event\LifecycleEventArgs;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Validator\Constraints\File;use Symfony\Component\Validator\Constraints\NotBlank;use Symfony\Component\Validator\Constraints\NotNull;#[ORM\Entity(repositoryClass: CertificateRepository::class)]#[ORM\HasLifecycleCallbacks]class Certificate{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 255)]#[NotNull]#[File(mimeTypes: ['application/x-pkcs12', 'application/octet-stream'], mimeTypesMessage: 'Tiene que ser un certificado .p12. No {{ type }}')]private ?string $file = null;#[ORM\Column(length: 50)]#[NotBlank]private ?string $password = null;#[ORM\OneToMany(mappedBy: 'certificate', targetEntity: SriInfo::class)]private Collection $sriInfos;#[ORM\Column(length: 255)]private ?string $name = null;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]private ?\DateTimeInterface $expiredDate = null;public function __construct(){$this->sriInfos = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getFile(): ?string{return $this->file;}public function setFile(?string $file): self{$this->file = $file;return $this;}public function getPassword(): ?string{return $this->password;}public function setPassword(string $password): self{$this->password = $password;return $this;}/*** @return Collection<int, SriInfo>*/public function getSriInfos(): Collection{return $this->sriInfos;}public function addSriInfo(SriInfo $sriInfo): self{if (!$this->sriInfos->contains($sriInfo)) {$this->sriInfos->add($sriInfo);$sriInfo->setCertificate($this);}return $this;}public function removeSriInfo(SriInfo $sriInfo): self{if ($this->sriInfos->removeElement($sriInfo)) {// set the owning side to null (unless already changed)if ($sriInfo->getCertificate() === $this) {$sriInfo->setCertificate(null);}}return $this;}public function getName(): ?string{return $this->name;}public function setName(string $name): self{$this->name = $name;return $this;}#[ORM\PreRemove]public function deleteCertificateFile(LifecycleEventArgs $eventArgs){/** @var Certificate $cert */$cert = $eventArgs->getObject();try {if (!empty($cert->getFile()))unlink(__DIR__ . '/../../storage/certificates/' . $cert->getFile());} catch (\Error|\Exception $ex) {}}public function getExpiredDate(): ?\DateTimeInterface{return $this->expiredDate;}public function setExpiredDate(?\DateTimeInterface $expiredDate): self{$this->expiredDate = $expiredDate;return $this;}}