1: <?php
2:
3: /**
4: * TODO: License
5: */
6:
7: namespace Mapbender\CoreBundle\Entity;
8:
9: use Doctrine\ORM\Mapping as ORM;
10: use Symfony\Component\Validator\Constraints as Assert;
11:
12: /**
13: * Element configuration entity
14: *
15: * @author Christian Wygoda <christian.wygoda@wheregroup.com>
16: *
17: * @ORM\Entity
18: * @ORM\Table(name="mb_core_element")
19: */
20: class Element
21: {
22:
23: /**
24: * @var integer $id
25: * @ORM\Id
26: * @ORM\Column(type="integer")
27: * @ORM\GeneratedValue(strategy="AUTO")
28: */
29: protected $id;
30:
31: /**
32: * @var string $title The element title
33: * @ORM\Column(type="string", length=128)
34: * @Assert\NotBlank()
35: */
36: protected $title;
37:
38: /**
39: * @var string $class The element class
40: * @ORM\Column(type="string", length=1024)
41: */
42: protected $class;
43:
44: /**
45: * @var array $configuration The element configuration
46: * @ORM\Column(type="array", nullable=true)
47: */
48: protected $configuration;
49:
50: /**
51: * @var Application The configuration entity for the application
52: * @ORM\ManyToOne(targetEntity="Application", inversedBy="elements")
53: */
54: protected $application;
55:
56: /**
57: * @var string $region The template region for the element
58: * @ORM\Column()
59: */
60: protected $region;
61:
62: /**
63: * @ORM\Column(type="boolean", nullable=true)
64: */
65: protected $enabled = true;
66:
67: /**
68: * @var integer $weight The sorting weight for display
69: * @ORM\Column(type="integer")
70: */
71: protected $weight;
72:
73: public function __construct()
74: {
75: $this->enabled = true;
76: }
77:
78: /**
79: * Set id. DANGER
80: *
81: * Set the entity id. DO NOT USE THIS unless you know what you're doing.
82: * Probably the only place where this should be used is in the
83: * ApplicationYAMLMapper class. Maybe this could be done using a proxy
84: * class instead?
85: */
86: public function setId($id)
87: {
88: $this->id = $id;
89: return $this;
90: }
91:
92: /**
93: * Get id
94: *
95: * @return integer
96: */
97: public function getId()
98: {
99: return $this->id;
100: }
101:
102: /**
103: * Set title
104: *
105: * @param string $title
106: */
107: public function setTitle($title)
108: {
109: $this->title = $title;
110: return $this;
111: }
112:
113: /**
114: * Get title
115: *
116: * @return string
117: */
118: public function getTitle()
119: {
120: return $this->title;
121: }
122:
123: /**
124: * Set class
125: *
126: * @param string $class
127: */
128: public function setClass($class)
129: {
130: $this->class = $class;
131: return $this;
132: }
133:
134: /**
135: * Get class
136: *
137: * @return string
138: */
139: public function getClass()
140: {
141: return $this->class;
142: }
143:
144: /**
145: * Set configuration
146: *
147: * @param array $configuration
148: */
149: public function setConfiguration($configuration)
150: {
151: $this->configuration = $configuration;
152: return $this;
153: }
154:
155: /**
156: * Get configuration
157: *
158: * @return array
159: */
160: public function getConfiguration()
161: {
162: return $this->configuration;
163: }
164:
165: /**
166: * Set region
167: *
168: * @param string $region
169: */
170: public function setRegion($region)
171: {
172: $this->region = $region;
173: return $this;
174: }
175:
176: /**
177: * Get region
178: *
179: * @return string
180: */
181: public function getRegion()
182: {
183: return $this->region;
184: }
185:
186: /**
187: * Set enabled
188: *
189: * @param boolean $enabled
190: */
191: public function setEnabled($enabled)
192: {
193: $this->enabled = $enabled;
194: return $this;
195: }
196:
197: /**
198: * Is enabled?
199: *
200: * @return boolean
201: */
202: public function getEnabled()
203: {
204: return $this->enabled;
205: }
206:
207: /**
208: * Set weight
209: *
210: * @param integer $weight
211: */
212: public function setWeight($weight)
213: {
214: $this->weight = $weight;
215: return $this;
216: }
217:
218: /**
219: * Get weight
220: *
221: * @return integer
222: */
223: public function getWeight()
224: {
225: return $this->weight;
226: }
227:
228: /**
229: * Set application
230: *
231: * @param Mapbender\CoreBundle\Entity\Application $application
232: */
233: public function setApplication(\Mapbender\CoreBundle\Entity\Application $application)
234: {
235: $this->application = $application;
236: return $this;
237: }
238:
239: /**
240: * Get application
241: *
242: * @return Mapbender\CoreBundle\Entity\Application
243: */
244: public function getApplication()
245: {
246: return $this->application;
247: }
248:
249: public function __toString()
250: {
251: return (string) $this->id;
252: }
253:
254: }
255:
256: