1: <?php
2: namespace Mapbender\WmtsBundle\Entity;
3:
4: use Doctrine\Common\Collections\ArrayCollection;
5:
6:
7: /**
8: * Theme class
9: *
10: * @author Paul Schmidt
11: */
12: class Theme {
13:
14: protected $identifier = "";
15:
16: protected $title = "";
17:
18: protected $abstract = "";
19:
20: protected $layerref = "";
21:
22: protected $theme;
23:
24: public function __construct(){
25: $this->theme = new ArrayCollection();
26: }
27:
28: public function loadFromArray($theme = null, $theme_arr) {
29: $theme = $theme=null? $this: $theme;
30: $theme->setIdentifier($theme_arr["identifier"]);
31: $theme->setTitle($theme_arr["title"]);
32: $theme->setAbstract($theme_arr["abstract"]);
33: foreach ($theme_arr["theme"] as $subtheme) {
34: $theme->addTheme(new Theme(), $subtheme);
35: }
36: return $theme;
37: }
38: /**
39: * Get identifier
40: * @return string identifier
41: */
42: public function getIdentifier() {
43: return $this->identifier;
44: }
45: /**
46: * Set identifier
47: * @param string $identifier
48: */
49: public function setIdentifier($identifier) {
50: $this->identifier = $identifier;
51: }
52:
53: /**
54: * Get title
55: * @return string title
56: */
57: public function getTitle() {
58: return $this->title;
59: }
60: /**
61: * Set title
62: * @param string $title
63: */
64: public function setTitle($title) {
65: $this->title = $title;
66: }
67:
68: /**
69: * Get abstract
70: * @return string abstract
71: */
72: public function getAbstract() {
73: return $this->abstract;
74: }
75: /**
76: * Set abstract
77: * @param string $abstract
78: */
79: public function setAbstract($abstract) {
80: $this->abstract = $abstract;
81: }
82: /**
83: * Get layerref
84: * @return string layerref
85: */
86: public function getLayerRef() {
87: return $this->layerref;
88: }
89: /**
90: * Set layerref
91: * @param string $layerref
92: */
93: public function setLayerRef($layerref) {
94: $this->layerref = $layerref;
95: }
96: /**
97: * Get theme
98: * @return arrray theme
99: */
100: public function getTheme() {
101: return $this->theme;
102: }
103: /**
104: * Set theme
105: * @param array $theme
106: */
107: public function setTheme($theme) {
108: $this->theme = $theme;
109: }
110:
111: /**
112: * Add theme into theme
113: * @param Theme $theme
114: */
115: public function addTheme($theme) {
116: $this->theme->add($theme);
117: }
118: public function getAsArray() {
119: $theme = $this;
120: $themes = array();
121: $themes["identifier"] = $theme->getIdentifier();
122: $themes["title"] = $theme->getTitle();
123: $themes["abstract"] = $theme->getAbstract();
124: $themes["layerref"] = $theme->getLayerRef();
125: $arr = $theme->getTheme();
126: foreach ($theme->getTheme() as $subtheme){
127: // $themes["theme"][] = $subtheme->getAsArray($subtheme, $subtheme->getTheme());
128: $themes["theme"][] = $subtheme->getAsArray();
129: }
130: return $themes;
131: }
132: }