src/Model/CustomerFile/CustomerFile.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Model\CustomerFile;
  3. use App\Model\CustomerResource\CustomerResource;
  4. use App\Model\Traits\ImportableObjectTrait;
  5. use DateTime;
  6. use Exception;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  11. /**
  12.  * @Vich\Uploadable
  13.  */
  14. class CustomerFile extends CustomerResource
  15. {
  16.     use ImportableObjectTrait;
  17.     /**
  18.      * @Groups({
  19.      *     "product:read",
  20.      *     "list_resource",
  21.      *      "read_resource",
  22.      *     "read", "read_prospect", "read_task", "list","get_folder", "read_mail",
  23.      *     "customer_file:write", "customer_file:update"
  24.      * })
  25.      * @Assert\File(
  26.      *     mimeTypes = {
  27.      *          "image/png",
  28.      *          "image/jpeg",
  29.      *          "image/jpg",
  30.      *          "application/pdf",
  31.      *          "application/msword",
  32.      *          "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
  33.      *          "application/vnd.ms-excel",
  34.      *          "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  35.      *     },
  36.      *     maxSize = "10M",
  37.      *     mimeTypesMessage = "Fichiers autorisés : .jpg, .jpeg, .png .pdf",
  38.      *     maxSizeMessage = "Taille maximale autorisée : 10Mo",
  39.      * )
  40.      * @Vich\UploadableField(mapping="customer_file", fileNameProperty="fileName")
  41.      *
  42.      * @var File|null
  43.      */
  44.     private $customerFile;
  45.     /**
  46.      * @Groups({
  47.      *     "product:read",
  48.      *     "list_resource",
  49.      *      "read_resource","get_folder", "read_mail",
  50.      *     "customer_file:write", "customer_file:update"
  51.      * })
  52.      *
  53.      * @var string|null
  54.      */
  55.     private $fileName;
  56.     /**
  57.      * @var string|null
  58.      * @Groups({
  59.      *     "product:read",
  60.      *     "list_resource",
  61.      *      "read_resource","put_resource",
  62.      *     "read", "read_prospect", "read_task", "list","get_folder", "read_mail",
  63.      *     "customer_file:write", "customer_file:update"
  64.      * })
  65.      */
  66.     private $fileLabel;
  67.     /**
  68.      * @var string|null
  69.      * @Groups({
  70.      *     "product:read",
  71.      *     "list_resource",
  72.      *      "read_resource","put_resource", "read_task", "list","get_folder","read_mail",
  73.      *     "customer_file:write", "customer_file:update"
  74.      * })
  75.      */
  76.     private $realFileName;
  77.     /**
  78.      * @var string|null
  79.      * @Groups({
  80.      *     "product:read",
  81.      *     "list_resource",
  82.      *      "read_resource","get_folder",
  83.      *     "customer_file:write", "customer_file:update"
  84.      * })
  85.      */
  86.     private $prospectId;
  87.     /**
  88.      * @var string|null
  89.      * @Groups({
  90.      *     "product:read",
  91.      *     "list_resource",
  92.      *      "read_resource","get_folder",
  93.      *     "customer_file:write", "customer_file:update"
  94.      * })
  95.      */
  96.     private $taskId;
  97.     /**
  98.      * @var string|null
  99.      * @Groups({
  100.      *     "product:read",
  101.      *     "list_resource",
  102.      *      "read_resource","get_folder",
  103.      *     "customer_file:write", "customer_file:update"
  104.      * })
  105.      */
  106.     private $productId;
  107.     /**
  108.      * @var string|null
  109.      * @Groups({
  110.      *     "product:read",
  111.      *     "list_resource",
  112.      *      "read_resource","get_folder",
  113.      *     "customer_file:write", "customer_file:update"
  114.      * })
  115.      */
  116.     private $quoteId;
  117.     /**
  118.      * @var array|null
  119.      * @Groups({
  120.      *     "product:read",
  121.      *     "list_resource",
  122.      *      "read_resource","get_folder", "read_mail",
  123.      *     "customer_file:write", "customer_file:update"
  124.      * })
  125.      */
  126.     private $mailTypeIds;
  127.     /**
  128.      * @Groups({
  129.      *     "product:read",
  130.      *     "list_resource",
  131.      *      "read_resource",
  132.      *     "read_prospect","get_folder", "read_mail",
  133.      *     "customer_file:write", "customer_file:update"
  134.      * })
  135.      *
  136.      * @var string|null
  137.      */
  138.     private $contentUrl;
  139.     /**
  140.      * @Groups({
  141.      *     "product:read",
  142.      *     "list_resource",
  143.      *      "read_resource",
  144.      *     "read", "read_prospect","read_task", "list","get_folder", "read_mail",
  145.      *     "customer_file:write", "customer_file:update"
  146.      * })
  147.      *
  148.      * @var string|null
  149.      */
  150.     private $downloadLink;
  151.     /**
  152.      * @Groups({
  153.      *     "product:read",
  154.      *     "list_resource",
  155.      *      "read_resource",
  156.      *     "read", "read_prospect","read_task", "list","get_folder", "read_mail",
  157.      *     "customer_file:write", "customer_file:update"
  158.      * })
  159.      *
  160.      * @var string|null
  161.      */
  162.     private $deleteLink;
  163.     /**
  164.      * @var string|null
  165.      * @Groups({
  166.      *     "list_resource",
  167.      *      "read_resource","get_folder",
  168.      *     "customer_file:write", "customer_file:update"
  169.      * })
  170.      */
  171.     private $contactId;
  172.     /**
  173.      * @var string|null
  174.      * @Groups({
  175.      *     "product:read",
  176.      *     "list_resource",
  177.      *      "read_resource","put_resource",
  178.      *     "read", "read_prospect", "read_task", "list","get_folder", "read_mail",
  179.      *     "customer_file:write", "customer_file:update"
  180.      * })
  181.      */
  182.     private $size;
  183.     /**
  184.      * @var bool
  185.      */
  186.     private $shouldDelete false;
  187.     /**
  188.      * @var bool
  189.      * @Groups({
  190.      *     "product:read",
  191.      *     "list_resource",
  192.      *      "read_resource","put_resource",
  193.      *     "read", "read_prospect", "read_task", "list","get_folder", "read_mail",
  194.      *     "customer_file:write", "customer_file:update"
  195.      * })
  196.      */
  197.     private $isQuotePdf false;
  198.     /**
  199.      * @var int|null
  200.      * @Groups({
  201.      *     "product:read",
  202.      *     "list_resource", "read_resource",
  203.      *     "read", "read_prospect", "read_task", "list","get_folder", "read_mail"
  204.      * })
  205.      */
  206.     private $versionNumber;
  207.     /**
  208.      * @return string|null
  209.      */
  210.     public function getFileLabel(): ?string
  211.     {
  212.         return $this->fileLabel;
  213.     }
  214.     /**
  215.      * @param string|null $fileLabel
  216.      *
  217.      * @return CustomerFile
  218.      */
  219.     public function setFileLabel(?string $fileLabel): CustomerFile
  220.     {
  221.         $this->fileLabel $fileLabel;
  222.         return $this;
  223.     }
  224.     /**
  225.      * @return string|null
  226.      */
  227.     public function getRealFileName(): ?string
  228.     {
  229.         return $this->realFileName;
  230.     }
  231.     /**
  232.      * @param string|null $realFileName
  233.      *
  234.      * @return CustomerFile
  235.      */
  236.     public function setRealFileName(?string $realFileName): CustomerFile
  237.     {
  238.         $this->realFileName $realFileName;
  239.         return $this;
  240.     }
  241.     /**
  242.      * @param File|null $customerFile
  243.      *
  244.      * @return $this
  245.      *
  246.      * @throws Exception
  247.      */
  248.     public function setCustomerFile(?File $customerFile): CustomerFile
  249.     {
  250.         $this->customerFile $customerFile;
  251.         if ($customerFile) {
  252.             $this->updatedAt = new DateTime('now');
  253.         }
  254.         return $this;
  255.     }
  256.     /**
  257.      * @return string|null
  258.      */
  259.     public function getFileName(): ?string
  260.     {
  261.         return $this->fileName;
  262.     }
  263.     /**
  264.      * @param string|null $fileName
  265.      *
  266.      * @return CustomerFile
  267.      */
  268.     public function setFileName(?string $fileName): CustomerFile
  269.     {
  270.         $this->fileName $fileName;
  271.         return $this;
  272.     }
  273.     /**
  274.      * @return string|null
  275.      */
  276.     public function getProspectId(): ?string
  277.     {
  278.         return $this->prospectId;
  279.     }
  280.     /**
  281.      * @param string|null $prospectId
  282.      *
  283.      * @return CustomerFile
  284.      */
  285.     public function setProspectId(?string $prospectId): CustomerFile
  286.     {
  287.         $this->prospectId $prospectId;
  288.         return $this;
  289.     }
  290.     /**
  291.      * @return string|null
  292.      */
  293.     public function getTaskId(): ?string
  294.     {
  295.         return $this->taskId;
  296.     }
  297.     /**
  298.      * @param string|null $taskId
  299.      *
  300.      * @return CustomerFile
  301.      */
  302.     public function setTaskId(?string $taskId): CustomerFile
  303.     {
  304.         $this->taskId $taskId;
  305.         return $this;
  306.     }
  307.     /**
  308.      * @return string|null
  309.      */
  310.     public function getProductId(): ?string
  311.     {
  312.         return $this->productId;
  313.     }
  314.     /**
  315.      * @param string|null $productId
  316.      *
  317.      * @return CustomerFile
  318.      */
  319.     public function setProductId(?string $productId): CustomerFile
  320.     {
  321.         $this->productId $productId;
  322.         return $this;
  323.     }
  324.     /**
  325.      * @return string|null
  326.      */
  327.     public function getQuoteId(): ?string
  328.     {
  329.         return $this->quoteId;
  330.     }
  331.     /**
  332.      * @param string|null $quoteId
  333.      *
  334.      * @return $this
  335.      */
  336.     public function setQuoteId(?string $quoteId): self
  337.     {
  338.         $this->quoteId $quoteId;
  339.         return $this;
  340.     }
  341.     /**
  342.      * @return File|null
  343.      */
  344.     public function getCustomerFile(): ?File
  345.     {
  346.         return $this->customerFile;
  347.     }
  348.     /**
  349.      * @return string|null
  350.      */
  351.     public function getContentUrl(): ?string
  352.     {
  353.         return $this->contentUrl;
  354.     }
  355.     /**
  356.      * @param string|null $contentUrl
  357.      *
  358.      * @return CustomerFile
  359.      */
  360.     public function setContentUrl(?string $contentUrl): CustomerFile
  361.     {
  362.         $this->contentUrl $contentUrl;
  363.         return $this;
  364.     }
  365.     /**
  366.      * @return string
  367.      */
  368.     public function __toString(): string
  369.     {
  370.         return $this->contentUrl ?? '';
  371.     }
  372.     /**
  373.      * @return string|null
  374.      */
  375.     public function getDownloadLink(): ?string
  376.     {
  377.         return $this->downloadLink;
  378.     }
  379.     /**
  380.      * @param string|null $downloadLink
  381.      *
  382.      * @return CustomerFile
  383.      */
  384.     public function setDownloadLink(?string $downloadLink): CustomerFile
  385.     {
  386.         $this->downloadLink $downloadLink;
  387.         return $this;
  388.     }
  389.     /**
  390.      * @return string|null
  391.      */
  392.     public function getDeleteLink(): ?string
  393.     {
  394.         return $this->deleteLink;
  395.     }
  396.     /**
  397.      * @param string|null $deleteLink
  398.      *
  399.      * @return CustomerFile
  400.      */
  401.     public function setDeleteLink(?string $deleteLink): CustomerFile
  402.     {
  403.         $this->deleteLink $deleteLink;
  404.         return $this;
  405.     }
  406.     /**
  407.      * @return string|null
  408.      */
  409.     public function getSize(): ?string
  410.     {
  411.         return $this->size;
  412.     }
  413.     /**
  414.      * @param string|null $size
  415.      *
  416.      * @return CustomerFile
  417.      */
  418.     public function setSize(?string $size): CustomerFile
  419.     {
  420.         $this->size $size;
  421.         return $this;
  422.     }
  423.     public function getContactId(): ?string
  424.     {
  425.         return $this->contactId;
  426.     }
  427.     public function setContactId(?string $contactId): self
  428.     {
  429.         $this->contactId $contactId;
  430.         return $this;
  431.     }
  432.     /**
  433.      * @return array|null
  434.      */
  435.     public function getMailTypeIds(): ?array
  436.     {
  437.         return $this->mailTypeIds;
  438.     }
  439.     /**
  440.      * @param array|null $mailTypeIds
  441.      *
  442.      * @return CustomerFile
  443.      */
  444.     public function setMailTypeIds(?array $mailTypeIds): CustomerFile
  445.     {
  446.         $this->mailTypeIds $mailTypeIds;
  447.         return $this;
  448.     }
  449.     /**
  450.      * @return bool
  451.      */
  452.     public function isShouldDelete(): bool
  453.     {
  454.         return $this->shouldDelete;
  455.     }
  456.     /**
  457.      * @param bool $shouldDelete
  458.      *
  459.      * @return self
  460.      */
  461.     public function setShouldDelete(bool $shouldDelete): self
  462.     {
  463.         $this->shouldDelete $shouldDelete;
  464.         return $this;
  465.     }
  466.     /**
  467.      * @return bool
  468.      */
  469.     public function isQuotePdf(): bool
  470.     {
  471.         return $this->isQuotePdf;
  472.     }
  473.     /**
  474.      * @param bool $isQuotePdf
  475.      *
  476.      * @return CustomerFile
  477.      */
  478.     public function setIsQuotePdf(bool $isQuotePdf): CustomerFile
  479.     {
  480.         $this->isQuotePdf $isQuotePdf;
  481.         return $this;
  482.     }
  483.     /**
  484.      * @return int|null
  485.      */
  486.     public function getVersionNumber(): ?int
  487.     {
  488.         return $this->versionNumber;
  489.     }
  490.     /**
  491.      * @param int|null $versionNumber
  492.      *
  493.      * @return self
  494.      */
  495.     public function setVersionNumber(?int $versionNumber): self
  496.     {
  497.         $this->versionNumber $versionNumber;
  498.         return $this;
  499.     }
  500. }