PHP Class Phrozn\Site\View\Base

Author: Victor Farazdagi
Inheritance: implements Phrozn\Site\View
Show file Open project: farazdagi/phrozn Class Usage Examples

Protected Properties

Property Type Description
$outputFile string Output file path

Public Methods

Method Description
__construct ( string $inputFile = null, string $outputDir = null ) : Phrozn\Site\View Initialize page
addProcessor ( $processor ) : Phrozn\Site\View Add text processor
compile ( array $vars = [] ) : Phrozn\Site\View Create static version of a concrete page
getFrontMatter ( ) : array Get YAML front matter from input view
getInputFile ( ) : string Get input file path
getInputRootDir ( ) : string Get input root directory path
getOutputDir ( ) : string Get output directory path
getOutputFile ( ) : string Get output file path
getParam ( string $param, mixed $default = null ) : mixed Get param value
getParams ( string $param = null, string $default = [] ) : array Get view parameters from both front matter and general site options
getProcessors ( ) : array Get list of registered processors
getSiteConfig ( ) : array Get site configuration
getTemplate ( ) : string Get template content from input view
hasLayout ( boolean $value = null ) : boolean Get/set hasLayout setting. Allows to enable/disable layout for a given view
removeProcessor ( $processor ) : Phrozn\Site\View Remove text processor
render ( array $vars = [] ) : string Render view
setFrontMatter ( array $frontMatter ) : Phrozn\Has\FrontMatter Set front matter
setInputFile ( $path ) : Phrozn\Site\View Set input file path
setInputRootDir ( string $path ) : Phrozn\Site\View Set input root directory path
setOutputDir ( string $path ) : Phrozn\Site\View Set output directory path
setOutputFile ( string $path ) : Phrozn\Site\View Set output file path
setParam ( string $param, mixed $value ) : Phrozn\Has\Param Set param
setSiteConfig ( array $config ) : Phrozn\Has\SiteConfig Set site configuration
setTemplate ( string $template ) : Phrozn\Has\Template Set template

Protected Methods

Method Description
applyLayout ( string $content, array $vars ) : string Two step view is used. View to wrap is provided with content variable.

Private Methods

Method Description
getAppConfig ( )
locateParam ( $params, $param ) : mixed Locate nested param (levels separated with dot) in params array
parse ( ) : Phrozn\Site\View Parses input file into front matter and actual template content
readSourceFile ( ) : string Read input file

Method Details

__construct() public method

Initialize page
public __construct ( string $inputFile = null, string $outputDir = null ) : Phrozn\Site\View
$inputFile string Path to page source file
$outputDir string File destination path
return Phrozn\Site\View

addProcessor() public method

Add text processor
public addProcessor ( $processor ) : Phrozn\Site\View
return Phrozn\Site\View

applyLayout() protected method

Two step view is used. View to wrap is provided with content variable.
protected applyLayout ( string $content, array $vars ) : string
$content string View text to wrap into layout
$vars array List of variables passed to processors
return string

compile() public method

Create static version of a concrete page
public compile ( array $vars = [] ) : Phrozn\Site\View
$vars array List of variables passed to template engine
return Phrozn\Site\View

getFrontMatter() public method

Get YAML front matter from input view
public getFrontMatter ( ) : array
return array

getInputFile() public method

Get input file path
public getInputFile ( ) : string
return string

getInputRootDir() public method

Get input root directory path
public getInputRootDir ( ) : string
return string

getOutputDir() public method

Get output directory path
public getOutputDir ( ) : string
return string

getOutputFile() public method

Get output file path
public getOutputFile ( ) : string
return string

getParam() public method

Get param value
public getParam ( string $param, mixed $default = null ) : mixed
$param string Parameter name to obtain value for
$default mixed Default parameter value, if non found in FM
return mixed

getParams() public method

Get view parameters from both front matter and general site options
public getParams ( string $param = null, string $default = [] ) : array
$param string Parameter to get value for. Levels are separated with dots
$default string Default value to fetch if param is not found
return array

getProcessors() public method

Get list of registered processors
public getProcessors ( ) : array
return array of \Phrozn\Processor items

getSiteConfig() public method

Get site configuration
public getSiteConfig ( ) : array
return array

getTemplate() public method

Get template content from input view
public getTemplate ( ) : string
return string

hasLayout() public method

Get/set hasLayout setting. Allows to enable/disable layout for a given view
public hasLayout ( boolean $value = null ) : boolean
$value boolean Value to set to hasLayout option
return boolean

removeProcessor() public method

Remove text processor
public removeProcessor ( $processor ) : Phrozn\Site\View
return Phrozn\Site\View

render() public method

Render view
public render ( array $vars = [] ) : string
$vars array List of variables passed to text processors
return string

setFrontMatter() public method

Set front matter
public setFrontMatter ( array $frontMatter ) : Phrozn\Has\FrontMatter
$frontMatter array Array of options
return Phrozn\Has\FrontMatter

setInputFile() public method

Set input file path
public setInputFile ( $path ) : Phrozn\Site\View
return Phrozn\Site\View

setInputRootDir() public method

Set input root directory path
public setInputRootDir ( string $path ) : Phrozn\Site\View
$path string Directory path
return Phrozn\Site\View

setOutputDir() public method

Set output directory path
public setOutputDir ( string $path ) : Phrozn\Site\View
$path string Directory path
return Phrozn\Site\View

setOutputFile() public method

Set output file path
public setOutputFile ( string $path ) : Phrozn\Site\View
$path string File path
return Phrozn\Site\View

setParam() public method

Set param
public setParam ( string $param, mixed $value ) : Phrozn\Has\Param
$param string Name of the parameter to set
$value mixed Value of the parameter
return Phrozn\Has\Param

setSiteConfig() public method

Set site configuration
public setSiteConfig ( array $config ) : Phrozn\Has\SiteConfig
$config array Array of options
return Phrozn\Has\SiteConfig

setTemplate() public method

Set template
public setTemplate ( string $template ) : Phrozn\Has\Template
$template string Source template
return Phrozn\Has\Template

Property Details

$outputFile protected property

Output file path
protected string $outputFile
return string