Class yii\twig\Extension

Inheritanceyii\twig\Extension » Twig_Extension
Source Code https://github.com/yiisoft/yii2-twig/blob/master/Extension.php

Extension provides Yii-specific syntax for Twig templates.

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$aliases array Used class aliases yii\twig\Extension
$namespaces array Used namespaces yii\twig\Extension
$widgets array Used widgets yii\twig\Extension

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__construct() Creates new instance yii\twig\Extension
addUses() Adds namespaces and aliases from constructor yii\twig\Extension
beginWidget() Function for *_begin syntax support yii\twig\Extension
call() Calls a method yii\twig\Extension
endWidget() Function for *_end syntax support yii\twig\Extension
getFunctions() yii\twig\Extension
getName() yii\twig\Extension
getNodeVisitors() yii\twig\Extension
path() Generates relative URL yii\twig\Extension
registerAsset() Function for registering an asset yii\twig\Extension
registerAssetBundle() Function for additional syntax of registering asset bundles yii\twig\Extension
resolveAndCall() Resolves a method from widget and asset syntax and calls it yii\twig\Extension
resolveClassName() Resolves class name from widget and asset syntax yii\twig\Extension
setProperty() Sets object property yii\twig\Extension
url() Generates absolute URL yii\twig\Extension
viewHelper() Used for 'begin_page', 'end_page', 'begin_body', 'end_body', 'head' yii\twig\Extension
widget() Function for *_widget syntax support yii\twig\Extension

Property Details

$aliases protected property

Used class aliases

protected array $aliases = []
$namespaces protected property

Used namespaces

protected array $namespaces = []
$widgets protected property

Used widgets

protected array $widgets = []

Method Details

__construct() public method

Creates new instance

public void __construct ( array $uses = [] )
$uses array

Namespaces and classes to use in the template

addUses() public method

Adds namespaces and aliases from constructor

public void addUses ( $args )
$args array

Namespaces and classes to use in the template

beginWidget() public method

Function for *_begin syntax support

public mixed beginWidget ( $widget, $config = [] )
$widget string

Widget name

$config array

Widget config

call() public method

Calls a method

public mixed call ( $className, $method, $arguments null )
$className string

Class name

$method string

Method name

$arguments array
endWidget() public method

Function for *_end syntax support

public void endWidget ( $widget null )
$widget string

Widget name

getFunctions() public method

public void getFunctions ( )
getName() public method

public void getName ( )
getNodeVisitors() public method

public void getNodeVisitors ( )
path() public method

Generates relative URL

public string path ( $path, $args = [] )
$path string

The parameter to be used to generate a valid URL

$args array

Arguments

return string

The generated relative URL

registerAsset() public method

Function for registering an asset

{{ use('yii/web/JqueryAsset') }}
{{ register_jquery_asset() }}
public mixed registerAsset ( $context, $asset )
$context array

Context information

$asset string

Asset name

registerAssetBundle() public method (available since version 2.0.4)

Function for additional syntax of registering asset bundles

{{ register_asset_bundle('yii/web/JqueryAsset') }}
public void|yii\web\AssetBundle registerAssetBundle ( $context, $bundle, $return false )
$context array

Context information

$bundle string

Asset bundle class fully qualified name

$return boolean

Indicates if AssetBundle should be returned

resolveAndCall() public method

Resolves a method from widget and asset syntax and calls it

public mixed resolveAndCall ( $className, $method, $arguments null )
$className string

Class name

$method string

Method name

$arguments array
resolveClassName() public method

Resolves class name from widget and asset syntax

public string resolveClassName ( $className )
$className string

Class name

setProperty() public method

Sets object property

public void setProperty ( $object, $property, $value )
$object stdClass
$property string
$value mixed
url() public method

Generates absolute URL

public string url ( $path, $args = [] )
$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 void viewHelper ( $context, $name null )
$context array

Context information

$name string
widget() public method

Function for *_widget syntax support

public mixed widget ( $widget, $config = [] )
$widget string

Widget name

$config array

Widget config