public function createMessage($text, $username, $email = null) { $message = new GuestBookMessage(); $message->setText($text)->setUsername($username)->setEmail($email); $this->manager->persist($message); $this->manager->flush(); }
/** * @return GuestBookMessage */ private function createMessageEntity() { $message = new GuestBookMessage(); /** @var User $user */ if ($user = $this->getUser()) { $message->setUsername($user->getUsername()); } return $message; }
/** * Load data fixtures with the passed EntityManager * * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $systemMessage = new GuestBookMessage(); $systemMessage->setText('Welcome to guest book!')->setUsername(MessageCreator::SYSTEM_MESSAGE); $manager->persist($systemMessage); $message = new GuestBookMessage(); $message->setText('My first message. Yay!')->setUsername('Maks')->setEmail('*****@*****.**'); $manager->persist($message); $manager->flush(); }