Overview

Namespaces

  • None
  • PHP
  • Wei
    • Validator

Classes

  • Apc
  • App
  • ArrayCache
  • Asset
  • Base
  • BaseCache
  • Bicache
  • Cache
  • Config
  • Cookie
  • Couchbase
  • Counter
  • Db
  • DbCache
  • E
  • Env
  • Error
  • FileCache
  • Gravatar
  • Http
  • Lock
  • Logger
  • Memcache
  • Memcached
  • MongoCache
  • Password
  • PhpError
  • Pinyin
  • Record
  • Redis
  • Request
  • Response
  • Router
  • SafeUrl
  • Session
  • Soap
  • T
  • Ua
  • Upload
  • Url
  • Uuid
  • Validate
  • View
  • WeChatApp
  • Wei
  • Overview
  • Namespace
  • Class
  • Tree

Class View

A service that use to render PHP template

Wei\Base
Extended by Wei\View implements ArrayAccess
Namespace: Wei
Author: Twin Huang twinhuang@qq.com
Located at View.php
Methods summary
public
# __construct( array $options = array() )

Constructor

Constructor

Parameters

$options

Throws

InvalidArgumentException
When option "wei" is not an instance of "Wei\Wei"

Overrides

Wei\Base::__construct()
public string
# __invoke( string $name = null, array $data = array() )

Render a PHP template

Render a PHP template

Parameters

$name
The name of template
$data
The variables pass to template

Returns

string
public string|null
# render( string $name, array $data = array() )

Render a template

Render a template

Parameters

$name
The name of template
$data
The variables pass to template

Returns

string|null
public
# display( string $name, array $data = array() )

Output a rendered template

Output a rendered template

Parameters

$name
The name of template
$data
The variables pass to template
public mixed
# assign( string $name, mixed $value = null )

Assign variables to template

Assign variables to template

Parameters

$name
The name of the variable
$value
The value of the variable

Returns

mixed
$this
public mixed
# get( string $name )

Returns the variable value or null if not defined

Returns the variable value or null if not defined

Parameters

$name
The name of variable

Returns

mixed
public string
# getFile( string $name )

Get the template file by name

Get the template file by name

Parameters

$name
The name of template

Returns

string
The template file path

Throws

RuntimeException
When template file not found
public mixed
# layout( string $name = null, string $variable = 'content' )

Set layout file for current view

Set layout file for current view

Parameters

$name
The name of layout template
$variable
The variable name of layout content

Returns

mixed
$this
public mixed
# setDefaultLayout( string $defaultLayout )

Set the default layout parameter

Set the default layout parameter

Parameters

$defaultLayout

Returns

mixed
$this
public mixed
# setDirs( string|array $dirs )

Set base directory for views

Set base directory for views

Parameters

$dirs

Returns

mixed
$this
public string
# getExtension( )

Get default template file extension, such as php, tpl, this is useful for automatic render template

Get default template file extension, such as php, tpl, this is useful for automatic render template

Returns

string
public boolean
# offsetExists( string $offset )

Check if the offset exists

Check if the offset exists

Parameters

$offset

Returns

boolean

Implementation of

ArrayAccess::offsetExists()
public mixed &
# offsetGet( string $offset )

Get the offset value

Get the offset value

Parameters

$offset

Returns

mixed

Implementation of

ArrayAccess::offsetGet()
public
# offsetSet( string $offset, mixed $value )

Set the offset value

Set the offset value

Parameters

$offset
$value

Implementation of

ArrayAccess::offsetSet()
public
# offsetUnset( string $offset )

Unset the offset

Unset the offset

Parameters

$offset

Implementation of

ArrayAccess::offsetUnset()
Methods inherited from Wei\Base
__call(), __get(), getOption(), setOption()
Properties summary
protected array $data

The template variables

The template variables

# array()
protected array $dirs

The directories to find template

The directories to find template

# array('.')
protected string $extension

Default template file extension

Default template file extension

# '.php'
protected array $layout

The layout configuration

The layout configuration

# array()
protected string $defaultLayout

The default layout path for layout method

The default layout path for layout method

#
Properties inherited from Wei\Base
$providers, $wei
Wei Framework API documentation generated by ApiGen