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

  • MapFieldSubscriber
  • PrintClientSubscriber
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download
 1: <?php
 2: 
 3: namespace Mapbender\CoreBundle\Form\EventListener;
 4: 
 5: use Symfony\Component\Form\Event\DataEvent;
 6: use Symfony\Component\Form\FormFactoryInterface;
 7: use Symfony\Component\EventDispatcher\EventSubscriberInterface;
 8: use Symfony\Component\Form\FormEvents;
 9: 
10: /**
11:  * 
12:  */
13: class MapFieldSubscriber implements EventSubscriberInterface
14: {
15: 
16:     /**
17:      * @inheritdoc
18:      */
19:     public function __construct(FormFactoryInterface $factory)
20:     {
21:         
22:     }
23: 
24:     /**
25:      * @inheritdoc
26:      */
27:     public static function getSubscribedEvents()
28:     {
29:         return array(
30:             FormEvents::PRE_SET_DATA => 'preSetData',
31:             FormEvents::PRE_BIND => 'preBind');
32:     }
33: 
34:     /**
35:      * Checkt form fields by PRE_BIND DataEvent
36:      * 
37:      * @param DataEvent $event
38:      */
39:     public function preBind(DataEvent $event)
40:     {
41:         $data = $event->getData();
42: 
43:         if(null === $data)
44:         {
45:             return;
46:         }
47:         if(key_exists("otherSrs", $data) && is_string($data["otherSrs"]))
48:         {
49:             $data["otherSrs"] = preg_split("/\s?,\s?/", $data["otherSrs"]);
50:             $event->setData($data);
51:         }
52:         if(key_exists("scales", $data) && is_string($data["scales"]))
53:         {
54:             $data["scales"] = preg_split("/\s?,\s?/", $data["scales"]);
55:             $event->setData($data);
56:         }
57:     }
58: 
59:     /**
60:      * Checkt form fields by PRE_SET_DATA DataEvent
61:      * 
62:      * @param DataEvent $event
63:      */
64:     public function preSetData(DataEvent $event)
65:     {
66:         $data = $event->getData();
67:         if(null === $data)
68:         {
69:             return;
70:         }
71: 
72:         if(key_exists("otherSrs", $data) && is_array($data["otherSrs"]))
73:         {
74:             $data["otherSrs"] = implode(",", $data["otherSrs"]);
75:             $event->setData($data);
76:         }
77:         if(key_exists("scales", $data) && is_array($data["scales"]))
78:         {
79:             $data["scales"] = implode(",", $data["scales"]);
80:             $event->setData($data);
81:         }
82:     }
83: 
84: }
Mapbender3 API documenation API documentation generated by ApiGen 2.8.0