PHP Trait skeeks\cms\traits\WidgetTrait

See also: yii\base\Widget Class WidgetTrait
Afficher le fichier Open project: skeeks-cms/cms

Méthodes publiques

Свойство Type Description
$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 WidgetTrait::begin and WidgetTrait::end methods.

Méthodes publiques

Méthode Description
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.

Method Details

begin() public static méthode

This method creates an instance of the calling class. It will apply the configuration to the created instance. A matching WidgetTrait::end call should be called later.
public static begin ( array $config = [] ) : static
$config array name-value pairs that will be used to initialize the object properties
Résultat static the newly created widget instance

end() public static méthode

Note that the rendering result of the widget is directly echoed out.
public static end ( ) : static
Résultat static the widget instance that is ended.

getId() public méthode

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
Résultat string ID of the widget.

getView() public méthode

The WidgetTrait::render and WidgetTrait::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
Résultat yii\web\View the view object that can be used to render views or view files.

getViewPath() public méthode

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

render() public méthode

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.
Résultat string the rendering result.

renderFile() public méthode

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.
Résultat string the rendering result.

run() public méthode

Executes the widget.
public run ( ) : string
Résultat string the result of widget execution to be outputted.

setId() public méthode

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

setView() public méthode

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() public static méthode

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
Résultat string the rendering result of the widget.

Property Details

$autoIdPrefix public_oe static_oe property

the prefix to the automatically generated widget IDs.
See also: getId()
public static $autoIdPrefix

$counter public_oe static_oe property

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

$stack public_oe static_oe property

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