entries = new ArrayCollection(); } public function __toString() { return $this->label; } /** * Get id. * * @return int */ public function getId() { return $this->id; } /** * Set label. * * @param string $label * * @return Tag */ public function setLabel($label) { $this->label = $label; return $this; } /** * Get label. * * @return string */ public function getLabel() { return $this->label; } public function getSlug() { return $this->slug; } public function addEntry(Entry $entry) { $this->entries[] = $entry; } public function hasEntry($entry) { return $this->entries->contains($entry); } /** * Get entries for this tag. * * @return ArrayCollection */ public function getEntries() { return $this->entries; } public function getEntriesByUserId($userId) { $filteredEntries = new ArrayCollection(); foreach ($this->entries as $entry) { if ($entry->getUser()->getId() === $userId) { $filteredEntries->add($entry); } } return $filteredEntries; } }