1 | <?php |
||
20 | class ReadmeController extends \hidev\controllers\TemplateController |
||
21 | { |
||
22 | /** |
||
23 | * @var \Twig_Environment |
||
24 | */ |
||
25 | protected $_twig; |
||
26 | |||
27 | /** |
||
28 | * @var array list of sections to render |
||
29 | */ |
||
30 | protected $_sections; |
||
31 | |||
32 | /** |
||
33 | * Get charset. |
||
34 | * @return string |
||
35 | */ |
||
36 | public function getCharset() |
||
37 | { |
||
38 | return (isset(Yii::$app->charset) ? Yii::$app->charset : null) ?: mb_internal_encoding(); |
||
39 | } |
||
40 | |||
41 | 4 | public function renderH($title, $prefix) |
|
45 | |||
46 | 3 | public function renderH1($title) |
|
50 | |||
51 | 1 | public function renderH2($title) |
|
55 | |||
56 | public function renderH3($title) |
||
60 | |||
61 | 1 | public function renderText($text) |
|
67 | |||
68 | 1 | public function renderBold($text) |
|
74 | |||
75 | 2 | public function renderSection($section, $default = null) |
|
84 | |||
85 | 2 | public function getSection($file, $default = null) |
|
97 | |||
98 | /** |
||
99 | * Set sections list. |
||
100 | * @param array $value |
||
101 | */ |
||
102 | public function setSections($value) |
||
106 | |||
107 | /** |
||
108 | * Returns sections list. Returns default list if not set. |
||
109 | * @return array |
||
110 | */ |
||
111 | 2 | public function getSections() |
|
112 | { |
||
113 | 2 | if (empty($this->_sections)) { |
|
114 | 2 | $this->_sections = ['Requirements', 'Installation', 'Idea', 'Configuration', 'Basic Usage', 'Usage', 'Support', 'License', 'Acknowledgements', 'Acknowledgments']; |
|
115 | 2 | } |
|
116 | |||
117 | 2 | return array_unique($this->_sections); |
|
118 | } |
||
119 | |||
120 | /** |
||
121 | * Render all configured sections. |
||
122 | * @return string |
||
123 | */ |
||
124 | 2 | public function renderSections($sections = null) |
|
125 | { |
||
126 | 2 | if ($sections === null) { |
|
127 | 2 | $sections = $this->getSections(); |
|
128 | 2 | } |
|
129 | 2 | $res = ''; |
|
130 | 2 | foreach ($sections as $section) { |
|
131 | 2 | $res .= $this->renderSection($section); |
|
132 | 2 | } |
|
133 | |||
134 | 2 | return $res; |
|
135 | } |
||
136 | |||
137 | /** |
||
138 | * Render all configured badges. |
||
139 | * @return string |
||
140 | */ |
||
141 | 2 | public function renderBadges() |
|
142 | { |
||
143 | 2 | $badges = $this->badges; |
|
|
|||
144 | 2 | if (!$badges) { |
|
145 | return ''; |
||
146 | } |
||
147 | 2 | $pm = $this->takeGoal('package')->getPackageManager(); |
|
148 | 2 | if (!$pm || !$pm->getConfiguration()->getRequire()) { |
|
149 | 2 | unset($badges['versioneye.dependencies']); |
|
150 | 2 | } |
|
151 | 2 | $res = ''; |
|
152 | 2 | foreach ($badges as $badge => $tpl) { |
|
153 | 2 | if (!$tpl) { |
|
154 | 2 | $tpl = $this->markdownBadges[$badge]; |
|
155 | 2 | } |
|
156 | 2 | if ($tpl === 'disabled') { |
|
157 | continue; |
||
158 | } |
||
159 | 2 | $res .= $this->renderBadge($tpl) . "\n"; |
|
160 | 2 | } |
|
161 | |||
162 | 2 | return $res ? "\n$res" : ''; |
|
163 | } |
||
164 | |||
165 | /** |
||
166 | * Render badge by given template. |
||
167 | * @param string $template string to render |
||
168 | * @return string |
||
169 | */ |
||
170 | 2 | public function renderBadge($template) |
|
174 | |||
175 | /** |
||
176 | * Twig getter. |
||
177 | * @return \Twig_Environment |
||
178 | */ |
||
179 | 2 | public function getTwig() |
|
187 | } |
||
188 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.