1 | <?php |
||
28 | abstract class AbstractSection implements Section |
||
29 | { |
||
30 | |||
31 | /** |
||
32 | * Name of the Section. |
||
33 | * |
||
34 | * @since 1.0.0 |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $sectionName; |
||
39 | |||
40 | /** |
||
41 | * Configuration Settings. |
||
42 | * |
||
43 | * @since 1.0.0 |
||
44 | * |
||
45 | * @var ConfigInterface |
||
46 | */ |
||
47 | protected $config; |
||
48 | |||
49 | /** |
||
50 | * Content of the section. |
||
51 | * |
||
52 | * @since 1.0.0 |
||
53 | * |
||
54 | * @var string |
||
55 | */ |
||
56 | protected $content; |
||
57 | |||
58 | /** |
||
59 | * ViewBuilder to create template and section views. |
||
60 | * |
||
61 | * @since 1.0.0 |
||
62 | * |
||
63 | * @var ViewBuilder |
||
64 | */ |
||
65 | protected $viewBuilder; |
||
66 | |||
67 | /** |
||
68 | * Instantiate a AbstractSection object. |
||
69 | * |
||
70 | * @since 1.0.0 |
||
71 | * |
||
72 | * @param ConfigInterface $config Configuration settings. |
||
73 | * @param array $arguments Arguments that are passed through the constructor. |
||
74 | * Contained elements: |
||
75 | * string $section, string $content |
||
76 | * |
||
77 | * @throws RuntimeException |
||
78 | */ |
||
79 | 8 | public function __construct($config, array $arguments) |
|
86 | |||
87 | /** |
||
88 | * Get the name of the Section. |
||
89 | * |
||
90 | * @since 1.0.0 |
||
91 | * |
||
92 | * @return string Name of the section. |
||
93 | */ |
||
94 | 8 | public function getSectionName() |
|
98 | |||
99 | /** |
||
100 | * Set the name of the Section. |
||
101 | * |
||
102 | * @since 1.0.0 |
||
103 | * |
||
104 | * @param string|null $section Optional. Name of the section. |
||
105 | * |
||
106 | * @throws FailedToInitialiseSection If no section name was passed. |
||
107 | * @throws FailedToInitialiseSection If an unknown section name was passed. |
||
108 | */ |
||
109 | 8 | protected function setSectionName($section = null) |
|
123 | |||
124 | /** |
||
125 | * Render the current Renderable for a given context. |
||
126 | * |
||
127 | * @since 1.0.0 |
||
128 | * |
||
129 | * @param array $context The context in which to render the Renderable. |
||
130 | * |
||
131 | * @return string Rendered output of the Renderable. |
||
132 | * @throws RuntimeException |
||
133 | */ |
||
134 | 8 | public function render(array $context) |
|
145 | |||
146 | /** |
||
147 | * Get the name of the View to use for rendering. |
||
148 | * |
||
149 | * @since 1.0.0 |
||
150 | * |
||
151 | * @param array $context The context in which to render the template. |
||
152 | * |
||
153 | * @return string Name of the view. |
||
154 | */ |
||
155 | 8 | protected function getViewName(array $context) |
|
160 | |||
161 | /** |
||
162 | * Get the CSS class that is used for the section. |
||
163 | * |
||
164 | * @since 1.0.0 |
||
165 | * |
||
166 | * @return string |
||
167 | */ |
||
168 | 8 | protected function getCSSClass() |
|
172 | } |
||
173 |