SlaxWeb Framework
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
SlaxWeb\View\Base Class Reference

Public Member Functions

 __construct (Config $config, Loader $loader, Response $response)
 
 setLayout (Base $layout=null)
 
 addSubView (string $name, Base $subView)
 
 addSubTemplate (string $name, string $subTemplate)
 
 render (array $data=[], int $return=Loader::TPL_OUTPUT, int $cacheData=Loader::TPL_CACHE_VARS)
 

Public Attributes

 $template = ""
 
 $viewData = []
 

Protected Member Functions

 renderSubViews ()
 

Protected Attributes

 $layout = null
 
 $subViews = []
 
 $config = null
 
 $loader = null
 
 $response = null
 

Constructor & Destructor Documentation

SlaxWeb\View\Base::__construct ( Config  $config,
Loader  $loader,
Response  $response 
)

Class constructor

Instantiate the view, by assigning its dependencies to the class properties. Set the base directory for the template files, and set the template name if none is already set by an override property and config permits it.

Parameters
\SlaxWeb\Config\Container$configConfiguration container
\SlaxWeb\View\AbstractLoader$loaderTemplate file loader
\Symfony\Component\HttpFoundation\Response$responseResponse object

Member Function Documentation

SlaxWeb\View\Base::addSubTemplate ( string  $name,
string  $subTemplate 
)

Add SubTemplate

Adds a SubTemplate to the local container. The '$name' parameter is the name under which the rendered subview is then available in the main view. Example: When '$name' is 'foo', the variable in the template will be 'subview_foo'. The SubTemplate is the same as a SubView except it does not provide its own View Class, but is simply rendered using the current instance.

Parameters
string$nameName of the SubView
string$subTemplateSub Template name
Returns
self
SlaxWeb\View\Base::addSubView ( string  $name,
Base  $subView 
)

Add SubView

Adds a SubView to the local container. The '$name' parameter is the name under which the rendered subview is then available in the main view. Example: When '$name' is 'foo', the variable in the template will be 'subview_foo'.

Parameters
string$nameName of the SubView
\SlaxWeb\View\Base$subViewSub View object extended from the same Base class
Returns
self
SlaxWeb\View\Base::render ( array  $data = [],
int  $return = Loader::TPL_OUTPUT,
int  $cacheData = Loader::TPL_CACHE_VARS 
)

Render view

Renders the view by rendering the template with the provided template loader.

Parameters
array$dataTemplate data to be passed to the template. Default []
int$returnOutput or return rendered template. Default self::TPL_OUTPUT
int$cacheDataCache template data. Default self::TPL_CACHE_VARS
Returns
mixed
SlaxWeb\View\Base::renderSubViews ( )
protected

Render SubViews

Render the SubViews and add rendered results to the View Data array.

Returns
void
SlaxWeb\View\Base::setLayout ( Base  $layout = null)

Set Layout

Sets the received View class as layout if it is supplied. If no parameter is set, then the layout will not be used.

Parameters
\SlaxWeb\View\Base$layoutLayout view class
Returns
self

The documentation for this class was generated from the following file: