Revision #13 was created by Kartik V on May 9, 2014, 4:34:25 AM.
Updated model find method and attribute calls
Content
[...]
Design
------
The design approach involves creating the data structure to store the serialized array configurations with tags as variables that will be replaced at runtime. The rules/validators for validating the widget configuration, will also be stored serialized in a rules column. While running the widget at runtime, the rules will be validated dynamically using the yii\base\DynamicModel.
### 1. Data Structure
Create a table `tbl_widget_config` in your database with the following minimum columns. Create a model called `WidgetConfig` for this table through gii.
~~~
[...]
// Retrieve the configuration
public function runWidget($configId) {
$dbWidget = WidgetConfig::findOne($configId)->asArray();
$widgetConfig = \yii\base\DynamicModel::validateData(
static::parseTags($dbWidget['->config']),
static::parseTags($dbWidget['->rules'])
);
// To run the widget call below
$class = $dbWidget['->class_name'];