Class lispa\amos\core\migration\AmosMigrationWidgets

Inheritancelispa\amos\core\migration\AmosMigrationWidgets » yii\db\Migration » yii\base\Component » yii\base\Object
Implementsyii\base\Configurable, yii\db\MigrationInterface
Uses Traitsyii\db\SchemaBuilderTrait

Class AmosMigrationWidgets

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$behaviors yii\base\Behavior[] List of behaviors attached to this component yii\base\Component
$db yii\db\Connection|array|string The DB connection object or the application component ID of the DB connection that this migration should work with. yii\db\Migration

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$widgets array This array contains all widgets configurations. lispa\amos\core\migration\AmosMigrationWidgets

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__call() Calls the named method which is not a class method. yii\base\Component
__clone() This method is called after the object is created by cloning an existing one. yii\base\Component
__construct() Constructor. yii\base\Object
__get() Returns the value of a component property. yii\base\Component
__isset() Checks if a property is set, i.e. defined and not null. yii\base\Component
__set() Sets the value of a component property. yii\base\Component
__unset() Sets a component property to be null. yii\base\Component
addColumn() Builds and executes a SQL statement for adding a new DB column. yii\db\Migration
addCommentOnColumn() Builds and execute a SQL statement for adding comment to column yii\db\Migration
addCommentOnTable() Builds a SQL statement for adding comment to table yii\db\Migration
addForeignKey() Builds a SQL statement for adding a foreign key constraint to an existing table. yii\db\Migration
addPrimaryKey() Builds and executes a SQL statement for creating a primary key. yii\db\Migration
afterAddWidgets() Override this to make operations after adding the widgets. lispa\amos\core\migration\AmosMigrationWidgets
afterRemoveWidgets() Override this to make operations after removing the widgets. lispa\amos\core\migration\AmosMigrationWidgets
alterColumn() Builds and executes a SQL statement for changing the definition of a column. yii\db\Migration
attachBehavior() Attaches a behavior to this component. yii\base\Component
attachBehaviors() Attaches a list of behaviors to the component. yii\base\Component
batchInsert() Creates and executes an batch INSERT SQL statement. yii\db\Migration
beforeAddWidgets() Override this to make operations before adding the widgets. lispa\amos\core\migration\AmosMigrationWidgets
beforeRemoveWidgets() Override this to make operations before removing the widgets. lispa\amos\core\migration\AmosMigrationWidgets
behaviors() Returns a list of behaviors that this component should behave as. yii\base\Component
bigInteger() Creates a bigint column. yii\db\SchemaBuilderTrait
bigPrimaryKey() Creates a big primary key column. yii\db\SchemaBuilderTrait
binary() Creates a binary column. yii\db\SchemaBuilderTrait
boolean() Creates a boolean column. yii\db\SchemaBuilderTrait
canGetProperty() Returns a value indicating whether a property can be read. yii\base\Component
canSetProperty() Returns a value indicating whether a property can be set. yii\base\Component
char() Creates a char column. yii\db\SchemaBuilderTrait
className() Returns the fully qualified name of this class. yii\base\Object
createIndex() Builds and executes a SQL statement for creating a new index. yii\db\Migration
createTable() Builds and executes a SQL statement for creating a new DB table. yii\db\Migration
date() Creates a date column. yii\db\SchemaBuilderTrait
dateTime() Creates a datetime column. yii\db\SchemaBuilderTrait
decimal() Creates a decimal column. yii\db\SchemaBuilderTrait
delete() Creates and executes a DELETE SQL statement. yii\db\Migration
detachBehavior() Detaches a behavior from the component. yii\base\Component
detachBehaviors() Detaches all behaviors from the component. yii\base\Component
double() Creates a double column. yii\db\SchemaBuilderTrait
down() This method contains the logic to be executed when removing this migration. yii\db\Migration
dropColumn() Builds and executes a SQL statement for dropping a DB column. yii\db\Migration
dropCommentFromColumn() Builds and execute a SQL statement for dropping comment from column yii\db\Migration
dropCommentFromTable() Builds a SQL statement for dropping comment from table yii\db\Migration
dropForeignKey() Builds a SQL statement for dropping a foreign key constraint. yii\db\Migration
dropIndex() Builds and executes a SQL statement for dropping an index. yii\db\Migration
dropPrimaryKey() Builds and executes a SQL statement for dropping a primary key. yii\db\Migration
dropTable() Builds and executes a SQL statement for dropping a DB table. yii\db\Migration
ensureBehaviors() Makes sure that the behaviors declared in behaviors() are attached to this component. yii\base\Component
execute() Executes a SQL statement. yii\db\Migration
float() Creates a float column. yii\db\SchemaBuilderTrait
getBehavior() Returns the named behavior object. yii\base\Component
getBehaviors() Returns all behaviors attached to this component. yii\base\Component
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\Component
hasProperty() Returns a value indicating whether a property is defined for this component. yii\base\Component
init() lispa\amos\core\migration\AmosMigrationWidgets
insert() Creates and executes an INSERT SQL statement. yii\db\Migration
integer() Creates an integer column. yii\db\SchemaBuilderTrait
money() Creates a money column. yii\db\SchemaBuilderTrait
off() Detaches an existing event handler from this component. yii\base\Component
on() Attaches an event handler to an event. yii\base\Component
primaryKey() Creates a primary key column. yii\db\SchemaBuilderTrait
renameColumn() Builds and executes a SQL statement for renaming a column. yii\db\Migration
renameTable() Builds and executes a SQL statement for renaming a DB table. yii\db\Migration
safeDown() This method contains the logic to be executed when removing this migration. lispa\amos\core\migration\AmosMigrationWidgets
safeUp() This method contains the logic to be executed when applying this migration. lispa\amos\core\migration\AmosMigrationWidgets
smallInteger() Creates a smallint column. yii\db\SchemaBuilderTrait
string() Creates a string column. yii\db\SchemaBuilderTrait
text() Creates a text column. yii\db\SchemaBuilderTrait
time() Creates a time column. yii\db\SchemaBuilderTrait
timestamp() Creates a timestamp column. yii\db\SchemaBuilderTrait
trigger() Triggers an event. yii\base\Component
truncateTable() Builds and executes a SQL statement for truncating a DB table. yii\db\Migration
up() This method contains the logic to be executed when applying this migration. yii\db\Migration
update() Creates and executes an UPDATE SQL statement. yii\db\Migration

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
checkWidgetExist() This method check if a widget already exists in the amos_widgets table. Return true if the widget exists. lispa\amos\core\migration\AmosMigrationWidgets
getDb() yii\db\SchemaBuilderTrait
initWidgetsConfs() In this method you must define the widgets configurations. You must set the configurations in the global "$this->widgets = []" array. lispa\amos\core\migration\AmosMigrationWidgets
insertOrUpdateWidget() Method to add a widget configuration. lispa\amos\core\migration\AmosMigrationWidgets
replaceExistentWidget() This method replace an existent widget if exists. lispa\amos\core\migration\AmosMigrationWidgets
updateExistentWidget() This method update an existent widget if exists. lispa\amos\core\migration\AmosMigrationWidgets

