/** * {@inheritdoc} */ public function removeTag(ConversationInterface $conversation, PersonInterface $person, TagInterface $tag) { $conversationPerson = $this->repository->getConversationPerson($conversation, $person); if (!$conversationPerson instanceof ConversationPersonInterface) { throw new \LogicException(sprintf('Link between conversation %s and person %s was not found in %s', $conversation->getId(), $person->getId(), __METHOD__)); } if (!$conversationPerson->hasTag($tag)) { return false; } $conversationPerson->removeTag($tag); $this->driver->persistConversationPerson($conversationPerson); $this->driver->flush(); return true; }
public function testFindConversationPerson() { $person = $this->createPerson(); $conversation = $this->driver->createConversationModel(); $conversation->setSubject('Subject'); $this->driver->persistConversation($conversation); $personModel = $this->driver->createConversationPersonModel($conversation, $person); $this->driver->persistConversationPerson($personModel); $this->driver->flush(); $fetched = $this->driver->findConversationPerson($conversation, $person); $this->assertInstanceOf(get_class($personModel), $fetched); $this->assertEquals($personModel->getConversation(), $conversation); $this->assertEquals($personModel->getPerson(), $person); }
/** * Create and persist a conversation person object. * * @param ConversationInterface $conversation * @param PersonInterface $person * * @return ConversationPersonInterface */ private function createAndPersistConversationPerson(ConversationInterface $conversation, PersonInterface $person) { $conversationPerson = $this->driver->createConversationPersonModel($conversation, $person); $this->driver->persistConversationPerson($conversationPerson); return $conversationPerson; }