View
in package
implements
RendererInterface
uses
ViewDecoratorTrait
Class View
Tags
Table of Contents
Interfaces
- RendererInterface
- Interface RendererInterface
Properties
- $config : View
- $currentSection : string|null
- The name of the current section being rendered, if any.
- $data : array<string, mixed>
- Saved Data.
- $debug : bool
- Should we store performance info?
- $layout : string|null
- The name of the layout being used, if any.
- $loader : FileLocatorInterface
- Instance of FileLocator for when we need to attempt to find a view that's not in standard place.
- $logger : LoggerInterface
- Logger instance.
- $performanceData : array<int, array{start: float, end: float, view: string}>
- Cache stats about our performance here, when CI_DEBUG = true
- $renderVars : array<string, mixed>
- Data for rendering including Caching and Debug Toolbar data.
- $saveData : bool
- Whether data should be saved between renders.
- $sections : array<string, array<int, string>>
- Holds the sections and their data.
- $sectionStack : array<int, string>
- The name of the current section being rendered, if any.
- $tempData : array<string, mixed>|null
- Data for the variables that are available in the Views.
- $viewPath : string
- The base directory to look in for our Views.
- $viewsCount : int
- Number of loaded views
Methods
- __construct() : mixed
- endSection() : void
- Captures the last section
- excerpt() : string
- Extract first bit of a long string and add ellipsis
- extend() : void
- Specifies that the current view should extend an existing layout.
- getData() : array<string, mixed>
- Returns the current data that will be displayed in the view.
- getPerformanceData() : array<int, array{start: float, end: float, view: string}>
- Returns the performance data that might have been collected during the execution. Used primarily in the Debug Toolbar.
- include() : string
- Used within layout views to include additional views.
- render() : string
- Builds the output based upon a file name and any data that has already been set.
- renderSection() : void
- Renders a section's contents.
- renderString() : string
- Builds the output based upon a string and any data that has already been set.
- resetData() : RendererInterface
- Removes all of the view data from the system.
- section() : void
- Starts holds content for a section within the layout.
- setData() : RendererInterface
- Sets several pieces of view data at once.
- setVar() : RendererInterface
- Sets a single piece of view data.
- decorateOutput() : string
- Runs the generated output through any declared view decorators.
- logPerformance() : void
- Logs performance data for rendering a view.
- prepareTemplateData() : void
Properties
$config
protected
View
$config
$currentSection
The name of the current section being rendered, if any.
protected
string|null
$currentSection
$data
Saved Data.
protected
array<string, mixed>
$data
= []
$debug
Should we store performance info?
protected
bool
$debug
= false
$layout
The name of the layout being used, if any.
protected
string|null
$layout
Set by the extend
method used within views.
$loader
Instance of FileLocator for when we need to attempt to find a view that's not in standard place.
protected
FileLocatorInterface
$loader
$logger
Logger instance.
protected
LoggerInterface
$logger
$performanceData
Cache stats about our performance here, when CI_DEBUG = true
protected
array<int, array{start: float, end: float, view: string}>
$performanceData
= []
$renderVars
Data for rendering including Caching and Debug Toolbar data.
protected
array<string, mixed>
$renderVars
= []
$saveData
Whether data should be saved between renders.
protected
bool
$saveData
$sections
Holds the sections and their data.
protected
array<string, array<int, string>>
$sections
= []
$sectionStack
The name of the current section being rendered, if any.
protected
array<int, string>
$sectionStack
= []
$tempData
Data for the variables that are available in the Views.
protected
array<string, mixed>|null
$tempData
$viewPath
The base directory to look in for our Views.
protected
string
$viewPath
$viewsCount
Number of loaded views
protected
int
$viewsCount
= 0
Methods
__construct()
public
__construct(View $config[, string|null $viewPath = null ][, FileLocatorInterface|null $loader = null ][, bool|null $debug = null ][, LoggerInterface|null $logger = null ]) : mixed
Parameters
- $config : View
- $viewPath : string|null = null
- $loader : FileLocatorInterface|null = null
- $debug : bool|null = null
- $logger : LoggerInterface|null = null
endSection()
Captures the last section
public
endSection() : void
Tags
excerpt()
Extract first bit of a long string and add ellipsis
public
excerpt(string $string[, int $length = 20 ]) : string
Parameters
- $string : string
- $length : int = 20
Return values
stringextend()
Specifies that the current view should extend an existing layout.
public
extend(string $layout) : void
Parameters
- $layout : string
getData()
Returns the current data that will be displayed in the view.
public
getData() : array<string, mixed>
Return values
array<string, mixed>getPerformanceData()
Returns the performance data that might have been collected during the execution. Used primarily in the Debug Toolbar.
public
getPerformanceData() : array<int, array{start: float, end: float, view: string}>
Return values
array<int, array{start: float, end: float, view: string}>include()
Used within layout views to include additional views.
public
include(string $view[, array<string, mixed>|null $options = null ][, bool $saveData = true ]) : string
Parameters
- $view : string
- $options : array<string, mixed>|null = null
- $saveData : bool = true
Return values
stringrender()
Builds the output based upon a file name and any data that has already been set.
public
render(string $view[, array<string, mixed>|null $options = null ][, bool|null $saveData = null ]) : string
Valid $options:
- cache Number of seconds to cache for
- cache_name Name to use for cache
Parameters
- $view : string
-
File name of the view source
- $options : array<string, mixed>|null = null
-
Reserved for 3rd-party uses since it might be needed to pass additional info to other template engines.
- $saveData : bool|null = null
-
If true, saves data for subsequent calls, if false, cleans the data after displaying, if null, uses the config setting.
Return values
stringrenderSection()
Renders a section's contents.
public
renderSection(string $sectionName[, bool $saveData = false ]) : void
Parameters
- $sectionName : string
- $saveData : bool = false
-
If true, saves data for subsequent calls, if false, cleans the data after displaying.
renderString()
Builds the output based upon a string and any data that has already been set.
public
renderString(string $view[, array<string, mixed>|null $options = null ][, bool|null $saveData = null ]) : string
Cache does not apply, because there is no "key".
Parameters
- $view : string
-
The view contents
- $options : array<string, mixed>|null = null
-
Reserved for 3rd-party uses since it might be needed to pass additional info to other template engines.
- $saveData : bool|null = null
-
If true, saves data for subsequent calls, if false, cleans the data after displaying, if null, uses the config setting.
Return values
stringresetData()
Removes all of the view data from the system.
public
resetData() : RendererInterface
Return values
RendererInterfacesection()
Starts holds content for a section within the layout.
public
section(string $name) : void
Parameters
- $name : string
-
Section name
setData()
Sets several pieces of view data at once.
public
setData([array<string|int, mixed> $data = [] ][, non-empty-string|null $context = null ]) : RendererInterface
Parameters
- $data : array<string|int, mixed> = []
- $context : non-empty-string|null = null
-
The context to escape it for. If 'raw', no escaping will happen.
Tags
Return values
RendererInterfacesetVar()
Sets a single piece of view data.
public
setVar(string $name[, mixed $value = null ][, non-empty-string|null $context = null ]) : RendererInterface
Parameters
- $name : string
- $value : mixed = null
- $context : non-empty-string|null = null
-
The context to escape it for. If 'raw', no escaping will happen.
Tags
Return values
RendererInterfacedecorateOutput()
Runs the generated output through any declared view decorators.
protected
decorateOutput(string $html) : string
Parameters
- $html : string
Return values
stringlogPerformance()
Logs performance data for rendering a view.
protected
logPerformance(float $start, float $end, string $view) : void
Parameters
- $start : float
- $end : float
- $view : string
prepareTemplateData()
protected
prepareTemplateData(bool $saveData) : void
Parameters
- $saveData : bool