1: <?php
2:
3: namespace Mapbender\CoreBundle\Component;
4:
5: use Mapbender\CoreBundle\Entity\State;
6:
7: /**
8: * Description of State
9: *
10: * @author Paul Schmidt
11: */
12: class StateHandler
13: {
14:
15: private $id;
16:
17: private $name;
18:
19: private $serverurl;
20:
21: private $slug;
22:
23: private $window;
24:
25: private $extent;
26:
27: private $maxextent;
28:
29: private $sources = array();
30:
31: /**
32: * Sets id
33: *
34: * @param type $value
35: * @return StateHandler
36: */
37: public function setId($value){
38: $this->id = $value;
39: return $this;
40: }
41:
42: /**
43: * Returns id
44: *
45: * @return integer
46: */
47: public function getId(){
48: return $this->id;
49: }
50:
51: /**
52: * Sets name
53: *
54: * @param string $value
55: * @return StateHandler
56: */
57: public function setName($value){
58: $this->name = $value;
59: return $this;
60: }
61:
62: /**
63: * Returns name
64: *
65: * @return string
66: */
67: public function getName(){
68: return $this->name;
69: }
70:
71:
72:
73: /**
74: * Sets serverurl
75: *
76: * @param string $value
77: * @return StateHandler
78: */
79: public function setServerurl($value){
80: $this->serverurl = $value;
81: return $this;
82: }
83:
84: /**
85: * Returns serverurl
86: *
87: * @return string
88: */
89: public function getServerurl(){
90: return $this->serverurl;
91: }
92:
93:
94:
95: /**
96: * Sets slug
97: *
98: * @param string $value
99: * @return StateHandler
100: */
101: public function setSlug($value){
102: $this->slug = $value;
103: return $this;
104: }
105:
106: /**
107: * Returns slug
108: *
109: * @return string
110: */
111: public function getSlug(){
112: return $this->slug;
113: }
114:
115:
116:
117: /**
118: * Sets window
119: *
120: * @param Size $value
121: * @return StateHandler
122: */
123: public function setWindow(Size $value){
124: $this->window = $value;
125: return $this;
126: }
127:
128: /**
129: * Returns window
130: *
131: * @return Size
132: */
133: public function getWindow(){
134: return $this->window;
135: }
136:
137:
138:
139: /**
140: * Sets extent
141: *
142: * @param BoundingBox $value
143: * @return StateHandler
144: */
145: public function setExtent(BoundingBox $value){
146: $this->extent = $value;
147: return $this;
148: }
149:
150: /**
151: * Returns extent
152: *
153: * @return BoundingBox
154: */
155: public function getExtent(){
156: return $this->extent;
157: }
158:
159:
160:
161: /**
162: * Sets maxextent
163: *
164: * @param BoundingBox $value
165: * @return StateHandler
166: */
167: public function setMaxextent(BoundingBox $value){
168: $this->maxextent = $value;
169: return $this;
170: }
171:
172: /**
173: * Returns maxextent
174: *
175: * @return BoundingBox
176: */
177: public function getMaxextent(){
178: return $this->maxextent;
179: }
180:
181: /**
182: * Sets sources
183: *
184: * @param array $value
185: * @return StateHandler
186: */
187: public function setSources($value){
188: $this->sources = $value;
189: return $this;
190: }
191:
192: /**
193: * Returns sources
194: *
195: * @return array
196: */
197: public function getSources(){
198: return $this->sources;
199: }
200:
201: /**
202: * Adds source
203: *
204: * @return StateHandler
205: */
206: public function addSource($value){
207: $this->sources[] = $value;
208: return $this;
209: }
210:
211: /**
212: * Creates a StateHandler from parameters
213: *
214: * @param array $json
215: * @return StateHandler
216: */
217: public static function create($json, $id = null, $name = null, $serverurl = null, $slug = null){
218: $sh = new StateHandler();
219: $sh->setId($id);
220: $sh->setName($name);
221: $sh->setServerurl($serverurl);
222: $sh->setSlug($slug);
223: $sh->setWindow(Size::create($json["window"]));
224: $sh->setExtent(BoundingBox::create($json["extent"]));
225: $sh->setMaxextent(BoundingBox::create($json["maxextent"]));
226: $sh->setSources($json["sources"]);
227: return $sh;
228: }
229:
230: public function generateState(){
231: $state = new State();
232: $state->setTitle($this->name)
233: ->setServerurl($this->serverurl)
234: ->setSlug($this->slug)
235: ->setJson($this->toArray());
236: return $state;
237: }
238:
239: public function toArray()
240: {
241: return array(
242: "window" => $this->window->toArray(),
243: "extent" => $this->extent->ToArray(),
244: "maxextent" => $this->maxextent->ToArray(),
245: "sources" => $this->sources);
246: }
247:
248: //
249: // /**
250: // * Sets
251: // *
252: // * @param type $value
253: // * @return StateHandler
254: // */
255: // public function set($value){
256: // $this-> = $value;
257: // return $this;
258: // }
259: //
260: // /**
261: // * Returns
262: // *
263: // * @return integer
264: // */
265: // public function get(){
266: // return $this->;
267: // }
268:
269: }
270:
271: ?>
272: