1: <?php
2:
3: namespace Charcoal\Cms;
4:
5: /**
6: * Default implementation, as Trait,
7: * of the {@see \Charcoal\Cms\TemplateableInterface}.
8: */
9: trait TemplateableTrait
10: {
11: /**
12: * The object's template identifier.
13: *
14: * @var mixed
15: */
16: private $templateIdent;
17:
18: /**
19: * The object's template controller identifier.
20: *
21: * @var mixed
22: */
23: private $controllerIdent;
24:
25: /**
26: * The customized template options.
27: *
28: * @var array
29: */
30: private $templateOptions = [];
31:
32: /**
33: * Set the renderable object's template identifier.
34: *
35: * @param mixed $template The template ID.
36: * @return self
37: */
38: public function setTemplateIdent($template)
39: {
40: $this->templateIdent = $template;
41:
42: return $this;
43: }
44:
45: /**
46: * Retrieve the renderable object's template identifier.
47: *
48: * @return mixed
49: */
50: public function templateIdent()
51: {
52: return $this->templateIdent;
53: }
54:
55: /**
56: * Set the renderable object's template controller identifier.
57: *
58: * @param mixed $ident The template controller identifier.
59: * @return self
60: */
61: public function setControllerIdent($ident)
62: {
63: $this->controllerIdent = $ident;
64:
65: return $this;
66: }
67:
68: /**
69: * Retrieve the renderable object's template controller identifier.
70: *
71: * @return mixed
72: */
73: public function controllerIdent()
74: {
75: return $this->controllerIdent;
76: }
77:
78: /**
79: * Customize the template's options.
80: *
81: * @param mixed $options Template options.
82: * @return self
83: */
84: public function setTemplateOptions($options)
85: {
86: if (is_string($options)) {
87: $options = json_decode($options, true);
88: }
89:
90: $this->templateOptions = $options;
91:
92: return $this;
93: }
94:
95: /**
96: * Retrieve the template's customized options.
97: *
98: * @return array
99: */
100: public function templateOptions()
101: {
102: return $this->templateOptions;
103: }
104: }
105: