/** * Load the Document * * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $description = new Description(); $description->setType($manager->find("Project\\Entity\\Idea\\DescriptionType", 1)); $description->setIdea($manager->find("Project\\Entity\\Idea\\Idea", 1)); $description->setDescription('This is the inital description'); $manager->persist($description); $manager->flush(); }
/** * @return string */ public function parseNewIdea() { if ($this->getCallService()->isEmpty()) { return 'The selected call is empty'; } $data = array_merge_recursive($this->getRequest()->getPost()->toArray(), $this->getRequest()->getFiles()->toArray()); $form = $this->getFormService()->prepare('Idea\\Idea', null, $data); $form->setAttribute('class', 'form-horizontal'); if ($this->getRequest()->isPost() && $form->isValid()) { /* * @var Idea */ $idea = $form->getData(); $idea->setCall($this->getCallService()->getCall()); $idea->setContact($this->getServiceLocator()->get('zfcuser_auth_service')->getIdentity()); $idea->setNumber($this->getIdeaService()->findNextIdeaNumber($this->getCallService()->getCall())); /* * @var Idea */ $result = $this->getIdeaService()->newEntity($idea); //Add the descriptions to the idea $ideaDescriptionTypes = $this->getIdeaService()->findAll('Idea\\DescriptionType'); foreach ($ideaDescriptionTypes as $ideaDescriptionType) { $description = new Description(); $description->setIdea($result); $description->setType($ideaDescriptionType); $description->setDescription($ideaDescriptionType->getTemplate()); $this->getIdeaService()->newEntity($description); } /* * Grab the redirect plugin from the controllerpluginmanager. * * @var Redirect */ $redirect = $this->getServiceLocator()->get('controllerpluginmanager')->get('redirect'); /* * Grab the flashmessenger plugin from the controllerpluginmanager. * * @var FlashMessenger */ $flashMessenger = $this->getServiceLocator()->get('controllerpluginmanager')->get('flashmessenger'); $flashMessenger->setNamespace('success')->addMessage(sprintf(_("txt-idea-%s-has-successfully-been-created"), $idea->getIdea())); $redirect->toRoute('route-' . $result->get('underscore_full_entity_name'), ['docRef' => $result->getDocRef()]); } return $this->getZfcTwigRenderer()->render('project/idea/new', ['form' => $form]); }