예제 #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();
 }
예제 #2
0
 /**
  * @Route("/create", name="bugs_create")
  * @Template()
  */
 public function createAction()
 {
     if (!$this->getUserLayer()->isUser()) {
         return $this->createAccessDeniedResponse();
     }
     if (!$this->getUser()->hasPermission('bugs.add')) {
         throw new AccessDeniedHttpException('Vous n\'avez pas la permission nécessaire pour signaler un problème.');
     }
     $bug = new Issue();
     $bug->setUser($this->getUser());
     $form = $this->createFormBuilder($bug)->add('title')->add('criticality', 'choice', array('choices' => array(Issue::CRITICALITY_SECURITY => 'bugs.criticality.60', Issue::CRITICALITY_CRITICAL => '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')))->add('body')->getForm();
     $request = $this->getRequest();
     if ($request->getMethod() == 'POST' && $form->bind($request)->isValid()) {
         /** @var $em EntityManager */
         $em = $this->getDoctrine()->getManager();
         $em->persist($bug);
         $em->flush();
         // Send notifications to subscribers ("entityId = 0" mean all opened bugs)
         $notif = new Notification();
         $notif->setModule($this->getCurrentBundle()->getIdentifier())->setHelper('bugs_new_opened')->setAuthorId($this->getUser()->getId())->setEntityType('issue')->setEntityId(0)->addEntity($bug);
         $this->getNotificationsSender()->send($notif);
         // Subscribe automatically the user at the issue
         $this->getSubscriptionsManager()->subscribe($this->getUser(), 'issue', $bug->getId());
         $this->get('session')->getFlashBag()->set('message', array('type' => 'success', 'message' => 'bugs.bugs.create.confirm'));
         return $this->redirect($this->generateUrl('bugs_view', array('id' => $bug->getId(), 'slug' => StringManipulationExtension::slugify($bug->getTitle()))));
     }
     return array('form' => $form->createView());
 }