public function createNew() { $client = new Muscle(); $client->setUser($this->token->getToken()->getUser()); $this->form->setData($client); $this->form->handleRequest($this->request); if ($this->form->isSubmitted() && $this->form->isValid()) { $this->createNewSuccess(); return true; } return false; }
protected function execute(InputInterface $input, OutputInterface $output) { $dm = $this->getContainer()->get('doctrine_mongodb.odm.document_manager'); switch ($input->getArgument('entity')) { case 'muscle': for ($i = 1; $i <= 15; $i++) { $muscle = new Muscle(); $muscle->setNameFr('Name ' . $i . ' FR'); $muscle->setNameEn('Name ' . $i . ' En'); $muscle->setDescriptionFr('Description ' . $i . ' FR'); $muscle->setDescriptionEn('Description ' . $i . ' En'); $dm->persist($muscle); } break; } $dm->flush(); $output->writeln(sprintf('Database populated with 15 random <info>%s</info> .', $input->getArgument('entity') . 's')); }