Exemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $bug = new Issue();
     $bug->setUser($this->getReference('user_user'));
     $bug->setTitle('Issue title');
     $bug->setBody('Issue body');
     $bug->setCriticality(Issue::CRITICALITY_SECURITY);
     $bug->setUpdatedAt(new \DateTime());
     $manager->persist($bug);
     $comment = new Comment();
     $comment->setUser($this->getReference('user_admin'));
     $comment->setIssue($bug);
     $comment->setBody('Comment body');
     $manager->persist($comment);
     $manager->flush();
 }
Exemplo n.º 2
0
 /**
  * @Route("/{id}-{slug}", requirements = {"id" = "\d+"}, name="bugs_view")
  * @Template()
  */
 public function viewAction($id, $slug)
 {
     if (!$this->getUserLayer()->isUser()) {
         return $this->createAccessDeniedResponse();
     }
     /** @var $em EntityManager */
     $em = $this->getDoctrine()->getManager();
     /** @var $bug Issue */
     $bug = $em->createQueryBuilder()->select('i, u, a')->from('EtuModuleBugsBundle:Issue', 'i')->leftJoin('i.user', 'u')->leftJoin('i.assignee', 'a')->where('i.id = :id')->setParameter('id', $id)->setMaxResults(1)->getQuery()->getOneOrNullResult();
     if (!$bug) {
         throw $this->createNotFoundException('Issue #' . $id . ' not found');
     }
     if (StringManipulationExtension::slugify($bug->getTitle()) != $slug) {
         return $this->redirect($this->generateUrl('bugs_view', array('id' => $id, 'slug' => StringManipulationExtension::slugify($bug->getTitle()))), 301);
     }
     /** @var $bug Issue */
     $comments = $em->createQueryBuilder()->select('c, u')->from('EtuModuleBugsBundle:Comment', 'c')->leftJoin('c.user', 'u')->where('c.issue = :issue')->setParameter('issue', $bug->getId())->getQuery()->getResult();
     $comment = new Comment();
     $comment->setIssue($bug);
     $comment->setUser($this->getUser());
     $form = $this->createFormBuilder($comment)->add('body')->getForm();
     $request = $this->getRequest();
     if ($request->getMethod() == 'POST') {
         if ($form->submit($request)->isValid() && $this->getUser()->hasPermission('bugs.add')) {
             $em->persist($comment);
             $em->flush();
             // Send notifications to subscribers
             $notif = new Notification();
             $notif->setModule($this->getCurrentBundle()->getIdentifier())->setHelper('bugs_new_comment')->setAuthorId($this->getUser()->getId())->setEntityType('issue')->setEntityId($bug->getId())->addEntity($comment);
             $this->getNotificationsSender()->send($notif);
             // Subscribe automatically the user
             $this->getSubscriptionsManager()->subscribe($this->getUser(), 'issue', $bug->getId());
             $this->get('session')->getFlashBag()->set('message', array('type' => 'success', 'message' => 'bugs.bugs.view.comment_confirm'));
             return $this->redirect($this->generateUrl('bugs_view', array('id' => $bug->getId(), 'slug' => StringManipulationExtension::slugify($bug->getTitle()))));
         }
     }
     $updateForm = $this->createFormBuilder($bug)->add('criticality', 'choice', array('choices' => array(Issue::CRITICALITY_CRITICAL => 'bugs.criticality.60', Issue::CRITICALITY_SECURITY => 'bugs.criticality.50', Issue::CRITICALITY_MAJOR => 'bugs.criticality.40', Issue::CRITICALITY_MINOR => 'bugs.criticality.30', Issue::CRITICALITY_VISUAL => 'bugs.criticality.20', Issue::CRITICALITY_TYPO => 'bugs.criticality.10')))->getForm();
     return array('bug' => $bug, 'comments' => $comments, 'form' => $form->createView(), 'updateForm' => $updateForm->createView());
 }
Exemplo n.º 3
0
 /**
  * @Route("/{id}-{slug}/open", requirements = {"id" = "\d+"}, name="bugs_admin_open")
  * @Template()
  */
 public function openAction($id, $slug)
 {
     if (!$this->getUserLayer()->isUser() || !$this->getUser()->hasPermission('bugs.admin')) {
         return $this->createAccessDeniedResponse();
     }
     /** @var $em EntityManager */
     $em = $this->getDoctrine()->getManager();
     /** @var $bug Issue */
     $bug = $em->createQueryBuilder()->select('i, u, a')->from('EtuModuleBugsBundle:Issue', 'i')->leftJoin('i.user', 'u')->leftJoin('i.assignee', 'a')->where('i.id = :id')->setParameter('id', $id)->setMaxResults(1)->getQuery()->getOneOrNullResult();
     if (!$bug) {
         throw $this->createNotFoundException('Issue #' . $id . ' not found');
     }
     if (StringManipulationExtension::slugify($bug->getTitle()) != $slug) {
         throw $this->createNotFoundException('Invalid slug');
     }
     $bug->open();
     $em->persist($bug);
     $comment = new Comment();
     $comment->setIsStateUpdate(true);
     $comment->setIssue($bug);
     $comment->setUser($this->getUser());
     $comment->setBody($this->get('translator')->trans('bugs.bugs_admin.open.message', array('%adminName%' => $this->getUser()->getFullName())));
     $em->persist($comment);
     $em->flush();
     $this->get('session')->getFlashBag()->set('message', array('type' => 'success', 'message' => 'bugs.bugs_admin.open.success'));
     return $this->redirect($this->generateUrl('bugs_view', array('id' => $bug->getId(), 'slug' => StringManipulationExtension::slugify($bug->getTitle()))));
 }