PHP Class Voodoo\Core\View

Inheritance: use trait Voodoo\Core\View\TView
Show file Open project: voodoophp/voodoo

Public Properties

Property Type Description
$isDisabled
$isRendered

Protected Properties

Property Type Description
$actionView
$appRootDir
$config
$controllersViewPath
$definedRaws
$ext View file extension
$isActionViewAbsolute
$isLayoutAbsolute
$layout
$parsed
$renderedContent
$templateDir
$templates

Public Methods

Method Description
__construct ( Controller $controller ) The constructor
__string ( )
actionViewExists ( ) : boolean Retun bool if the action view file exists
addTemplate ( type $name, type $src, $absolutePath = false ) : Voodoo\Core\View To add a template file
addTemplateString ( string $name, string $content ) : Voodoo\Core\View To add a template string
clearFlashMessage ( ) : View Clear flash message
exists ( ) : boolean Check if the views directory exists
getEngine ( ) : Handlebars\Handlebars\Handlebars Return the view engine
getFilePath ( strin $path = "index" ) : string Return the complete file path of the template in the current view.
getFlashMessage ( string $type = null ) : Array Get flash message
getFormat ( ) : string Return the view format
issetActionView ( ) : boolean Return if the view is set
issetLayout ( ) : boolean Return if the layout is set
removeTemplate ( type $name ) : Voodoo\Core\View To remove a template name
render ( ) : String Render the template
reparse ( ) : Voodoo\Core\View To reset the parsing
setActionError ( string $errorMessage = "", integer $errorCode = 500 ) : Voodoo\Core\View To set the error page
setActionView ( string $filename, boolean $absolute = false ) : Voodoo\Core\View Set the view body to use. By default it will use the the action view => $action.html
setDescription ( string $description ) : View Set the description
setFlashMessage ( type $message, type $type = View\FlashMessage::TYPE_NOTICE, array $data = [] ) : View Set a flash message
setFormat ( type $format ) : View Set the view format
setKeywords ( array $keywords ) : View Set the keywords
setMeta ( type $key, type $value ) : View Set multiple meta data
setPagination ( array $data ) : View Set the pagination model
setTitle ( string $title, boolean $concat = false, integer $position = self::TITLE_CONCAT_APPEND ) : View To set the title
useLayout ( string $filename, $isAbsolute = false ) : Voodoo\Core\View Set the view layout to use. By default it will user the contain set in config.

Protected Methods

Method Description
loadFile ( type $src ) : string Load the template file

Private Methods

Method Description
addExt ( string $file ) : string Add file extension if ommitted
assign_ ( mixed $key, mixed $value = null ) : View Assign data to _.* For local use only
getModuleAssetsDir ( ) : string To create the module's assets dir Base on the config file
getPublicAssetsDir ( ) : string To create the shared assets dir Base on the config file
parse ( ) Parse the template
parseTemplate ( string $template ) : string Parse the template and catch any {{!include }} expression

Method Details

__construct() public method

The constructor
public __construct ( Controller $controller )
$controller Controller

__string() public method

public __string ( )

actionViewExists() public method

Retun bool if the action view file exists
public actionViewExists ( ) : boolean
return boolean

addTemplate() public method

To add a template file
public addTemplate ( type $name, type $src, $absolutePath = false ) : Voodoo\Core\View
$name type - the name of the template. Can be used to call it: {{!include @name}}
$src type - the filepath relative to the working dir
return Voodoo\Core\View

addTemplateString() public method

To add a template string
public addTemplateString ( string $name, string $content ) : Voodoo\Core\View
$name string
$content string
return Voodoo\Core\View

clearFlashMessage() public method

Clear flash message
public clearFlashMessage ( ) : View
return View

exists() public method

Check if the views directory exists
public exists ( ) : boolean
return boolean

getEngine() public method

Return the view engine
public getEngine ( ) : Handlebars\Handlebars\Handlebars
return Handlebars\Handlebars\Handlebars

getFilePath() public method

It can be used to access another views from another module
public getFilePath ( strin $path = "index" ) : string
$path strin
return string

getFlashMessage() public method

Get flash message
public getFlashMessage ( string $type = null ) : Array
$type string - Return flash messages of a type
return Array [message, type, data]

getFormat() public method

Return the view format
public getFormat ( ) : string
return string

issetActionView() public method

Return if the view is set
public issetActionView ( ) : boolean
return boolean

issetLayout() public method

Return if the layout is set
public issetLayout ( ) : boolean
return boolean

loadFile() protected method

Load the template file
protected loadFile ( type $src ) : string
$src type
return string

removeTemplate() public method

To remove a template name
public removeTemplate ( type $name ) : Voodoo\Core\View
$name type
return Voodoo\Core\View

render() public method

Render the template
public render ( ) : String
return String

reparse() public method

To reset the parsing
public reparse ( ) : Voodoo\Core\View
return Voodoo\Core\View

setActionError() public method

To set the error page
public setActionError ( string $errorMessage = "", integer $errorCode = 500 ) : Voodoo\Core\View
$errorMessage string
$errorCode integer
return Voodoo\Core\View

setActionView() public method

Set the view body to use. By default it will use the the action view => $action.html
public setActionView ( string $filename, boolean $absolute = false ) : Voodoo\Core\View
$filename string
$absolute boolean - true, it will use the full path of filename, or it will look in the current Views
return Voodoo\Core\View

setDescription() public method

Set the description
public setDescription ( string $description ) : View
$description string
return View

setFlashMessage() public method

Set a flash message
public setFlashMessage ( type $message, type $type = View\FlashMessage::TYPE_NOTICE, array $data = [] ) : View
$message type
$type type
$data array
return View

setFormat() public method

Set the view format
public setFormat ( type $format ) : View
$format type
return View

setKeywords() public method

Set the keywords
public setKeywords ( array $keywords ) : View
$keywords array
return View

setMeta() public method

Set multiple meta data
public setMeta ( type $key, type $value ) : View
$key type
$value type
return View

setPagination() public method

Set the pagination model
public setPagination ( array $data ) : View
$data array
return View

setTitle() public method

To set the title
public setTitle ( string $title, boolean $concat = false, integer $position = self::TITLE_CONCAT_APPEND ) : View
$title string
$concat boolean
$position integer
return View

useLayout() public method

Set the view layout to use. By default it will user the contain set in config.
public useLayout ( string $filename, $isAbsolute = false ) : Voodoo\Core\View
$filename string - The name of the layout under _layouts/
return Voodoo\Core\View

Property Details

$actionView protected property

protected $actionView

$appRootDir protected property

protected $appRootDir

$config protected property

protected $config

$controllersViewPath protected property

protected $controllersViewPath

$definedRaws protected property

protected $definedRaws

$ext protected property

View file extension
protected $ext

$isActionViewAbsolute protected property

protected $isActionViewAbsolute

$isDisabled public property

public $isDisabled

$isLayoutAbsolute protected property

protected $isLayoutAbsolute

$isRendered public property

public $isRendered

$layout protected property

protected $layout

$parsed protected property

protected $parsed

$renderedContent protected property

protected $renderedContent

$templateDir protected property

protected $templateDir

$templates protected property

protected $templates