") * @Serializer\SerializedName("metaFields") * @Serializer\Accessor(getter="getVisibleMetaFields") * * @ORM\OneToMany(targetEntity="App\Entity\CustomerMeta", mappedBy="customer", cascade={"persist"}) */ private $meta; /** * Teams * * If no team is assigned, everyone can access the customer * * @var Team[]|ArrayCollection * * @Serializer\Expose() * @Serializer\Groups({"Customer"}) * @SWG\Property(type="array", @SWG\Items(ref="#/definitions/Team")) * * @ORM\ManyToMany(targetEntity="Team", cascade={"persist"}, inversedBy="customers") * @ORM\JoinTable( * name="kimai2_customers_teams", * joinColumns={ * @ORM\JoinColumn(name="customer_id", referencedColumnName="id", onDelete="CASCADE") * }, * inverseJoinColumns={ * @ORM\JoinColumn(name="team_id", referencedColumnName="id", onDelete="CASCADE") * } * ) */ private $teams; public function __construct() { $this->meta = new ArrayCollection(); $this->teams = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function setName(string $name): Customer { $this->name = $name; return $this; } public function getName(): ?string { return $this->name; } public function setNumber(?string $number): Customer { $this->number = $number; return $this; } public function getNumber(): ?string { return $this->number; } public function setComment(?string $comment): Customer { $this->comment = $comment; return $this; } public function getComment(): ?string { return $this->comment; } public function setVisible(bool $visible): Customer { $this->visible = $visible; return $this; } public function isVisible(): bool { return $this->visible; } public function setCompany(?string $company): Customer { $this->company = $company; return $this; } public function getCompany(): ?string { return $this->company; } public function getVatId(): ?string { return $this->vatId; } public function setVatId(?string $vatId): Customer { $this->vatId = $vatId; return $this; } public function setContact(?string $contact): Customer { $this->contact = $contact; return $this; } public function getContact(): ?string { return $this->contact; } public function setAddress(?string $address): Customer { $this->address = $address; return $this; } public function getAddress(): ?string { return $this->address; } public function setCountry(?string $country): Customer { $this->country = $country; return $this; } public function getCountry(): ?string { return $this->country; } public function setCurrency(?string $currency): Customer { $this->currency = $currency; return $this; } public function getCurrency(): ?string { return $this->currency; } public function setPhone(?string $phone): Customer { $this->phone = $phone; return $this; } public function getPhone(): ?string { return $this->phone; } public function setFax(?string $fax): Customer { $this->fax = $fax; return $this; } public function getFax(): ?string { return $this->fax; } public function setMobile(?string $mobile): Customer { $this->mobile = $mobile; return $this; } public function getMobile(): ?string { return $this->mobile; } public function setEmail(?string $mail): Customer { $this->email = $mail; return $this; } public function getEmail(): ?string { return $this->email; } public function setHomepage(?string $homepage): Customer { $this->homepage = $homepage; return $this; } public function getHomepage(): ?string { return $this->homepage; } public function setTimezone(string $timezone): Customer { $this->timezone = $timezone; return $this; } public function getTimezone(): ?string { return $this->timezone; } public function setBudget(float $budget): Customer { $this->budget = $budget; return $this; } public function getBudget(): float { return $this->budget; } public function setTimeBudget(int $seconds): Customer { $this->timeBudget = $seconds; return $this; } public function getTimeBudget(): int { return $this->timeBudget; } /** * @return Collection|MetaTableTypeInterface[] */ public function getMetaFields(): Collection { return $this->meta; } /** * @return MetaTableTypeInterface[] */ public function getVisibleMetaFields(): array { $all = []; foreach ($this->meta as $meta) { if ($meta->isVisible()) { $all[] = $meta; } } return $all; } public function getMetaField(string $name): ?MetaTableTypeInterface { foreach ($this->meta as $field) { if (strtolower($field->getName()) === strtolower($name)) { return $field; } } return null; } public function setMetaField(MetaTableTypeInterface $meta): EntityWithMetaFields { if (null === ($current = $this->getMetaField($meta->getName()))) { $meta->setEntity($this); $this->meta->add($meta); return $this; } $current->merge($meta); return $this; } public function addTeam(Team $team) { if ($this->teams->contains($team)) { return; } $this->teams->add($team); $team->addCustomer($this); } public function removeTeam(Team $team) { if (!$this->teams->contains($team)) { return; } $this->teams->removeElement($team); $team->removeCustomer($this); } /** * @return Collection */ public function getTeams(): Collection { return $this->teams; } /** * @return string */ public function __toString() { return $this->getName(); } public function __clone() { if ($this->id) { $this->id = null; } $currentTeams = $this->teams; $this->teams = new ArrayCollection(); /** @var Team $team */ foreach ($currentTeams as $team) { $this->addTeam($team); } $currentMeta = $this->meta; $this->meta = new ArrayCollection(); /** @var ProjectMeta $meta */ foreach ($currentMeta as $meta) { $newMeta = clone $meta; $newMeta->setEntity($this); $this->setMetaField($newMeta); } } }