Skip to content

Commit 1430887

Browse files
committed
Implement review fixes
1 parent 0489678 commit 1430887

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

system/Config/View.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
*/
1717
class View extends BaseConfig
1818
{
19+
/**
20+
* When false, the view method will clear the data between each
21+
* call.
22+
*
23+
* @var boolean
24+
*/
25+
public $saveData = true;
26+
1927
/**
2028
* Parser Filters map a filter name with any PHP callable. When the
2129
* Parser prepares a variable for display, it will chain it

system/View/View.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function __construct(ViewConfig $config, string $viewPath = null, FileLoc
142142
$this->loader = $loader ?? Services::locator();
143143
$this->logger = $logger ?? Services::logger();
144144
$this->debug = $debug ?? CI_DEBUG;
145-
$this->saveData = $config->saveData ?? null;
145+
$this->saveData = (bool) $config->saveData;
146146
}
147147

148148
//--------------------------------------------------------------------
@@ -156,7 +156,7 @@ public function __construct(ViewConfig $config, string $viewPath = null, FileLoc
156156
* - cache_name Name to use for cache
157157
*
158158
* @param string $view File name of the view source
159-
* @param array $options Reserved for 3rd-party uses since
159+
* @param array|null $options Reserved for 3rd-party uses since
160160
* it might be needed to pass additional info
161161
* to other template engines.
162162
* @param boolean|null $saveData If true, saves data for subsequent calls,
@@ -176,7 +176,7 @@ public function render(string $view, array $options = null, bool $saveData = nul
176176
$fileExt = pathinfo($view, PATHINFO_EXTENSION);
177177
$realPath = empty($fileExt) ? $view . '.php' : $view; // allow Views as .html, .tpl, etc (from CI3)
178178
$this->renderVars['view'] = $realPath;
179-
$this->renderVars['options'] = $options;
179+
$this->renderVars['options'] = $options ?? [];
180180

181181
// Was it cached?
182182
if (isset($this->renderVars['options']['cache']))
@@ -277,7 +277,7 @@ public function render(string $view, array $options = null, bool $saveData = nul
277277
* Cache does not apply, because there is no "key".
278278
*
279279
* @param string $view The view contents
280-
* @param array $options Reserved for 3rd-party uses since
280+
* @param array|null $options Reserved for 3rd-party uses since
281281
* it might be needed to pass additional info
282282
* to other template engines.
283283
* @param boolean|null $saveData If true, saves data for subsequent calls,

0 commit comments

Comments
 (0)