PHP 클래스 yii\base\Widget

For more details and usage information on Widget, see the guide article on widgets.
부터: 2.0
저자: Qiang Xue ([email protected])
상속: extends Component, implements yii\base\ViewContextInterface
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$autoIdPrefix the prefix to the automatically generated widget IDs.
$counter a counter used to generate [[id]] for widgets.
$stack the widgets that are currently being rendered (not ended). This property is maintained by Widget::begin and Widget::end methods.

공개 메소드들

메소드 설명
begin ( array $config = [] ) : static Begins a widget.
end ( ) : static Ends a widget.
getId ( boolean $autoGenerate = true ) : string Returns the ID of the widget.
getView ( ) : View Returns the view object that can be used to render views or view files.
getViewPath ( ) : string Returns the directory containing the view files for this widget.
render ( string $view, array $params = [] ) : string Renders a view.
renderFile ( string $file, array $params = [] ) : string Renders a view file.
run ( ) : string Executes the widget.
setId ( string $value ) Sets the ID of the widget.
setView ( View $view ) Sets the view object to be used by this widget.
widget ( array $config = [] ) : string Creates a widget instance and runs it.

메소드 상세

begin() 공개 정적인 메소드

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.
또한 보기: end()
public static begin ( array $config = [] ) : static
$config array name-value pairs that will be used to initialize the object properties
리턴 static the newly created widget instance

end() 공개 정적인 메소드

Note that the rendering result of the widget is directly echoed out.
또한 보기: begin()
public static end ( ) : static
리턴 static the widget instance that is ended.

getId() 공개 메소드

Returns the ID of the widget.
public getId ( boolean $autoGenerate = true ) : string
$autoGenerate boolean whether to generate an ID if it is not set previously
리턴 string ID of the widget.

getView() 공개 메소드

The Widget::render and Widget::renderFile methods will use this view object to implement the actual view rendering. If not set, it will default to the "view" application component.
public getView ( ) : View
리턴 yii\web\View the view object that can be used to render views or view files.

getViewPath() 공개 메소드

The default implementation returns the 'views' subdirectory under the directory containing the widget class file.
public getViewPath ( ) : string
리턴 string the directory containing the view files for this widget.

render() 공개 메소드

The view to be rendered can be specified in one of the following formats: - path alias (e.g. "@app/views/site/index"); - absolute path within application (e.g. "//site/index"): the view name starts with double slashes. The actual view file will be looked for under the [[Application::viewPath|view path]] of the application. - absolute path within module (e.g. "/site/index"): the view name starts with a single slash. The actual view file will be looked for under the [[Module::viewPath|view path]] of the currently active module. - relative path (e.g. "index"): the actual view file will be looked for under [[viewPath]]. If the view name does not contain a file extension, it will use the default one .php.
public render ( string $view, array $params = [] ) : string
$view string the view name.
$params array the parameters (name-value pairs) that should be made available in the view.
리턴 string the rendering result.

renderFile() 공개 메소드

Renders a view file.
public renderFile ( string $file, array $params = [] ) : string
$file string the view file to be rendered. This can be either a file path or a path alias.
$params array the parameters (name-value pairs) that should be made available in the view.
리턴 string the rendering result.

run() 공개 메소드

Executes the widget.
public run ( ) : string
리턴 string the result of widget execution to be outputted.

setId() 공개 메소드

Sets the ID of the widget.
public setId ( string $value )
$value string id of the widget.

setView() 공개 메소드

Sets the view object to be used by this widget.
public setView ( View $view )
$view View the view object that can be used to render views or view files.

widget() 공개 정적인 메소드

The widget rendering result is returned by this method.
public static widget ( array $config = [] ) : string
$config array name-value pairs that will be used to initialize the object properties
리턴 string the rendering result of the widget.

프로퍼티 상세

$autoIdPrefix 공개적으로 정적으로 프로퍼티

the prefix to the automatically generated widget IDs.
또한 보기: getId()
public static $autoIdPrefix

$counter 공개적으로 정적으로 프로퍼티

a counter used to generate [[id]] for widgets.
public static $counter

$stack 공개적으로 정적으로 프로퍼티

the widgets that are currently being rendered (not ended). This property is maintained by Widget::begin and Widget::end methods.
public static $stack