1: <?php
2:
3: namespace Charcoal\Cms\Config;
4:
5: // Local dependencies
6: use Charcoal\Cms\Config\EventConfig;
7: use Charcoal\Cms\Config\NewsConfig;
8: use Charcoal\Cms\Config\SectionConfig;
9:
10: // dependencies from `charcoal-base`
11: use Charcoal\Config\AbstractConfig;
12: use Charcoal\Model\ModelInterface;
13:
14: /**
15: * Class Config
16: */
17: class CmsConfig extends AbstractConfig
18: {
19: /**
20: * @var string $defaultFromEmail
21: */
22: protected $defaultFromEmail;
23:
24: /**
25: * @var array $homeNews
26: */
27: protected $homeNews;
28:
29: /**
30: * @var array $homeEvents
31: */
32: protected $homeEvents;
33:
34: /**
35: * @var NewsConfig $newsConfig
36: */
37: protected $newsConfig;
38:
39: /**
40: * @var EventConfig $eventConfig
41: */
42: protected $eventConfig;
43:
44: /**
45: * @var SectionConfig $sectionConfig
46: */
47: protected $sectionConfig;
48:
49: /**
50: * @var string $contactCategoryObj Must conform Cms\\Support\\Interface\\ContactCategoryInterface.
51: */
52: protected $contactCategoryObj;
53:
54: /**
55: * @var string $defaultContactCategory The default contact category to fallback.
56: */
57: protected $defaultContactCategory;
58:
59: /**
60: * @var string $contactObj Must conform Cms\\Support\\Interface\\ContactInterface.
61: */
62: protected $contactObj;
63:
64: /**
65: * @var array $dateFormats
66: */
67: protected $dateFormats = [];
68:
69: /**
70: * @var array $timeFormats
71: */
72: protected $timeFormats = [];
73:
74: // ==========================================================================
75: // INIT
76: // ==========================================================================
77:
78: /**
79: * @param ModelInterface $model The object model.
80: * @return void
81: */
82: public function addModel(ModelInterface $model)
83: {
84: $this->setData($model->data());
85: }
86:
87: // ==========================================================================
88: // SETTERS
89: // ==========================================================================
90:
91: /**
92: * @param mixed $defaultFromEmail The default email for contact forms.
93: * @return self
94: */
95: public function setDefaultFromEmail($defaultFromEmail)
96: {
97: $this->defaultFromEmail = $defaultFromEmail;
98:
99: return $this;
100: }
101:
102: /**
103: * @param mixed $homeNews The news to display on home page.
104: * @return self
105: */
106: public function setHomeNews($homeNews)
107: {
108: $this->homeNews = $homeNews;
109:
110: return $this;
111: }
112:
113: /**
114: * @param mixed $homeEvents The events to display on home page.
115: * @return self
116: */
117: public function setHomeEvents($homeEvents)
118: {
119: $this->homeEvents = $homeEvents;
120:
121: return $this;
122: }
123:
124: /**
125: * @param array $newsConfig The news configuration object.
126: * @return $this
127: */
128: public function setNews(array $newsConfig)
129: {
130: if (!$this->newsConfig) {
131: $this->newsConfig = new NewsConfig();
132: }
133:
134: $this->newsConfig->setData($newsConfig);
135:
136: return $this;
137: }
138:
139: /**
140: * @param array $eventConfig The event configuration object.
141: * @return $this
142: */
143: public function setEvent(array $eventConfig)
144: {
145: if (!$this->eventConfig) {
146: $this->eventConfig = new EventConfig();
147: }
148:
149: $this->eventConfig->setData($eventConfig);
150:
151: return $this;
152: }
153:
154: /**
155: * @param array $sectionConfig The section configuration object.
156: * @return $this
157: */
158: public function setSection(array $sectionConfig)
159: {
160: if (!$this->sectionConfig) {
161: $this->sectionConfig = new SectionConfig();
162: }
163:
164: $this->sectionConfig->setData($sectionConfig);
165:
166: return $this;
167: }
168:
169: /**
170: * @param string $contactCategory Must conform City\\Support\\Interface\\ContactCategoryInterface.
171: * @return self
172: */
173: public function setContactCategoryObj($contactCategory)
174: {
175: $this->contactCategoryObj = $contactCategory;
176:
177: return $this;
178: }
179:
180: /**
181: * @param string $contactObj Must conform City\\Support\\Interface\\ContactInterface.
182: * @return self
183: */
184: public function setContactObj($contactObj)
185: {
186: $this->contactObj = $contactObj;
187:
188: return $this;
189: }
190:
191: /**
192: * @param string $defaultContactCategory The default contact category fallback.
193: * @return self
194: */
195: public function setDefaultContactCategory($defaultContactCategory)
196: {
197: $this->defaultContactCategory = $defaultContactCategory;
198:
199: return $this;
200: }
201:
202: /**
203: * @param array $dateFormats Formats for full dates.
204: * @return self
205: */
206: public function setDateFormats(array $dateFormats)
207: {
208: $this->dateFormats = array_replace_recursive(
209: $this->dateFormats,
210: $dateFormats
211: );
212:
213: return $this;
214: }
215:
216: /**
217: * @param array $timeFormats Formats for time.
218: * @return self
219: */
220: public function setTimeFormats(array $timeFormats)
221: {
222: $this->timeFormats = array_replace_recursive(
223: $this->timeFormats,
224: $timeFormats
225: );
226:
227: return $this;
228: }
229:
230: // ==========================================================================
231: // GETTERS
232: // ==========================================================================
233:
234: /**
235: * @return mixed
236: */
237: public function defaultFromEmail()
238: {
239: return $this->defaultFromEmail;
240: }
241:
242: /**
243: * @return mixed
244: */
245: public function homeNews()
246: {
247: return $this->homeNews;
248: }
249:
250: /**
251: * @return mixed
252: */
253: public function homeEvents()
254: {
255: return $this->homeEvents;
256: }
257:
258: /**
259: * @return NewsConfig
260: */
261: public function newsConfig()
262: {
263: return $this->newsConfig;
264: }
265:
266: /**
267: * @return EventConfig
268: */
269: public function eventConfig()
270: {
271: return $this->eventConfig;
272: }
273:
274: /**
275: * @return SectionConfig
276: */
277: public function sectionConfig()
278: {
279: return $this->sectionConfig;
280: }
281:
282: /**
283: * @return string
284: */
285: public function contactCategoryObj()
286: {
287: return $this->contactCategoryObj;
288: }
289:
290: /**
291: * @return string
292: */
293: public function contactObj()
294: {
295: return $this->contactObj;
296: }
297:
298: /**
299: * @return string
300: */
301: public function defaultContactCategory()
302: {
303: return $this->defaultContactCategory;
304: }
305:
306: /**
307: * @return array
308: */
309: public function dateFormats()
310: {
311: return $this->dateFormats;
312: }
313:
314: /**
315: * @return array
316: */
317: public function timeFormats()
318: {
319: return $this->timeFormats;
320: }
321: }
322: