Class yii\twig\Extension
| Inheritance | yii\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
| 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() | 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
| void __construct( array $uses = [] ) | ||
| $uses | array | Namespaces and classes to use in the template |
Adds namespaces and aliases from constructor
| void addUses( $args ) | ||
| $args | array | Namespaces and classes to use in the template |
Function for *_begin syntax support
| mixed beginWidget( $widget, $config = [] ) | ||
| $widget | string | Widget name |
| $config | array | Widget config |
Calls a method
| mixed call( $className, $method, $arguments = null ) | ||
| $className | string | Class name |
| $method | string | Method name |
| $arguments | array | |
Function for *_end syntax support
| void endWidget( $widget = null ) | ||
| $widget | string | Widget name |
| void getFunctions( ) |
| void getName( ) |
| void getNodeVisitors( ) |
Generates relative URL
| 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() }}
| 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') }}
| void registerAssetBundle( $context, $bundle ) | ||
| $context | array | Context information |
| $bundle | string | Asset bundle class fully qualified name |
Resolves a method from widget and asset syntax and calls it
| mixed resolveAndCall( $className, $method, $arguments = null ) | ||
| $className | string | Class name |
| $method | string | Method name |
| $arguments | array | |
Resolves class name from widget and asset syntax
| string resolveClassName( $className ) | ||
| $className | string | Class name |
Sets object property
| void setProperty( $object, $property, $value ) | ||
| $object | stdClass | |
| $property | string | |
| $value | \yii\twig\mixes | |
Generates absolute URL
| 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 |
|---|---|---|
| void viewHelper( $context, $name = null ) | ||
| $context | ||
| $name | ||
Function for *_widget syntax support
| mixed widget( $widget, $config = [] ) | ||
| $widget | string | Widget name |
| $config | array | Widget config |