") * @Serializer\SerializedName("metaFields") * @Serializer\Accessor(getter="getVisibleMetaFields") * * @ORM\OneToMany(targetEntity="App\Entity\ActivityMeta", mappedBy="activity", cascade={"persist"}) */ private $meta; public function __construct() { $this->meta = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getProject(): ?Project { return $this->project; } public function setProject(?Project $project): Activity { $this->project = $project; return $this; } public function setName(string $name): Activity { $this->name = $name; return $this; } public function getName(): ?string { return $this->name; } public function setComment(?string $comment): Activity { $this->comment = $comment; return $this; } public function getComment(): ?string { return $this->comment; } public function setVisible(bool $visible): Activity { $this->visible = $visible; return $this; } public function isGlobal(): bool { return $this->project === null; } public function isVisible(): bool { return $this->visible; } public function setBudget(float $budget): Activity { $this->budget = $budget; return $this; } public function getBudget(): float { return $this->budget; } public function setTimeBudget(int $seconds): Activity { $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; } /** * @return string */ public function __toString() { return $this->getName(); } public function __clone() { if ($this->id) { $this->id = null; $this->meta = new ArrayCollection(); } } }