src/Entity/Customer.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CustomerRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Doctrine\ORM\PersistentCollection;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. use Monolog\DateTimeImmutable;
  10. use function PHPUnit\Framework\objectEquals;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use Symfony\Component\Serializer\Annotation\MaxDepth;
  13. use Symfony\Component\Serializer\Serializer;
  14. use Symfony\Component\Serializer\Annotation\Ignore;
  15. /**
  16.  * @ORM\Entity(repositoryClass=CustomerRepository::class)
  17.  */
  18. class Customer
  19. {
  20. //    // Certificate Document Subscriber
  21. //    // ________________________________________________________________________________________________________
  22. //
  23. //    private $serviceArgumentFileDirs = [];
  24. //
  25. //    # private $documentManagerController;
  26. //    private function getServiceArgumentFileDirs(): array { return $this->serviceArgumentFileDirs;  }
  27. //
  28. //    /**
  29. //     * @param $serviceArgumentFileFetchDir
  30. //     * Manage from EventSubscriber
  31. //     */
  32. //    public function setServiceArgumentFileDirs( $serviceArgumentFileFetchDir ): void {
  33. //        $this->serviceArgumentFileDirs = [
  34. //            "fetch" => $serviceArgumentFileFetchDir
  35. //        ];
  36. //    }
  37. //    // ________________________________________________________________________________________________________
  38.     /**
  39.      * @ORM\Id
  40.      * @ORM\GeneratedValue
  41.      * @ORM\Column(type="integer")
  42.      * @Groups({
  43.      *     "customer.list.base",
  44.      *     "customer.manage.base",
  45.      *     "worker.actually.activity",
  46.      *     "timesheet.for.stakeholder",
  47.      *     "customer.selected.project",
  48.      *
  49.      *     "customer.base",
  50.      *     "customer.core", "customer@core"
  51.      * })
  52.      */
  53.     private $id;
  54.     /**
  55.      * @ORM\Column(type="string", length=128)
  56.      * @Groups({
  57.      *     "customer.list.base",
  58.      *     "customer.manage.base",
  59.      *     "worker.actually.activity",
  60.      *     "timesheet.for.stakeholder",
  61.      *     "customer.selected.project",
  62.      *
  63.      *     "customer.base",
  64.      *     "customer.core", "customer@core"
  65.      * })
  66.      */
  67.     private $company;
  68.     /**
  69.      * @ORM\Column(type="string", unique=true, nullable=true)
  70.      * @Gedmo\Slug(fields={"company"})
  71.      * @Groups({
  72.      *     "customer.list.base",
  73.      *     "customer.manage.base",
  74.      *     "worker.actually.activity",
  75.      *     "customer.selected.project"
  76.      * })
  77.      */
  78.     private $slug;
  79.     /**
  80.      * @ORM\ManyToOne(targetEntity=Countries::class)
  81.      * @Groups({"customer.list.base", "customer.manage.base"})
  82.      */
  83.     private $country;
  84.     /**
  85.      * @ORM\Column(type="string", length=255, nullable=true)
  86.      * @Groups({"customer.list.base", "customer.manage.base"})
  87.      */
  88.     private $tel;
  89.     /**
  90.      * @ORM\Column(type="text", nullable=true)
  91.      * @Groups({"customer.list.base", "customer.manage.base"})
  92.      */
  93.     private $company_logo;
  94.     /**
  95.      * ____________________________________________________________________________________________________
  96.      * Event Listener Prop
  97.      * This prop Update during event.listener
  98.      * @Groups({"customer.list.base", "customer.manage.base"})
  99.      */
  100.     private $logo_image_full_path;
  101.     /**
  102.      * Event Listener Prop
  103.      * This prop Update during event.listener
  104.      * @param string $logo_image_full_path
  105.      * @return Customer|null
  106.      */
  107.     public function setLogoImageFullPathstring $logo_image_full_path ): ?self {
  108.         $this->logo_image_full_path $logo_image_full_path// $this->getServiceArgumentFileDirs()['fetch'] . DIRECTORY_SEPARATOR . $this->getCompanyLogo();
  109.         return $this;
  110.     }
  111.     /**
  112.      * Event Listener Prop
  113.      */
  114.     public function getLogoImageFullPath(): ?string /* $this->getServiceArgumentFileDirs()['fetch'] . DIRECTORY_SEPARATOR . $this->getCompanyLogo(); */
  115.         return $this->logo_image_full_path;
  116.     }
  117.     //  ____________________________________________________________________________________________________
  118.     /**
  119.      * @ORM\OneToMany(targetEntity=ProjectStakeholders::class, mappedBy="customer", fetch="EXTRA_LAZY")
  120.      * @ORM\OrderBy({"id":"DESC"})
  121.      * @ORM\JoinColumn(onDelete="CASCADE")
  122.      * @Groups({
  123.      *     "customer.joined.projects",
  124.      *     "worker.join.to.project",
  125.      *     "worker.manage.selectable.stakeholder.projects",
  126.      *     "timesheet.for.customer"
  127.      * })
  128.      */
  129.     private $project_stakeholders;
  130.     /**
  131.      * @ORM\OneToMany(targetEntity=WorkerActivities::class, mappedBy="customer", fetch="EXTRA_LAZY")
  132.      * @Groups({"customer.smart.active.employees"})
  133.      * @ORM\JoinColumn(onDelete="CASCADE")
  134.      */
  135.     private $worker_activities;
  136.     /**
  137.      * Ignore()
  138.      * @ORM\OneToMany(targetEntity=CustomerCertificates::class, mappedBy="customer", cascade={"persist", "remove"}, fetch="EXTRA_LAZY")
  139.      * @Groups({"customer.manage.base"})
  140.      * @ORM\JoinColumn(onDelete="CASCADE")
  141.      */
  142.     private $customer_certificates;
  143.     /**
  144.      * @ORM\Column(type="string", length=255, nullable=true)
  145.      * @Groups({"customer.list.base", "customer.manage.base"})
  146.      */
  147.     private $city;
  148.     /**
  149.      * @ORM\OneToOne(targetEntity=Administrative::class, mappedBy="paired_customer", cascade={"persist", "remove"})
  150.      * @Groups({"customer.manage.base", "customer.list.base", "worker.actually.activity"})
  151.      */
  152.     private $administrative;
  153.     public function __construct()
  154.     {
  155.         $this->project_stakeholders = new ArrayCollection();
  156.         $this->worker_activities = new ArrayCollection();
  157.         $this->customer_certificates = new ArrayCollection();
  158.     }
  159.     public function getId(): ?int
  160.     {
  161.         return $this->id;
  162.     }
  163.     public function getCompany(): ?string
  164.     {
  165.         return $this->company;
  166.     }
  167.     public function setCompany(string $company): self
  168.     {
  169.         $this->company $company;
  170.         return $this;
  171.     }
  172.     public function getSlug(): ?string
  173.     {
  174.         return $this->slug;
  175.     }
  176.     public function setSlug(?string $slug): self
  177.     {
  178.         $this->slug $slug;
  179.         return $this;
  180.     }
  181.     public function getCountry(): ?Countries
  182.     {
  183.         return $this->country;
  184.     }
  185.     public function setCountry(?Countries $country): self
  186.     {
  187.         $this->country $country;
  188.         return $this;
  189.     }
  190.     public function getTel(): ?string
  191.     {
  192.         return $this->tel;
  193.     }
  194.     public function setTel(string $tel): self
  195.     {
  196.         $this->tel $tel;
  197.         return $this;
  198.     }
  199.     public function getCompanyLogo(): ?string
  200.     {
  201.         return $this->company_logo;
  202.     }
  203.     public function setCompanyLogo(?string $company_logo): self
  204.     {
  205.         $this->company_logo $company_logo;
  206.         return $this;
  207.     }
  208.     /**
  209.      * @return Collection<int, ProjectStakeholders>
  210.      */
  211.     public function getProjectStakeholders(): Collection
  212.     {
  213.         return $this->project_stakeholders;
  214.     }
  215.     /**
  216.      * @return Collection<int, WorkerActivities>
  217.      */
  218.     public function getWorkerActivities(): Collection
  219.     {
  220.         return new ArrayCollection($this->worker_activities->filter( function ( /**@var $workerActivity WorkerActivities*/ $workerActivity ){
  221.             return $workerActivity->getEntryAt() && ( is_null$workerActivity->getExitAt() ) || $workerActivity->getExitAt() > new DateTimeImmutable('now')) ;
  222.         })->getValues());
  223.     }
  224.     public function getAllWorkers(): Collection
  225.     {
  226.         return $this->worker_activities;
  227.     }
  228.     public function addWorkerActivity(WorkerActivities $workerActivity): self
  229.     {
  230.         if (!$this->worker_activities->contains($workerActivity)) {
  231.             $this->worker_activities[] = $workerActivity;
  232.             $workerActivity->setCustomer($this);
  233.         }
  234.         return $this;
  235.     }
  236.     public function removeWorkerActivity(WorkerActivities $workerActivity): self
  237.     {
  238.         if ($this->worker_activities->removeElement($workerActivity)) {
  239.             // set the owning side to null (unless already changed)
  240.             if ($workerActivity->getCustomer() === $this) {
  241.                 $workerActivity->setCustomer(null);
  242.             }
  243.         }
  244.         return $this;
  245.     }
  246. /**
  247.  * @return Collection<int, CustomerCertificates>
  248.  */
  249. public function getCustomerCertificates(): Collection
  250. {
  251.     return $this->customer_certificates;
  252. }
  253. public function addCustomerCertificate(CustomerCertificates $customerCertificate): self
  254. {
  255.     if (!$this->customer_certificates->contains($customerCertificate)) {
  256.         $this->customer_certificates[] = $customerCertificate;
  257.         $customerCertificate->setCustomer($this);
  258.     }
  259.     return $this;
  260. }
  261. public function removeCustomerCertificate(CustomerCertificates $customerCertificate): self
  262. {
  263.     if ($this->customer_certificates->removeElement($customerCertificate)) {
  264.         // set the owning side to null (unless already changed)
  265.         if ($customerCertificate->getCustomer() === $this) {
  266.             $customerCertificate->setCustomer(null);
  267.         }
  268.     }
  269.     return $this;
  270. }
  271. public function getCity(): ?string
  272. {
  273.     return $this->city;
  274. }
  275. public function setCity(?string $city): self
  276. {
  277.     $this->city $city;
  278.     return $this;
  279. }
  280. public function getAdministrative(): ?Administrative
  281. {
  282.     return $this->administrative;
  283. }
  284. public function setAdministrative(Administrative $administrative): self
  285. {
  286.     // set the owning side of the relation if necessary
  287.     if ($administrative->getPairedCustomer() !== $this) {
  288.         $administrative->setPairedCustomer($this);
  289.     }
  290.     $this->administrative $administrative;
  291.     return $this;
  292. }
  293. }