View
in package
Class View.
Table of Contents
- $baseDir : string|null
- $blocks : array<string|int, mixed>
- $currentView : string
- $debugCollector : ViewsCollector
- $extension : string
- $includePrefix : string
- $inInclude : bool
- $instanceName : string
- $layout : string
- $layoutPrefix : string
- $layoutsOpen : array<string|int, mixed>
- $openBlock : string|null
- $openBlocks : array<string|int, mixed>
- $showDebugComments : bool
- $throwExceptionsInDestructor : bool
- $viewsPaths : array<string|int, mixed>
- __construct() : mixed
- __destruct() : mixed
- block() : static
- Open a block.
- currentBlock() : string|null
- Tells the name of the current block.
- disableDebugComments() : static
- Disable debug comments when in debug mode.
- enableDebugComments() : static
- Enable debug comments when in debug mode.
- endBlock() : static
- Close an open block.
- extends() : static
- Extends a layout.
- extendsWithoutPrefix() : static
- Extends a layout without prefix.
- getBaseDir() : string|null
- Get the base directory.
- getExtension() : string
- Get the extension of view files.
- getIncludePrefix() : string
- Get the name of the includes directory.
- getInstanceName() : string
- getInstanceNameWithPath() : string
- getLayoutPrefix() : string
- Get the name of the layouts directory.
- hasBlock() : bool
- Tells whether a given block is set.
- inBlock() : bool
- Tells whether the current content is inside a block.
- include() : string
- Returns the contents of an include.
- includeWithoutPrefix() : string
- Returns the contents of an include without prefix.
- inLayout() : bool
- Tells whether the current contents is inside a layout.
- isShowingDebugComments() : bool
- Tells if it is showing debug comments when in debug mode.
- isThrowExceptionsInDestructor() : bool
- Tells whether it is able to throw exceptions in the destructor.
- removeBlock() : static
- Remove a block.
- render() : string
- Render a view file.
- renderBlock() : string|null
- Render a block.
- setBaseDir() : static
- Sets the base directory where the views files are located.
- setDebugCollector() : static
- setExtension() : static
- Set the extension of views files.
- setIncludePrefix() : static
- Set the name of a directory for includes within the base directory.
- setInstanceName() : static
- setLayoutPrefix() : static
- Set the name of a directory for layouts within the base directory.
- setThrowExceptionsInDestructor() : static
- Enables/disables exceptions in the destructor.
- getCommentPath() : string
- getContents() : string
- getFilepath() : string
- getIncludeContents() : string
- getIncludeContentsWithDebug() : string
- getNamespacedFilepath() : string
- involveInclude() : string
- makeDirectoryPrefix() : string
- setDebugData() : static
Properties
$baseDir
protected
string|null
$baseDir
= null
$blocks
protected
array<string|int, mixed>
$blocks
$currentView
protected
string
$currentView
$debugCollector
protected
ViewsCollector
$debugCollector
$extension
protected
string
$extension
$includePrefix
protected
string
$includePrefix
= ''
$inInclude
protected
bool
$inInclude
= false
$instanceName
protected
string
$instanceName
$layout
protected
string
$layout
$layoutPrefix
protected
string
$layoutPrefix
= ''
$layoutsOpen
protected
array<string|int, mixed>
$layoutsOpen
= []
$openBlock
protected
string|null
$openBlock
$openBlocks
protected
array<string|int, mixed>
$openBlocks
= []
$showDebugComments
protected
bool
$showDebugComments
= true
$throwExceptionsInDestructor
protected
bool
$throwExceptionsInDestructor
= true
$viewsPaths
protected
array<string|int, mixed>
$viewsPaths
= []
Methods
__construct()
public
__construct([string|null $baseDir = null ][, string $extension = '.php' ]) : mixed
Parameters
- $baseDir : string|null = null
- $extension : string = '.php'
Return values
mixed —__destruct()
public
__destruct() : mixed
Return values
mixed —block()
Open a block.
public
block(string $name) : static
Parameters
- $name : string
-
Block name
Return values
static —currentBlock()
Tells the name of the current block.
public
currentBlock() : string|null
Return values
string|null —disableDebugComments()
Disable debug comments when in debug mode.
public
disableDebugComments() : static
Tags
Return values
static —enableDebugComments()
Enable debug comments when in debug mode.
public
enableDebugComments() : static
Tags
Return values
static —endBlock()
Close an open block.
public
endBlock() : static
Return values
static —extends()
Extends a layout.
public
extends(string $layout[, string|null $openBlock = null ]) : static
Parameters
- $layout : string
-
The name of the file within the layouts directory
- $openBlock : string|null = null
-
Optionally opens and closes this block automatically
Return values
static —extendsWithoutPrefix()
Extends a layout without prefix.
public
extendsWithoutPrefix(string $layout) : static
Parameters
- $layout : string
-
The name of the file within the base directory
Return values
static —getBaseDir()
Get the base directory.
public
getBaseDir() : string|null
Return values
string|null —getExtension()
Get the extension of view files.
public
getExtension() : string
Return values
string —getIncludePrefix()
Get the name of the includes directory.
public
getIncludePrefix() : string
Return values
string —getInstanceName()
public
getInstanceName() : string
Return values
string —getInstanceNameWithPath()
public
getInstanceNameWithPath(string $name) : string
Parameters
- $name : string
Return values
string —getLayoutPrefix()
Get the name of the layouts directory.
public
getLayoutPrefix() : string
Return values
string —hasBlock()
Tells whether a given block is set.
public
hasBlock(string $name) : bool
Parameters
- $name : string
-
Block name
Return values
bool —inBlock()
Tells whether the current content is inside a block.
public
inBlock(string $name) : bool
Parameters
- $name : string
-
Block name
Return values
bool —include()
Returns the contents of an include.
public
include(string $view[, array<string, mixed> $data = [] ]) : string
Parameters
- $view : string
-
The path of the file within the includes directory
- $data : array<string, mixed> = []
-
Data passed to the view. The array keys will be variables
Return values
string —includeWithoutPrefix()
Returns the contents of an include without prefix.
public
includeWithoutPrefix(string $view[, array<string, mixed> $data = [] ]) : string
Parameters
- $view : string
-
The path of the file within the base directory
- $data : array<string, mixed> = []
-
Data passed to the view. The array keys will be variables
Return values
string —inLayout()
Tells whether the current contents is inside a layout.
public
inLayout(string $layout) : bool
Parameters
- $layout : string
Return values
bool —isShowingDebugComments()
Tells if it is showing debug comments when in debug mode.
public
isShowingDebugComments() : bool
Tags
Return values
bool —isThrowExceptionsInDestructor()
Tells whether it is able to throw exceptions in the destructor.
public
isThrowExceptionsInDestructor() : bool
Tags
Return values
bool —removeBlock()
Remove a block.
public
removeBlock(string $name) : static
Parameters
- $name : string
-
Block name
Return values
static —render()
Render a view file.
public
render(string $view[, array<string, mixed> $data = [] ]) : string
Parameters
- $view : string
-
View path within the base directory
- $data : array<string, mixed> = []
-
Data passed to the view. The array keys will be variables
Return values
string —renderBlock()
Render a block.
public
renderBlock(string $name) : string|null
Parameters
- $name : string
-
Block name
Return values
string|null —setBaseDir()
Sets the base directory where the views files are located.
public
setBaseDir(string $baseDir) : static
Parameters
- $baseDir : string
Return values
static —setDebugCollector()
public
setDebugCollector(ViewsCollector $debugCollector) : static
Parameters
- $debugCollector : ViewsCollector
Return values
static —setExtension()
Set the extension of views files.
public
setExtension(string $extension) : static
Parameters
- $extension : string
Return values
static —setIncludePrefix()
Set the name of a directory for includes within the base directory.
public
setIncludePrefix(string $prefix) : static
Parameters
- $prefix : string
Return values
static —setInstanceName()
public
setInstanceName(string $instanceName) : static
Parameters
- $instanceName : string
Return values
static —setLayoutPrefix()
Set the name of a directory for layouts within the base directory.
public
setLayoutPrefix(string $prefix) : static
Parameters
- $prefix : string
Return values
static —setThrowExceptionsInDestructor()
Enables/disables exceptions in the destructor.
public
setThrowExceptionsInDestructor([bool $active = true ]) : static
Parameters
- $active : bool = true
-
True to throw exceptions, false otherwise
Tags
Return values
static —getCommentPath()
protected
getCommentPath(string $name) : string
Parameters
- $name : string
Return values
string —getContents()
protected
getContents(string $view, array<string, mixed> $data) : string
Parameters
- $view : string
- $data : array<string, mixed>
Return values
string —getFilepath()
protected
getFilepath(string $view) : string
Parameters
- $view : string
Return values
string —getIncludeContents()
protected
getIncludeContents(string $view[, array<string, mixed> $data = [] ]) : string
Parameters
- $view : string
- $data : array<string, mixed> = []
Return values
string —getIncludeContentsWithDebug()
protected
getIncludeContentsWithDebug(string $view[, array<string, mixed> $data = [] ]) : string
Parameters
- $view : string
- $data : array<string, mixed> = []
Return values
string —getNamespacedFilepath()
protected
getNamespacedFilepath(string $view) : string
Parameters
- $view : string
Return values
string —involveInclude()
protected
involveInclude(string $view, string $contents) : string
Parameters
- $view : string
- $contents : string
Return values
string —makeDirectoryPrefix()
protected
makeDirectoryPrefix(string $prefix) : string
Parameters
- $prefix : string
Return values
string —setDebugData()
protected
setDebugData(string $file, float $start, string $type) : static
Parameters
- $file : string
- $start : float
- $type : string