Class yii\twig\Extension
Inheritance | yii\twig\Extension » Twig\Extension\AbstractExtension |
---|---|
Source Code | https://github.com/yiisoft/yii2-twig/blob/master/Extension.php |
Extension provides Yii-specific syntax for Twig templates.
Protected Properties
Property | Type | Description | Defined 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
Method | Description | Defined 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
Used class aliases
Used namespaces
Used widgets
Method Details
Creates new instance
public void __construct ( array $uses = [] ) | ||
$uses | array | Namespaces and classes to use in the template |
Adds namespaces and aliases from constructor
public void addUses ( $args ) | ||
$args | array | Namespaces and classes to use in the template |
Function for *_begin syntax support
public mixed beginWidget ( $widget, $config = [] ) | ||
$widget | string | Widget name |
$config | array | Widget config |
Calls a method
public mixed call ( $className, $method, $arguments = null ) | ||
$className | string | Class name |
$method | string | Method name |
$arguments | array |
Function for *_end syntax support
public void endWidget ( $widget = null ) | ||
$widget | string | Widget name |
public void getFunctions ( ) |
public void getName ( ) |
public void getNodeVisitors ( ) |
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 |
---|
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 |
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 |
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 |
Resolves class name from widget and asset syntax
public string resolveClassName ( $className ) | ||
$className | string | Class name |
Sets object property
public void setProperty ( $object, $property, $value ) | ||
$object | stdClass | |
$property | string | |
$value | mixed |
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 |
---|
Used for 'begin_page', 'end_page', 'begin_body', 'end_body', 'head'
public void viewHelper ( $context, $name = null ) | ||
$context | array | Context information |
$name | string |
Function for *_widget syntax support
public mixed widget ( $widget, $config = [] ) | ||
$widget | string | Widget name |
$config | array | Widget config |