Overview

Namespaces

  • Mapbender
    • Component
      • HTTP
    • CoreBundle
      • Command
      • Component
        • Exception
      • Controller
      • DataFixtures
        • ORM
      • DependencyInjection
      • Element
        • Type
      • Entity
      • EventListener
      • Extension
      • Form
        • DataTransformer
        • EventListener
        • Type
      • Security
      • Template
    • DrupalIntegrationBundle
      • DependencyInjection
      • Security
        • Authentication
          • Provider
          • Token
        • Authorization
          • Voter
        • Factory
        • Firewall
        • User
      • Session
    • 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
        • EventListener
        • Type
    • WmsBundle
      • Component
        • Exception
      • Controller
      • DependencyInjection
      • Element
        • Type
      • Entity
      • Event
      • Form
        • EventListener
        • Type
    • WmtsBundle
      • Component
        • Exception
      • Controller
      • Entity
      • Form
        • Type
  • None
  • PHP

Classes

  • ApplicationController
  • ElementController
  • RepositoryController
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download
  1: <?php
  2: 
  3: /**
  4:  * Mapbender application management
  5:  *
  6:  * @author Christian Wygoda <christian.wygoda@wheregroup.com>
  7:  */
  8: 
  9: namespace Mapbender\ManagerBundle\Controller;
 10: 
 11: use Symfony\Bundle\FrameworkBundle\Controller\Controller;
 12: use FOM\ManagerBundle\Configuration\Route as ManagerRoute;
 13: use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
 14: use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
 15: use Symfony\Component\HttpFoundation\Response;
 16: use Symfony\Component\HttpFoundation\Request;
 17: use Mapbender\CoreBundle\Entity\Application;
 18: use Mapbender\ManagerBundle\Form\Type\ApplicationType;
 19: use Mapbender\CoreBundle\Entity\Layerset;
 20: use Mapbender\CoreBundle\Form\Type\LayersetType;
 21: 
 22: //FIXME: make this work without an explicit import
 23: use Mapbender\CoreBundle\Entity\SourceInstance;
 24: use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
 25: use Symfony\Component\Security\Core\Exception\AccessDeniedException;
 26: 
 27: class ApplicationController extends Controller
 28: {
 29:     /**
 30:      * Render a list of applications the current logged in user has access
 31:      * to.
 32:      *
 33:      * @ManagerRoute("/applications")
 34:      * @Method("GET")
 35:      * @Template
 36:      */
 37:     public function indexAction()
 38:     {
 39:         $securityContext = $this->get('security.context');
 40:         $oid = new ObjectIdentity('class', 'Mapbender\CoreBundle\Entity\Application');
 41: 
 42:         $applications = $this->get('mapbender')->getApplicationEntities();
 43:         $allowed_applications = array();
 44:         foreach($applications as $application)
 45:         {
 46:             if($securityContext->isGranted('VIEW', $application))
 47:             {
 48:                 if(!$application->isPublished() && !$securityContext->isGranted('OWNER', $application)) {
 49:                     continue;
 50:                 }
 51:                 $allowed_applications[] = $application;
 52:             }
 53:         }
 54: 
 55:         return array(
 56:             'applications' => $allowed_applications,
 57:             'create_permission' => $securityContext->isGranted('CREATE', $oid)
 58:         );
 59:     }
 60: 
 61:     /**
 62:      * Shows form for creating new applications
 63:      *
 64:      * @ManagerRoute("/application/new")
 65:      * @Method("GET")
 66:      * @Template
 67:      */
 68:     public function newAction()
 69:     {
 70:         $application = new Application();
 71: 
 72:         // ACL access check
 73:         $this->checkGranted('CREATE', $application);
 74: 
 75:         $form = $this->createApplicationForm($application);
 76: 
 77:         return array(
 78:             'application' => $application,
 79:             'form' => $form->createView(),
 80:             'form_name' => $form->getName());
 81:     }
 82: 
 83:     /**
 84:      * Create a new application from POSTed data
 85:      *
 86:      * @ManagerRoute("/application")
 87:      * @Method("POST")
 88:      * @Template("MapbenderManagerBundle:Application:new.html.twig")
 89:      */
 90:     public function createAction()
 91:     {
 92:         $application = new Application();
 93: 
 94:         // ACL access check
 95:         $this->checkGranted('CREATE', $application);
 96: 
 97:         $form = $this->createApplicationForm($application);
 98:         $request = $this->getRequest();
 99: 
100:         $form->bindRequest($request);
101:         if($form->isValid())
102:         {
103:             $application->setUpdated(new \DateTime('now'));
104:             $application->setTemplate("Mapbender\CoreBundle\Template\Fullscreen");
105:             $em = $this->getDoctrine()->getEntityManager();
106: 
107:             $em->getConnection()->beginTransaction();
108:             $em->persist($application);
109:             $em->flush();
110: 
111:             $aclManager = $this->get('fom.acl.manager');
112:             $aclManager->setObjectACLFromForm($application, $form->get('acl'),
113:                                                                        'object');
114: 
115:             $em->getConnection()->commit();
116: 
117:             $this->get('session')->setFlash('success',
118:                                             'Your application has been saved.');
119: 
120:             return $this->redirect(
121:                             $this->generateUrl('mapbender_manager_application_index'));
122:         }
123: 
124:         return array(
125:             'application' => $application,
126:             'form' => $form->createView(),
127:             'form_name' => $form->getName());
128:     }
129: 
130:     /**
131:      * Edit application
132:      *
133:      * @ManagerRoute("/application/{slug}/edit", requirements = { "slug" = "[\w-]+" })
134:      * @Method("GET")
135:      * @Template
136:      */
137:     public function editAction($slug)
138:     {
139:         $application = $this->get('mapbender')->getApplicationEntity($slug);
140: 
141:         // ACL access check
142:         $this->checkGranted('EDIT', $application);
143: 
144:         $form = $this->createApplicationForm($application);
145: 
146:         $templateClass = $application->getTemplate();
147:         $em = $this->getDoctrine()->getEntityManager();
148:         $query = $em->createQuery(
149:                 "SELECT s FROM MapbenderCoreBundle:Source s ORDER BY s.id ASC");
150:         $sources = $query->getResult();
151: 
152:         return array(
153:             'application' => $application,
154:             'regions' => $templateClass::getRegions(),
155:             'slug' => $slug,
156:             'available_elements' => $this->getElementList(),
157:             'sources' => $sources,
158:             'form' => $form->createView(),
159:             'form_name' => $form->getName());
160:     }
161: 
162:     /**
163:      * Updates application by POSTed data
164:      *
165:      * @ManagerRoute("/application/{slug}/update", requirements = { "slug" = "[\w-]+" })
166:      * @Method("POST")
167:      */
168:     public function updateAction($slug)
169:     {
170:         $application = $this->get('mapbender')->getApplicationEntity($slug);
171: 
172:         // ACL access check
173:         $this->checkGranted('EDIT', $application);
174:         $templateClassOld = $application->getTemplate();
175:         $form = $this->createApplicationForm($application);
176:         $request = $this->getRequest();
177: 
178:         $form->bindRequest($request);
179:         if($form->isValid())
180:         {
181:             $em = $this->getDoctrine()->getEntityManager();
182: 
183:             $em->getConnection()->beginTransaction();
184:             $templateClassNew = $application->getTemplate();
185:             $regions = $templateClassNew::getRegions();
186:             if($templateClassOld !== $templateClassNew && count($regions) > 0)
187:             {
188:                 foreach($application->getElements() as $element)
189:                 {
190:                     if(!in_array($element->getRegion(), $regions))
191:                     {
192:                         $element->setRegion($regions[0]);
193:                     }
194:                 }
195:             }
196:             $application->setUpdated(new \DateTime('now'));
197: 
198:             try
199:             {
200:                 $em->flush();
201: 
202:                 $aclManager = $this->get('fom.acl.manager');
203:                 $aclManager->setObjectACLFromForm($application,
204:                                                   $form->get('acl'), 'object');
205: 
206:                 $em->getConnection()->commit();
207: 
208:                 $this->get('session')->setFlash('success',
209:                                                 'Your application has been updated.');
210:             } catch(\Exception $e)
211:             {
212:                 $this->get('session')->setFlash('error',
213:                                                 'There was an error trying to save your application.');
214:                 $em->getConnection()->rollback();
215:                 $em->close();
216: 
217:                 if($this->container->getParameter('kernel.debug'))
218:                 {
219:                     throw($e);
220:                 }
221:             }
222:             return $this->redirect(
223:                             $this->generateUrl('mapbender_manager_application_edit',
224:                                                array(
225:                                 'slug' => $application->getSlug())));
226:         } else {
227:             $application->setSlug($slug);
228:         }
229: 
230:         $error = "error";
231: 
232:         if(count($form->getErrors()) > 0)
233:         {
234:             $error = $form->getErrors();
235:             $error = $error[0]->getMessageTemplate();
236:         } else
237:         {
238:             foreach($form->getChildren() as $child)
239:             {
240:                 if(count($child->getErrors()) > 0)
241:                 {
242:                     $error = $child->getErrors();
243:                     $error = $error[0]->getMessageTemplate();
244:                     break;
245:                 }
246:             }
247:         }
248: 
249:         $templateClass = $application->getTemplate();
250:         $em = $this->getDoctrine()->getEntityManager();
251:         $query = $em->createQuery(
252:                 "SELECT s FROM MapbenderCoreBundle:Source s ORDER BY s.id ASC");
253:         $sources = $query->getResult();
254:         return new Response($this->container->get('templating')
255:                                 ->render('MapbenderManagerBundle:Application:edit.html.twig',
256:                                          array(
257:                                     'application' => $application,
258:                                     'regions' => $templateClass::getRegions(),
259:                                     'slug' => $slug,
260:                                     'available_elements' => $this->getElementList(),
261:                                     'sources' => $sources,
262:                                     'form' => $form->createView(),
263:                                     'form_name' => $form->getName())));
264:     }
265: 
266:     /**
267:      * Toggle application state.
268:      *
269:      * @ManagerRoute("/application/{slug}/state", options={"expose"=true})
270:      * @Method("POST")
271:      */
272:     public function toggleStateAction($slug)
273:     {
274:         $application = $this->get('mapbender')->getApplicationEntity($slug);
275: 
276:         // ACL access check
277:         $this->checkGranted('EDIT', $application);
278: 
279:         $em = $this->getDoctrine()->getEntityManager();
280: 
281:         $requestedState = $this->get('request')->get('state');
282:         $currentState = $application->isPublished();
283:         $newState = $currentState;
284: 
285:         switch($requestedState)
286:         {
287:             case 'enabled':
288:             case 'disabled':
289:                 $newState = $requestedState === 'enabled' ? true : false;
290:                 $application->setPublished($newState);
291:                 $em->flush();
292:                 $message = 'State switched';
293:                 break;
294:             case null:
295:                 $message = 'No state given';
296:                 break;
297:             default:
298:                 $message = 'Unknown state requested';
299:                 break;
300:         }
301: 
302:         return new Response(json_encode(array(
303:             'oldState' => $currentState ? 'enabled' : 'disabled',
304:             'newState' => $newState ? 'enabled' : 'disabled',
305:             'message' => $message)), 200, array(
306:             'Content-Type' => 'application/json'
307:         ));
308:     }
309: 
310:     /**
311:      * Delete confirmation page
312:      * @ManagerRoute("/application/{slug}/delete", requirements = { "slug" = "[\w-]+" })
313:      * @Method("GET")
314:      * @Template("MapbenderManagerBundle:Application:delete.html.twig")
315:      */
316:     public function confirmDeleteAction($slug)
317:     {
318:         $application = $this->get('mapbender')->getApplicationEntity($slug);
319:         if($application === null)
320:         {
321:             $this->get('session')->setFlash('error',
322:                                             'Your application has been already deleted.');
323:             return $this->redirect(
324:                             $this->generateUrl('mapbender_manager_application_index'));
325:         }
326: 
327:         // ACL access check
328:         $this->checkGranted('EDIT', $application);
329: 
330:         $id = $application->getId();
331:         return array(
332:             'application' => $application,
333:             'form' => $this->createDeleteForm($id)->createView());
334:     }
335: 
336:     /**
337:      * Delete application
338:      *
339:      * @ManagerRoute("/application/{slug}/delete", requirements = { "slug" = "[\w-]+" })
340:      * @Method("POST")
341:      */
342:     public function deleteAction($slug)
343:     {
344:         $application = $this->get('mapbender')->getApplicationEntity($slug);
345: 
346:         // ACL access check
347:         $this->checkGranted('DELETE', $application);
348: 
349:         try {
350:             $em = $this->getDoctrine()->getEntityManager();
351:             $aclProvider = $this->get('security.acl.provider');
352:             $em->getConnection()->beginTransaction();
353:             $oid = ObjectIdentity::fromDomainObject($application);
354:             $aclProvider->deleteAcl($oid);
355:             $em->remove($application);
356:             $em->flush();
357:             $em->commit();
358:             $this->get('session')->setFlash('success','Your application has been deleted.');
359:         } catch(Exception $e) {
360:             $this->get('session')->setFlash('error','Your application couldn\'t be deleted.');
361:         }
362: 
363:         return new Response();
364:     }
365: 
366:     /* Layerset block start */
367: 
368:     /**
369:      * Create a form for a new layerset
370:      *
371:      * @ManagerRoute("/application/{slug}/layerset/new")
372:      * @Method("POST")
373:      * @Template("MapbenderManagerBundle:Application:form-layerset.html.twig")
374:      */
375:     public function newLayersetAction($slug)
376:     {
377:         $application = $this->get('mapbender')->getApplicationEntity($slug);
378:         // ACL access check
379:         $this->checkGranted('EDIT', $application);
380:         $layerset = new Layerset();
381:         $layerset->setApplication($application);
382: 
383:         $form = $this->createForm(new LayersetType(), $layerset);
384: 
385:         return array(
386:             "isnew" => true,
387:             "application" => $application,
388:             'form' => $form->createView());
389:     }
390: 
391:     /**
392:      * Create a new layerset from POSTed data
393:      *
394:      * @ManagerRoute("/application/{slug}/layerset/{layersetId}/edit")
395:      * @Method("POST")
396:      * @Template("MapbenderManagerBundle:Application:form-layerset.html.twig")
397:      */
398:     public function editLayersetAction($slug, $layersetId)
399:     {
400:         $application = $this->get('mapbender')->getApplicationEntity($slug);
401:         // ACL access check
402:         $this->checkGranted('EDIT', $application);
403:         $layerset = $this->getDoctrine()
404:                 ->getRepository("MapbenderCoreBundle:Layerset")
405:                 ->find($layersetId);
406: 
407:         $form = $this->createForm(new LayersetType(), $layerset);
408: 
409:         return array(
410:             "isnew" => false,
411:             "application" => $application,
412:             'form' => $form->createView());
413:     }
414: 
415:     /**
416:      * Create a new layerset from POSTed data
417:      *
418:      * @ManagerRoute("/application/{slug}/layerset/create")
419:      * @ManagerRoute("/application/{slug}/layerset/{layersetId}/save")
420:      * @Method("POST")
421:      * @Template("MapbenderManagerBundle:Application:form-layerset.html.twig")
422:      */
423:     public function saveLayersetAction($slug, $layersetId = null)
424:     {
425:         $application = $this->get('mapbender')->getApplicationEntity($slug);
426:         $this->checkGranted('EDIT', $application);
427:         if($layersetId === null)
428:         { // new object
429:             $layerset = new Layerset();
430:             $form = $this->createForm(new LayersetType(), $layerset);
431:             $layerset->setApplication($application);
432:         } else
433:         {
434:             $layerset = $this->getDoctrine()
435:                     ->getRepository("MapbenderCoreBundle:Layerset")
436:                     ->find($layersetId);
437:             $form = $this->createForm(new LayersetType(), $layerset);
438:         }
439:         $form->bindRequest($this->get('request'));
440:         if($form->isValid())
441:         {
442:             $this->getDoctrine()->getEntityManager()->persist($layerset);
443:             $this->getDoctrine()->getEntityManager()->flush();
444:             $this->get("logger")->debug("Layerset saved");
445:             $this->get('session')->setFlash('success', "Your layerset has been  saved");
446:             return $this->redirect($this->generateUrl(
447:                                     'mapbender_manager_application_edit',
448:                                     array('slug' => $slug)));
449:         }
450:         $this->get('session')->setFlash('error',
451:                                         'Your form has errors, please review them below.');
452:         return array(
453:             "isnew" => $layerset->getId() === null ? true : false,
454:             "application" => $application,
455:             'form' => $form->createView());
456:     }
457: 
458:     /**
459:      * A confirmation page for a layerset
460:      *
461:      * @ManagerRoute("/application/{slug}/layerset/{layersetId}/confirmdelete")
462:      * @Method("POST")
463:      * @Template("MapbenderManagerBundle:Application:deleteLayerset.html.twig")
464:      */
465:     public function confirmDeleteLayersetAction($slug, $layersetId)
466:     {
467:         $application = $this->get('mapbender')->getApplicationEntity($slug);
468:         $this->checkGranted('EDIT', $application);
469:         $layerset = $this->getDoctrine()
470:                 ->getRepository("MapbenderCoreBundle:Layerset")
471:                 ->find($layersetId);
472:         return array(
473:             'application' => $application,
474:             'layerset' => $layerset,
475:             'form' => $this->createDeleteForm($layerset->getId())->createView()
476:         );
477:     }
478: 
479:     /**
480:      * Delete a layerset
481:      *
482:      * @ManagerRoute("/application/{slug}/layerset/{layersetId}/delete")
483:      * @Method("POST")
484:      */
485:     public function deleteLayersetAction($slug, $layersetId)
486:     {
487:         $application = $this->get('mapbender')->getApplicationEntity($slug);
488:         $this->checkGranted('EDIT', $application);
489:         $layerset = $this->getDoctrine()
490:                 ->getRepository("MapbenderCoreBundle:Layerset")
491:                 ->find($layersetId);
492:         if($layerset !== null)
493:         {
494:             $em = $this->getDoctrine()->getEntityManager();
495: 
496:             $em->getConnection()->beginTransaction();
497: 
498:             $em->remove($layerset);
499:             $em->flush();
500:             $em->getConnection()->commit();
501: 
502:             $this->get("logger")->debug('The layerset "'
503:                     . $layerset->getId() . '"has been deleted.');
504:             $this->get('session')->setFlash('success',
505:                                             'Your layerset has been deleted.');
506:             return $this->redirect($this->generateUrl(
507:                                     'mapbender_manager_application_edit',
508:                                     array('slug' => $slug)) . "#layersets");
509:         }
510:         $this->get('session')->setFlash('error',
511:                                         'Your layerset con not be delete.');
512:         return $this->redirect($this->generateUrl(
513:                                 'mapbender_manager_application_edit',
514:                                 array('slug' => $slug)) . "#layersets");
515:     }
516: 
517:     /* Layerset block end */
518: 
519:     /* Instance block start */
520: 
521:     /**
522:      * Add a new SourceInstance to the Layerset
523:      * @ManagerRoute("/application/{slug}/layerset/{layersetId}/list")
524:      * @Method("POST")
525:      * @Template("MapbenderManagerBundle:Application:list-source.html.twig")
526:      */
527:     public function listInstanceAction($slug, $layersetId, Request $request)
528:     {
529:         $application = $this->get('mapbender')->getApplicationEntity($slug);
530:         // ACL access check
531:         $this->checkGranted('EDIT', $application);
532: 
533:         $layerset = $this->getDoctrine()
534:                 ->getRepository("MapbenderCoreBundle:Layerset")
535:                 ->find($layersetId);
536: 
537:         $securityContext = $this->get('security.context');
538:         $em = $this->getDoctrine()->getEntityManager();
539:         $query = $em->createQuery(
540:                 "SELECT s FROM MapbenderCoreBundle:Source s ORDER BY s.id ASC");
541:         $sources = $query->getResult();
542: 
543:         $allowed_sources = array();
544:         foreach($sources as $source) {
545:             if($securityContext->isGranted('EDIT', $source)) {
546:                 $allowed_sources[] = $source;
547:             }
548:         }
549: 
550:         return array(
551:             'application' => $application,
552:             'layerset' => $layerset,
553:             'sources' => $allowed_sources);
554:     }
555: 
556:     /**
557:      * Add a new SourceInstance to the Layerset
558:      * @ManagerRoute("/application/{slug}/layerset/{layersetId}/source/{sourceId}/add")
559:      * @Method("GET")
560:      */
561:     public function addInstanceAction($slug, $layersetId, $sourceId,
562:             Request $request)
563:     {
564:         $application = $this->get('mapbender')->getApplicationEntity($slug);
565:         // ACL access check
566:         $this->checkGranted('EDIT', $application);
567: 
568:         $layerset = $this->getDoctrine()
569:                 ->getRepository("MapbenderCoreBundle:Layerset")
570:                 ->find($layersetId);
571: 
572:         $source = $this->getDoctrine()
573:                 ->getRepository("MapbenderCoreBundle:Source")
574:                 ->find($sourceId);
575: 
576:         $sourceInstance = $source->createInstance();
577:         $sourceInstance->setLayerset($layerset);
578:         $sourceInstance->setWeight(-1);
579: 
580:         $layerset->addInstance($sourceInstance);
581:         $em = $this->getDoctrine()->getEntityManager();
582:         $em->persist($sourceInstance);
583:         $em->persist($application);
584:         $em->persist($layerset);
585:         $em->flush();
586: 
587:         $num = 0;
588:         foreach($layerset->getInstances() as $instance)
589:         {
590:             $instance->setWeight($num);
591:             $instance->generateConfiguration();
592:             $em->persist($instance);
593:             $em->flush();
594:             $num++;
595:         }
596: 
597:         $this->get("logger")->debug('A new instance "'
598:                 . $sourceInstance->getId() . '"has been created. Please edit it!');
599:         $this->get('session')->setFlash('success',
600:                                         'A new instance has been created. Please edit it!');
601:         return $this->redirect(
602:                         $this->generateUrl(
603:                                 "mapbender_manager_repository_instance",
604:                                 array("slug" => $slug, "instanceId" => $sourceInstance->getId()))
605:         );
606:     }
607: 
608:     /**
609:      * Delete a source instance from a layerset
610:      * @ManagerRoute("/application/{slug}/layerset/{layersetId}/instance/{instanceId}/delete")
611:      * @Method("POST")
612:      *
613:      */
614:     public function deleteInstanceAction($slug, $layersetId, $instanceId)
615:     {
616:         $application = $this->get('mapbender')->getApplicationEntity($slug);
617:         // ACL access check
618:         $this->checkGranted('EDIT', $application);
619:         $sourceInst = $this->getDoctrine()
620:                 ->getRepository("MapbenderCoreBundle:SourceInstance")
621:                 ->find($instanceId);
622: 
623:         $managers = $this->get('mapbender')->getRepositoryManagers();
624:         $manager = $managers[$sourceInst->getSource()->getManagertype()];
625: 
626:         return $this->forward(
627:                         $manager['bundle'] . ":" . "Repository:deleteInstance",
628:                         array("slug" => $slug, "instanceId" => $instanceId));
629:     }
630: 
631:     /* Instance block end */
632: 
633:     /**
634:      * Create the application form, set extra options needed
635:      */
636:     private function createApplicationForm($application)
637:     {
638:         $available_templates = array();
639:         foreach($this->get('mapbender')->getTemplates() as $templateClassName)
640:         {
641:             $available_templates[$templateClassName] =
642:                     $templateClassName::getTitle();
643:         }
644:         asort($available_templates);
645: 
646:         return $this->createForm(new ApplicationType(), $application,
647:                                  array(
648:                     'available_templates' => $available_templates));
649:     }
650: 
651:     /**
652:      * Collect available elements
653:      */
654:     private function getElementList()
655:     {
656:         $available_elements = array();
657:         foreach($this->get('mapbender')->getElements() as $elementClassName)
658:         {
659:             $available_elements[$elementClassName] = array(
660:                 'title' => $elementClassName::getClassTitle(),
661:                 'description' => $elementClassName::getClassDescription(),
662:                 'tags' => $elementClassName::getClassTags());
663:         }
664:         asort($available_elements);
665: 
666:         return $available_elements;
667:     }
668: 
669:     /**
670:      * Creates the form for the delete confirmation page
671:      */
672:     private function createDeleteForm($id)
673:     {
674:         return $this->createFormBuilder(array('id' => $id))
675:                         ->add('id', 'hidden')
676:                         ->getForm();
677:     }
678: 
679:     /**
680:      * Checks the grant for an action and an object
681:      *
682:      * @param string $action action "CREATE"
683:      * @param \Object $object the object
684:      * @throws AccessDeniedException
685:      */
686:     private function checkGranted($action, $object)
687:     {
688:         $securityContext = $this->get('security.context');
689:         if($action === "CREATE")
690:         {
691:             $oid = new ObjectIdentity('class', get_class($object));
692:             if(false === $securityContext->isGranted($action, $oid))
693:             {
694:                 throw new AccessDeniedException();
695:             }
696:         } else if($action === "VIEW" && !$securityContext->isGranted($action,
697:                                                                      $object))
698:         {
699:             throw new AccessDeniedException();
700:         } else if($action === "EDIT" && !$securityContext->isGranted($action,
701:                                                                      $object))
702:         {
703:             throw new AccessDeniedException();
704:         } else if($action === "DELETE" && !$securityContext->isGranted($action,
705:                                                                        $object))
706:         {
707:             throw new AccessDeniedException();
708:         }
709:     }
710: 
711: }
712: 
713: 
Mapbender3 API documenation API documentation generated by ApiGen 2.8.0