getParticipantsCollection()->toArray(); } /** * Gets the users participating in this conversation. * * Since the ORM schema does not map the participants collection field, it * must be created on demand. * * @return ArrayCollection|ParticipantInterface[] */ protected function getParticipantsCollection() { if (null === $this->participants) { $this->participants = new ArrayCollection(); foreach ($this->metadata as $data) { $this->participants->add($data->getParticipant()); } } return $this->participants; } /** * {@inheritdoc} */ public function addParticipant(ParticipantInterface $participant) { if (!$this->isParticipant($participant)) { $this->getParticipantsCollection()->add($participant); } } /** * Adds many participants to the thread. * * @param array|\Traversable * * @throws \InvalidArgumentException * * @return Thread */ public function addParticipants($participants) { if (!is_array($participants) && !$participants instanceof \Traversable) { throw new \InvalidArgumentException('Participants must be an array or instance of Traversable'); } foreach ($participants as $participant) { $this->addParticipant($participant); } return $this; } /** * {@inheritdoc} */ public function isParticipant(ParticipantInterface $participant) { return $this->getParticipantsCollection()->contains($participant); } /** * Get the collection of ModelThreadMetadata. * * @return Collection */ public function getAllMetadata() { return $this->metadata; } /** * {@inheritdoc} */ public function addMetadata(ModelThreadMetadata $meta) { $meta->setThread($this); parent::addMetadata($meta); } }