Example #1
0
 public function loadForStory(\Neblion\ScrumBundle\Entity\Story $story)
 {
     return $this->getEntityManager()->createQuery('SELECT st, s, m, a, p
                 FROM NeblionScrumBundle:StoryComment st
                 INNER JOIN st.story s
                 INNER JOIN st.member m
                 INNER JOIN m.account a
                 INNER JOIN a.profile p
                 WHERE s.id = :story_id
                 ORDER BY st.created')->setParameter('story_id', $story->getId())->getResult();
 }
Example #2
0
 /**
  * Creates a new Story entity.
  *
  * @Route("/{id}/create", name="story_create")
  * @Method("post")
  * @Template("NeblionScrumBundle:Story:new.html.twig")
  */
 public function createAction($id)
 {
     // Check if user is authorized
     if (!$this->get('security.context')->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
         throw new AccessDeniedException();
     }
     $user = $this->get('security.context')->getToken()->getUser();
     $em = $this->getDoctrine()->getManager();
     // Load project
     $project = $em->getRepository('NeblionScrumBundle:Project')->find($id);
     if (!$project) {
         throw $this->createNotFoundException('Unable to find Project entity.');
     }
     $success = false;
     $story = new Story();
     $story->setProject($project);
     $form = $this->createForm(new StoryType($project->getId()), $story, array('new' => true));
     $request = $this->getRequest();
     $form->bindRequest($request);
     if ($form->isValid()) {
         // Load default story status (To validate)
         $status = $em->getRepository('NeblionScrumBundle:ProcessStatus')->find(4);
         // Get last position for story
         $position = $em->getRepository('NeblionScrumBundle:Story')->getLastPositionForProject($project->getId());
         $story->setPosition($position + 1);
         $story->setStatus($status);
         $em->persist($story);
         // store activity
         $this->get('scrum_activity')->add($project, $user, 'created story', $this->generateUrl('project_backlog', array('id' => $project->getId())), 'Project #' . $project->getId() . ' ' . $story->getName());
         $em->flush();
         $success = true;
         if (!$this->getRequest()->isXmlHttpRequest()) {
             // Set flash message
             $this->get('session')->getFlashBag()->add('success', 'Story was created with success!');
             return $this->redirect($this->generateUrl('project_backlog', array('id' => $project->getId())));
         }
     }
     if ($this->getRequest()->isXmlHttpRequest()) {
         return $this->container->get('templating')->renderResponse('NeblionScrumBundle:Story/Ajax:new.html.twig', array('project' => $project, 'story' => $story, 'form' => $form->createView(), 'success' => $success));
     } else {
         return array('project' => $project, 'story' => $story, 'form' => $form->createView());
     }
 }
Example #3
0
 private function newEntity($params)
 {
     // Create story
     $entity = new Story();
     $entity->setProject($params['project']);
     $entity->setFeature($params['feature']);
     if ($params['sprint']) {
         $entity->setSprint($params['sprint']);
     }
     $entity->setStatus($params['status']);
     $entity->setType($params['type']);
     $entity->setName($params['name']);
     $entity->setDescription($params['name'] . ' description');
     $entity->setPosition($params['position']);
     $entity->setEstimate($params['estimate']);
     $this->manager->persist($entity);
 }