Contentserv PHP API

CSSmartView
in package

This class introduces a Template Concept into the Smart Documents Templates

The usage of Views allows to separate the HTML Generation and Data and Business Logic.

Tags
since

CS14.0

access

public

Table of Contents

__construct()  : CSSmartView
The constructor should be called only by the factory methods in the CSSmart API
__get()  : mixed
The magic get method that is automatically called when external code uses a virtual public member var
__set()  : void
The magic set method that is automatically called when external code sets a virtual public member var
assign()  : void
Assigns variables to the view script via differing strategies.
clear()  : void
This method clears the data vars of the view which could have been set through a magic set call
render()  : string
Renders the view against the data

Methods

__construct()

The constructor should be called only by the factory methods in the CSSmart API

public __construct(mixed $templateFolder) : CSSmartView
Parameters
$templateFolder : mixed

the template folder

Tags
access

public

Return values
CSSmartView

__get()

The magic get method that is automatically called when external code uses a virtual public member var

public __get(string $key) : mixed
Parameters
$key : string
Tags
access

public

Return values
mixed

the value as set in the magic set method

__set()

The magic set method that is automatically called when external code sets a virtual public member var

public __set(string $key, mixed $value) : void
Parameters
$key : string
$value : mixed
Tags
access

public

Return values
void

assign()

Assigns variables to the view script via differing strategies.

public assign(string|array<string|int, mixed> $data[, mixed $value = null ]) : void

$view->assign('name', $value) assigns a variable called 'name' with the corresponding $value.

$view->assign($array) assigns the array keys as variable names (with the corresponding array values).

Parameters
$data : string|array<string|int, mixed>

The assignment strategy to use.

$value : mixed = null
Tags
see
__set()
throws
Exception

if $data is neither a string nor an array, or if an attempt to set a private or protected member is detected

Return values
void

clear()

This method clears the data vars of the view which could have been set through a magic set call

public clear() : void
Tags
access

public

Return values
void

render()

Renders the view against the data

public render(string $template) : string

It is possible to use {$variable} in the template as a short form of variable; ?>

Parameters
$template : string

the template within the template folder

Tags
access

public

Return values
string

the rendered template


        

Search results