Scalr_Account_User::addDashboardWidget PHP Method

addDashboardWidget() public method

Adds widget to dashboard
public addDashboardWidget ( integer $envId, array $widgetConfig, integer $columnNumber, integer $position )
$envId integer The identifier of the environment
$widgetConfig array Widget config
$columnNumber integer optional the number of the column
$position integer optional the position
    public function addDashboardWidget($envId, $widgetConfig, $columnNumber = 0, $position = 0)
    {
        $dashboard = $this->getDashboard($envId);
        // we could use maximum only last column, do not create new one
        $columnNumber = $columnNumber >= count($dashboard['configuration']) ? count($dashboard['configuration']) - 1 : $columnNumber;
        array_splice($dashboard['configuration'][$columnNumber], min($position, count($dashboard['configuration'][$columnNumber])), 0, array($widgetConfig));
        $this->setDashboard($envId, $dashboard);
    }