Overview

Namespaces

  • Mapbender
    • Component
      • HTTP
    • CoreBundle
      • Command
      • Component
        • Exception
      • Controller
      • DataFixtures
        • ORM
      • DependencyInjection
      • Element
        • Type
      • Entity
      • EventListener
      • Extension
      • Form
        • DataTransformer
        • EventListener
        • Type
      • Security
      • Template
    • KmlBundle
      • Element
    • ManagerBundle
      • Controller
      • Form
        • DataTransformer
        • Type
    • MonitoringBundle
      • Command
      • Component
      • Controller
      • DependencyInjection
      • Entity
      • EventListener
      • Form
    • PrintBundle
      • Component
      • Controller
    • WmcBundle
      • Component
        • Exception
      • Element
        • Type
      • Entity
      • Form
        • Type
    • WmsBundle
      • Component
        • Exception
      • Controller
      • DependencyInjection
      • Element
        • Type
      • Entity
      • Event
      • Form
        • EventListener
        • Type
    • WmtsBundle
      • Component
        • Exception
      • Controller
      • Entity
      • Form
        • Type
  • None
  • PHP

Classes

  • ApplicationController
  • GroupController
  • ProxyController
  • TranslationController
  • WelcomeController
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download
  1: <?php
  2: namespace Mapbender\CoreBundle\Controller;
  3: use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  4: use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  5: use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
  6: use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  7: use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  8: use Mapbender\CoreBundle\Entity\Group;
  9: use Mapbender\CoreBundle\Form\GroupType;
 10: 
 11: /**
 12:  * Description of GroupController
 13:  *
 14:  * @author apour
 15:  */
 16: class GroupController extends Controller {
 17: 
 18:     /**
 19:      * @Route("/group/")
 20:      * @Method("GET")
 21:      * @Template()
 22:      * @ParamConverter("groupList",class="Mapbender\CoreBundle\Entity\Group")
 23:      */
 24:     public function indexAction(array $groupList) {
 25:         return array(
 26:             "groupList" => $groupList
 27:         );
 28:     }
 29: 
 30:     /**
 31:      * @Route("/group/create")
 32:      * @Method("GET")
 33:      * @Template()
 34:      */
 35:     public function createAction() {
 36:         $form = $this->get("form.factory")->create(
 37:                 new GroupType(),
 38:                 new Group()
 39:         );
 40: 
 41: 
 42:         return array(
 43:             "form" => $form->createView()
 44:         );
 45:     }
 46: 
 47:     /**
 48:      * @Route("/group/")
 49:      * @Method("POST")
 50:      */
 51:     public function addAction() {
 52:         $group = new Group();
 53: 
 54:         $form = $this->get("form.factory")->create(
 55:                 new GroupType(),
 56:                 $group
 57:         );
 58: 
 59:         $request = $this->get("request");
 60: 
 61:         $form->bindRequest($request);
 62: 
 63:         if($form->isValid()) {
 64:             $em = $this->getDoctrine()->getEntityManager();
 65:             $em->persist($group);
 66:             $em->flush();
 67:             return $this->redirect($this->generateUrl("mapbender_core_group_index"));
 68:         } else {
 69:             return $this->render(
 70:                 "MapbenderCoreBundle:Group:create.html.twig",
 71:                 array("form" => $form->createView())
 72:             );
 73:         }
 74:     }
 75: 
 76: 
 77:     /**
 78:      * @Route("/group/{groupId}")
 79:      * @Method("GET")
 80:      * @Template()
 81:      */
 82:     public function editAction(Group $group) {
 83:         $form = $this->get("form.factory")->create(
 84:                 new GroupType(),
 85:                 $group
 86:         );
 87: 
 88:         return array(
 89:             "form" => $form->createView(),
 90:             "group" => $group
 91:         );
 92:     }
 93: 
 94:     /**
 95:      * @Route("/group/{groupId}/delete")
 96:      * @Method("POST")
 97:      */
 98:     public function deleteAction(Group $group) {
 99:         $em = $this->getDoctrine()->getEntityManager();
100:         try {
101:             $em->remove($group);
102:             $em->flush();
103:         } catch(\Exception $E) {
104:             $this->get("logger")->info("Could not delete group. ".$E->getMessage());
105:             $this->get("session")->setFlash("error","Could not delete group.");
106:             return $this->redirect($this->generateUrl("mapbender_core_group_index"));
107:         }
108: 
109:         $this->get("session")->setFlash("success","Your group has been deleted.");
110:         return $this->redirect($this->generateUrl("mapbender_core_group_index"));
111:     }
112: 
113:     /**
114:      * @Route("/group/{groupId}/delete")
115:      * @Method("GET")
116:      * @Template()
117:      */
118:     public function confirmdeleteAction(Group $group) {
119: 
120:         return array(
121:             "group" => $group
122:         );
123:     }
124: 
125:     /**
126:      * @Route("/group/{groupId}")
127:      * @Method("POST")
128:      */
129:     public function saveAction(Group $group) {
130:         $form = $this->get("form.factory")->create(
131:                 new GroupType(),
132:                 $group
133:         );
134: 
135:         $request = $this->get("request");
136: 
137:         $form->bindRequest($request);
138: 
139:         if($form->isValid()) {
140:             try {
141:                 $em = $this->getDoctrine()->getEntityManager();
142:                 $em->persist($group);
143:                 $em->flush();
144:             } catch(\Exception $E) {
145:                 $this->get("logger")->err("Could not save group. ".$E->getMessage());
146:                 $this->get("session")->setFlash("error","Could not save group");
147:                 return $this->redirect($this->generateUrl("mapbender_core_group_edit",array("groupId" => $group->getId())));
148:             }
149:             return $this->redirect($this->generateUrl("mapbender_core_group_index"));
150:         } else {
151:             return $this->render(
152:                 "MapbenderCoreBundle:Group:edit.html.twig",
153:                 array(
154:           "form" => $form->createView(),
155:                     "group" => $group
156:         )
157:             );
158:         }
159:     }
160: }
161: 
Mapbender3 API documenation API documentation generated by ApiGen 2.8.0