PHP Class yii\twig\Extension

Author: Andrey Grachov ([email protected])
Author: Alexander Makarov ([email protected])
Inheritance: extends Twig_Extension
Show file Open project: yiisoft/yii2-twig

Protected Properties

Property Type Description
$aliases used class aliases
$namespaces used namespaces
$widgets used widgets

Public Methods

Method Description
__construct ( array $uses = [] ) Creates new instance
addUses ( array $args ) Adds namespaces and aliases from constructor
beginWidget ( string $widget, array $config = [] ) : mixed Function for *_begin syntax support
call ( string $className, string $method, array $arguments = null ) : mixed Calls a method
endWidget ( string $widget = null ) Function for *_end syntax support
getFunctions ( )
getName ( )
getNodeVisitors ( )
path ( string $path, array $args = [] ) : string Generates relative URL
registerAsset ( array $context, string $asset ) : mixed Function for registering an asset
registerAssetBundle ( array $context, string $bundle, boolean $return = false ) : void | AssetBundle Function for additional syntax of registering asset bundles
resolveAndCall ( string $className, string $method, array $arguments = null ) : mixed Resolves a method from widget and asset syntax and calls it
resolveClassName ( string $className ) : string Resolves class name from widget and asset syntax
setProperty ( stdClass $object, string $property, mixed $value ) Sets object property
url ( string $path, array $args = [] ) : string Generates absolute URL
viewHelper ( array $context, string $name = null ) Used for 'begin_page', 'end_page', 'begin_body', 'end_body', 'head'
widget ( string $widget, array $config = [] ) : mixed Function for *_widget syntax support

Method Details

__construct() public method

Creates new instance
public __construct ( array $uses = [] )
$uses array namespaces and classes to use in the template

addUses() public method

Adds namespaces and aliases from constructor
public addUses ( array $args )
$args array namespaces and classes to use in the template

beginWidget() public method

Function for *_begin syntax support
public beginWidget ( string $widget, array $config = [] ) : mixed
$widget string widget name
$config array widget config
return mixed

call() public method

Calls a method
public call ( string $className, string $method, array $arguments = null ) : mixed
$className string class name
$method string method name
$arguments array
return mixed

endWidget() public method

Function for *_end syntax support
public endWidget ( string $widget = null )
$widget string widget name

getFunctions() public method

public getFunctions ( )

getName() public method

public getName ( )

getNodeVisitors() public method

public getNodeVisitors ( )

path() public method

Generates relative URL
public path ( string $path, array $args = [] ) : string
$path string the parameter to be used to generate a valid URL
$args array arguments
return string the generated relative URL

registerAsset() public method

{{ use('yii/web/JqueryAsset') }} {{ register_jquery_asset() }}
public registerAsset ( array $context, string $asset ) : mixed
$context array context information
$asset string asset name
return mixed

registerAssetBundle() public method

{{ register_asset_bundle('yii/web/JqueryAsset') }}
Since: 2.0.4
public registerAssetBundle ( array $context, string $bundle, boolean $return = false ) : void | AssetBundle
$context array context information
$bundle string asset bundle class fully qualified name
$return boolean indicates if AssetBundle should be returned
return void | yii\web\AssetBundle

resolveAndCall() public method

Resolves a method from widget and asset syntax and calls it
public resolveAndCall ( string $className, string $method, array $arguments = null ) : mixed
$className string class name
$method string method name
$arguments array
return mixed

resolveClassName() public method

Resolves class name from widget and asset syntax
public resolveClassName ( string $className ) : string
$className string class name
return string

setProperty() public method

Sets object property
public setProperty ( stdClass $object, string $property, mixed $value )
$object stdClass
$property string
$value mixed

url() public method

Generates absolute URL
public url ( string $path, array $args = [] ) : string
$path string the parameter to be used to generate a valid URL
$args array arguments
return string the generated absolute URL

viewHelper() public method

Used for 'begin_page', 'end_page', 'begin_body', 'end_body', 'head'
public viewHelper ( array $context, string $name = null )
$context array context information
$name string

widget() public method

Function for *_widget syntax support
public widget ( string $widget, array $config = [] ) : mixed
$widget string widget name
$config array widget config
return mixed

Property Details

$aliases protected property

used class aliases
protected $aliases

$namespaces protected property

used namespaces
protected $namespaces

$widgets protected property

used widgets
protected $widgets