Property Details

$widgets protected property

This array contains all widgets configurations.

protected array $widgets null

Method Details

afterAddWidgets() public method

Override this to make operations after adding the widgets.

public boolean afterAddWidgets ( )
afterRemoveWidgets() public method

Override this to make operations after removing the widgets.

public boolean afterRemoveWidgets ( )
beforeAddWidgets() public method

Override this to make operations before adding the widgets.

public boolean beforeAddWidgets ( )
beforeRemoveWidgets() public method

Override this to make operations before removing the widgets.

public boolean beforeRemoveWidgets ( )
checkWidgetExist() protected method

This method check if a widget already exists in the amos_widgets table. Return true if the widget exists.

protected boolean checkWidgetExist ( $widgetData, $classNameField )
$widgetData array

The widget data.

$classNameField string

The widget data class name field.

return boolean

Returns true if the widget exists. False otherwise.

init() public method

See also yii\db\Migration::init() for more info.

public void init ( )
initWidgetsConfs() protected method

In this method you must define the widgets configurations. You must set the configurations in the global "$this->widgets = []" array.

A single widget configuration is an array. You must set these minimum keys: classname, type, module, status. You can also set these other keys: child_of, default_order, update. Key "classname": the classname of the widget (string) Key "type": the type of the widget, icon or graphic, defined with AmosWidgets::TYPE_ICON or AmosWidgets::TYPE_GRAPHIC (string) Key "module": the module that is referenced by the widget (string) Key "status": the status of the widget, defined by AmosWidgets::STATUS_ENABLED or AmosWidgets::STATUS_DISABLED (int) Key "default_order": the default order of the widget used in tab dashboard initialization (int) (optional) Key "update": if true means that updates the widget if it exists. The parameter is not considered if parameter "old_classname" is set (bool) (optional) Key "old_classname": if is set means that the widget will be replaced if it exists. Only the other fields set will be overwritten by the corresponding field value. This mean that you can set only the "old_classname" and "classname" key in the conf array. (string) (optional).

protected void initWidgetsConfs ( )
insertOrUpdateWidget() protected method

Method to add a widget configuration.

protected boolean insertOrUpdateWidget ( $widgetData )
$widgetData array

Key => value array that contains all data to insert in AmosWidgets table.

replaceExistentWidget() protected method

This method replace an existent widget if exists.

protected boolean replaceExistentWidget ( $widgetData )
$widgetData array

Key => value array that contains all widget data.

safeDown() public method

This method contains the logic to be executed when removing this migration.

This method differs from down() in that the DB logic implemented here will be enclosed within a DB transaction. Child classes may implement this method instead of down() if the DB logic needs to be within a transaction.

Note: Not all DBMS support transactions. And some DB queries cannot be put into a transaction. For some examples, please refer to implicit commit. If this is the case, you should still implement up() and down(), instead.

public boolean safeDown ( )
return boolean

Return a false value to indicate the migration fails and should not proceed further. All other return values mean the migration succeeds.

safeUp() public method

This method contains the logic to be executed when applying this migration.

This method differs from up() in that the DB logic implemented here will be enclosed within a DB transaction. Child classes may implement this method instead of up() if the DB logic needs to be within a transaction.

Note: Not all DBMS support transactions. And some DB queries cannot be put into a transaction. For some examples, please refer to implicit commit. If this is the case, you should still implement up() and down(), instead.

public boolean safeUp ( )
return boolean

Return a false value to indicate the migration fails and should not proceed further. All other return values mean the migration succeeds.

updateExistentWidget() protected method

This method update an existent widget if exists.

protected boolean updateExistentWidget ( $widgetData )
$widgetData array

Key => value array that contains all widget data.