Class craft\services\Dashboard
- Inheritance
- craft\services\Dashboard » yii\base\Component » yii\base\BaseObject
- Implements
- yii\base\Configurable
- Available since version
- 3.0
- Source Code
- https://github.com/craftcms/cms/blob/master/src/services/Dashboard.php
Dashboard service.
An instance of the Dashboard service is globally accessible in Craft via Craft::$app->dashboard
.
Method | Description | Defined By |
---|---|---|
__call() |
Calls the named method which is not a class method. | yii\base\BaseObject |
__clone() |
This method is called after the object is created by cloning an existing one. | yii\base\Component |
__construct() |
Constructor. | yii\base\BaseObject |
__get() |
Returns the value of an object property. | yii\base\BaseObject |
__isset() |
Checks if a property is set, i.e. defined and not null. | yii\base\BaseObject |
__set() |
Sets value of an object property. | yii\base\BaseObject |
__unset() |
Sets an object property to null. | yii\base\BaseObject |
attachBehavior() |
Attaches a behavior to this component. | yii\base\Component |
attachBehaviors() |
Attaches a list of behaviors to the component. | yii\base\Component |
behaviors() |
Returns a list of behaviors that this component should behave as. | yii\base\Component |
canGetProperty() |
Returns a value indicating whether a property can be read. | yii\base\BaseObject |
canSetProperty() |
Returns a value indicating whether a property can be set. | yii\base\BaseObject |
changeWidgetColspan() |
Changes the colspan of a widget. | craft\services\Dashboard |
className() |
Returns the fully qualified name of this class. | yii\base\BaseObject |
createWidget() |
Creates a widget with a given config. | craft\services\Dashboard |
deleteWidget() |
Soft-deletes a widget. | craft\services\Dashboard |
deleteWidgetById() |
Soft-deletes a widget by its ID. | craft\services\Dashboard |
detachBehavior() |
Detaches a behavior from the component. | yii\base\Component |
detachBehaviors() |
Detaches all behaviors from the component. | yii\base\Component |
doesUserHaveWidget() |
Returns whether the current user has a widget of the given type. | craft\services\Dashboard |
ensureBehaviors() |
Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\base\Component |
getAllWidgetTypes() |
Returns all available widget type classes. | craft\services\Dashboard |
getAllWidgets() |
Returns the dashboard widgets for the current user. | craft\services\Dashboard |
getBehavior() |
Returns the named behavior object. | yii\base\Component |
getBehaviors() |
Returns all behaviors attached to this component. | yii\base\Component |
getWidgetById() |
Returns a widget by its ID. | craft\services\Dashboard |
hasEventHandlers() |
Returns a value indicating whether there is any handler attached to the named event. | yii\base\Component |
hasMethod() |
Returns a value indicating whether a method is defined. | yii\base\BaseObject |
hasProperty() |
Returns a value indicating whether a property is defined. | yii\base\BaseObject |
init() |
Initializes the object. | yii\base\BaseObject |
off() |
Detaches an existing event handler from this component. | yii\base\Component |
on() |
Attaches an event handler to an event. | yii\base\Component |
reorderWidgets() |
Reorders widgets. | craft\services\Dashboard |
saveWidget() |
Saves a widget for the current user. | craft\services\Dashboard |
trigger() |
Triggers an event. | yii\base\Component |
Event | Type | Description | Defined By |
---|---|---|---|
EVENT_AFTER_DELETE_WIDGET |
craft\events\WidgetEvent | The event that is triggered after a widget is deleted. | craft\services\Dashboard |
EVENT_AFTER_SAVE_WIDGET |
craft\events\WidgetEvent | The event that is triggered after a widget is saved. | craft\services\Dashboard |
EVENT_BEFORE_DELETE_WIDGET |
craft\events\WidgetEvent | The event that is triggered before a widget is deleted. | craft\services\Dashboard |
EVENT_BEFORE_SAVE_WIDGET |
craft\events\WidgetEvent | The event that is triggered before a widget is saved. | craft\services\Dashboard |
EVENT_REGISTER_WIDGET_TYPES |
craft\events\RegisterComponentTypesEvent | The event that is triggered when registering Dashboard widget types. | craft\services\Dashboard |
Method Details
changeWidgetColspan()
public method
#
Changes the colspan of a widget.
public boolean changeWidgetColspan ( \craft\services\int $widgetId, \craft\services\int $colspan )
$widgetId |
integer | |
$colspan |
integer |
createWidget()
public method
#
Creates a widget with a given config.
public craft\base\WidgetInterface createWidget ( $config )
$config |
mixed | The widget’s class name, or its config, with a type value and optionally a settings value.
|
deleteWidget()
public method
#
Soft-deletes a widget.
public boolean deleteWidget ( craft\base\WidgetInterface $widget )
$widget |
craft\base\WidgetInterface | The widget to be deleted |
return | boolean | Whether the widget was deleted successfully |
---|---|---|
throws | Throwable | if reasons |
deleteWidgetById()
public method
#
Soft-deletes a widget by its ID.
public boolean deleteWidgetById ( \craft\services\int $widgetId )
$widgetId |
integer | The widget’s ID |
return | boolean | Whether the widget was deleted successfully |
---|
doesUserHaveWidget()
public method
#
Returns whether the current user has a widget of the given type.
public boolean doesUserHaveWidget ( \craft\services\string $type )
$type |
string | The widget type |
return | boolean | Whether the current user has a widget of the given type |
---|
getAllWidgetTypes()
public method
#
Returns all available widget type classes.
public string[] getAllWidgetTypes ( )
getAllWidgets()
public method
#
Returns the dashboard widgets for the current user.
public craft\base\WidgetInterface[] getAllWidgets ( )
return | craft\base\WidgetInterface[] | The widgets |
---|
getWidgetById()
public method
#
Returns a widget by its ID.
public craft\base\WidgetInterface, null getWidgetById ( \craft\services\int $id )
$id |
integer | The widget’s ID |
return | craft\base\WidgetInterface, null | The widget, or null if it doesn’t exist |
---|
reorderWidgets()
public method
#
Reorders widgets.
public boolean reorderWidgets ( array $widgetIds )
$widgetIds |
integer[] | The widget IDs |
return | boolean | Whether the widgets were reordered successfully |
---|---|---|
throws | Throwable | if reasons |
saveWidget()
public method
#
Saves a widget for the current user.
public boolean saveWidget ( craft\base\WidgetInterface $widget, \craft\services\bool $runValidation = true )
$widget |
craft\base\WidgetInterface | The widget to be saved |
$runValidation |
boolean | Whether the widget should be validated |
return | boolean | Whether the widget was saved successfully |
---|---|---|
throws | Throwable | if reasons |
Event Details
EVENT_AFTER_DELETE_WIDGET
event of type craft\events\WidgetEvent
#
The event that is triggered after a widget is deleted.
EVENT_AFTER_SAVE_WIDGET
event of type craft\events\WidgetEvent
#
The event that is triggered after a widget is saved.
EVENT_BEFORE_DELETE_WIDGET
event of type craft\events\WidgetEvent
#
The event that is triggered before a widget is deleted.
EVENT_BEFORE_SAVE_WIDGET
event of type craft\events\WidgetEvent
#
The event that is triggered before a widget is saved.
EVENT_REGISTER_WIDGET_TYPES
event of type craft\events\RegisterComponentTypesEvent
#
The event that is triggered when registering Dashboard widget types.