yii\base\Widget::begin PHP Method

begin() public static method

This method creates an instance of the calling class. It will apply the configuration to the created instance. A matching Widget::end call should be called later. As some widgets may use output buffering, the Widget::end call should be made in the same view to avoid breaking the nesting of output buffers.
See also: end()
public static begin ( array $config = [] ) : static
$config array name-value pairs that will be used to initialize the object properties
return static the newly created widget instance
    public static function begin($config = [])
    {
        $config['class'] = get_called_class();
        /* @var $widget Widget */
        $widget = Yii::createObject($config);
        static::$stack[] = $widget;
        return $widget;
    }

Usage Example

Ejemplo n.º 1
0
 public static function begin($config = [])
 {
     $widget = parent::begin($config);
     //Когда виджет рендерится вместе с контентом то используется собственный элемент
     //        $widget->element = '#' . $widget->options['id'];
     return $widget;
 }
All Usage Examples Of yii\base\Widget::begin