Commit cd47611b authored by Elias Luhr's avatar Elias Luhr

renaming from "widgets2" to widget

parent 8c9cbd01
<?php
namespace hrzg\widgets2;
namespace hrzg\widget;
/**
* This is just an example.
......
Widgets2 Module
widget Module
===============
Yii 2.0 Framework Widget Manager
......@@ -43,5 +43,5 @@ Usage
Once the extension is installed, simply use it in your code by :
```php
<?= \hrzg\widgets2\AutoloadExample::widget(); ?>
<?= \hrzg\widget\AutoloadExample::widget(); ?>
```
\ No newline at end of file
<?php
namespace hrzg\widgets2;
namespace hrzg\widget;
class Module extends \yii\base\Module
{
public $controllerNamespace = 'hrzg\widgets2\controllers';
public $controllerNamespace = 'hrzg\widget\controllers';
public function init()
{
......
<?php
namespace hrzg\widgets2\controllers;
namespace hrzg\widget\controllers;
use yii\web\Controller;
......
<?php
/**
* /app/src/../runtime/giiant/49eb2de82346bc30092f584268252ed2
*
* @package default
*/
namespace hrzg\widget\crud\controllers;
/**
* This is the class for controller "WidgetController".
*/
class WidgetController extends \hrzg\widget\crud\controllers\base\WidgetController
{
}
<?php
/**
* /app/src/../runtime/giiant/49eb2de82346bc30092f584268252ed2
*
* @package default
*/
namespace hrzg\widget\crud\controllers;
/**
* This is the class for controller "WidgetTemplateController".
*/
class WidgetTemplateController extends \hrzg\widget\crud\controllers\base\WidgetTemplateController
{
}
<?php
/**
* /app/src/../runtime/giiant/f197ab8e55d1e29a2dea883e84983544
*
* @package default
*/
namespace hrzg\widget\crud\controllers\api;
/**
* This is the class for REST controller "WidgetController".
*/
use yii\filters\AccessControl;
use yii\helpers\ArrayHelper;
class WidgetController extends \yii\rest\ActiveController
{
public $modelClass = 'hrzg\widget\crud\models\Widget';
/**
*
* @inheritdoc
* @return unknown
*/
public function behaviors() {
return ArrayHelper::merge(
parent::behaviors(),
[
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
/**
*
*/
'matchCallback' => function ($rule, $action) {return \Yii::$app->user->can($this->module->id . '_' . $this->id . '_' . $action->id, ['route' => true]);},
]
]
]
]
);
}
}
<?php
/**
* /app/src/../runtime/giiant/f197ab8e55d1e29a2dea883e84983544
*
* @package default
*/
namespace hrzg\widget\crud\controllers\api;
/**
* This is the class for REST controller "WidgetTemplateController".
*/
use yii\filters\AccessControl;
use yii\helpers\ArrayHelper;
class WidgetTemplateController extends \yii\rest\ActiveController
{
public $modelClass = 'hrzg\widget\crud\models\WidgetTemplate';
/**
*
* @inheritdoc
* @return unknown
*/
public function behaviors() {
return ArrayHelper::merge(
parent::behaviors(),
[
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
/**
*
*/
'matchCallback' => function ($rule, $action) {return \Yii::$app->user->can($this->module->id . '_' . $this->id . '_' . $action->id, ['route' => true]);},
]
]
]
]
);
}
}
<?php
/**
* /app/src/../runtime/giiant/358b0e44f1c1670b558e36588c267e47
*
* @package default
*/
// This class was automatically generated by a giiant build task
// You should not change it manually as it will be overwritten on next build
namespace hrzg\widget\crud\controllers\base;
use hrzg\widget\crud\models\Widget;
use hrzg\widget\crud\models\search\Widget as WidgetSearch;
use yii\web\Controller;
use yii\web\HttpException;
use yii\helpers\Url;
use yii\filters\AccessControl;
use dmstr\bootstrap\Tabs;
/**
* WidgetController implements the CRUD actions for Widget model.
*/
class WidgetController extends Controller
{
/**
*
* @var boolean whether to enable CSRF validation for the actions in this controller.
* CSRF validation is enabled only when both this property and [[Request::enableCsrfValidation]] are true.
*/
public $enableCsrfValidation = false;
/**
*
* @inheritdoc
* @return unknown
*/
public function behaviors() {
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
/**
*
*/
'matchCallback' => function ($rule, $action) {return \Yii::$app->user->can($this->module->id . '_' . $this->id . '_' . $action->id, ['route' => true]);},
]
]
]
];
}
/**
* Lists all Widget models.
*
* @return mixed
*/
public function actionIndex() {
$searchModel = new WidgetSearch;
$dataProvider = $searchModel->search($_GET);
Tabs::clearLocalStorage();
Url::remember();
\Yii::$app->session['__crudReturnUrl'] = null;
return $this->render('index', [
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
]);
}
/**
* Displays a single Widget model.
*
* @param integer $id
* @return mixed
*/
public function actionView($id) {
\Yii::$app->session['__crudReturnUrl'] = Url::previous();
Url::remember();
Tabs::rememberActiveState();
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Widget model.
* If creation is successful, the browser will be redirected to the 'view' page.
*
* @return mixed
*/
public function actionCreate() {
$model = new Widget;
try {
if ($model->load($_POST) && $model->save()) {
return $this->redirect(Url::previous());
} elseif (!\Yii::$app->request->isPost) {
$model->load($_GET);
}
} catch (\Exception $e) {
$msg = (isset($e->errorInfo[2]))?$e->errorInfo[2]:$e->getMessage();
$model->addError('_exception', $msg);
}
return $this->render('create', ['model' => $model]);
}
/**
* Updates an existing Widget model.
* If update is successful, the browser will be redirected to the 'view' page.
*
* @param integer $id
* @return mixed
*/
public function actionUpdate($id) {
$model = $this->findModel($id);
if ($model->load($_POST) && $model->save()) {
return $this->redirect(Url::previous());
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing Widget model.
* If deletion is successful, the browser will be redirected to the 'index' page.
*
* @param integer $id
* @return mixed
*/
public function actionDelete($id) {
try {
$this->findModel($id)->delete();
} catch (\Exception $e) {
$msg = (isset($e->errorInfo[2]))?$e->errorInfo[2]:$e->getMessage();
\Yii::$app->getSession()->addFlash('error', $msg);
return $this->redirect(Url::previous());
}
// TODO: improve detection
$isPivot = strstr('$id', ',');
if ($isPivot == true) {
return $this->redirect(Url::previous());
} elseif (isset(\Yii::$app->session['__crudReturnUrl']) && \Yii::$app->session['__crudReturnUrl'] != '/') {
Url::remember(null);
$url = \Yii::$app->session['__crudReturnUrl'];
\Yii::$app->session['__crudReturnUrl'] = null;
return $this->redirect($url);
} else {
return $this->redirect(['index']);
}
}
/**
* Finds the Widget model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
*
* @throws HttpException if the model cannot be found
* @param integer $id
* @return Widget the loaded model
*/
protected function findModel($id) {
if (($model = Widget::findOne($id)) !== null) {
return $model;
} else {
throw new HttpException(404, 'The requested page does not exist.');
}
}
}
<?php
/**
* /app/src/../runtime/giiant/358b0e44f1c1670b558e36588c267e47
*
* @package default
*/
// This class was automatically generated by a giiant build task
// You should not change it manually as it will be overwritten on next build
namespace hrzg\widget\crud\controllers\base;
use hrzg\widget\crud\models\WidgetTemplate;
use hrzg\widget\crud\models\search\WidgetTemplate as WidgetTemplateSearch;
use yii\web\Controller;
use yii\web\HttpException;
use yii\helpers\Url;
use yii\filters\AccessControl;
use dmstr\bootstrap\Tabs;
/**
* WidgetTemplateController implements the CRUD actions for WidgetTemplate model.
*/
class WidgetTemplateController extends Controller
{
/**
*
* @var boolean whether to enable CSRF validation for the actions in this controller.
* CSRF validation is enabled only when both this property and [[Request::enableCsrfValidation]] are true.
*/
public $enableCsrfValidation = false;
/**
*
* @inheritdoc
* @return unknown
*/
public function behaviors() {
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
/**
*
*/
'matchCallback' => function ($rule, $action) {return \Yii::$app->user->can($this->module->id . '_' . $this->id . '_' . $action->id, ['route' => true]);},
]
]
]
];
}
/**
* Lists all WidgetTemplate models.
*
* @return mixed
*/
public function actionIndex() {
$searchModel = new WidgetTemplateSearch;
$dataProvider = $searchModel->search($_GET);
Tabs::clearLocalStorage();
Url::remember();
\Yii::$app->session['__crudReturnUrl'] = null;
return $this->render('index', [
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
]);
}
/**
* Displays a single WidgetTemplate model.
*
* @param integer $id
* @return mixed
*/
public function actionView($id) {
\Yii::$app->session['__crudReturnUrl'] = Url::previous();
Url::remember();
Tabs::rememberActiveState();
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new WidgetTemplate model.
* If creation is successful, the browser will be redirected to the 'view' page.
*
* @return mixed
*/
public function actionCreate() {
$model = new WidgetTemplate;
try {
if ($model->load($_POST) && $model->save()) {
return $this->redirect(Url::previous());
} elseif (!\Yii::$app->request->isPost) {
$model->load($_GET);
}
} catch (\Exception $e) {
$msg = (isset($e->errorInfo[2]))?$e->errorInfo[2]:$e->getMessage();
$model->addError('_exception', $msg);
}
return $this->render('create', ['model' => $model]);
}
/**
* Updates an existing WidgetTemplate model.
* If update is successful, the browser will be redirected to the 'view' page.
*
* @param integer $id
* @return mixed
*/
public function actionUpdate($id) {
$model = $this->findModel($id);
if ($model->load($_POST) && $model->save()) {
return $this->redirect(Url::previous());
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing WidgetTemplate model.
* If deletion is successful, the browser will be redirected to the 'index' page.
*
* @param integer $id
* @return mixed
*/
public function actionDelete($id) {
try {
$this->findModel($id)->delete();
} catch (\Exception $e) {
$msg = (isset($e->errorInfo[2]))?$e->errorInfo[2]:$e->getMessage();
\Yii::$app->getSession()->addFlash('error', $msg);
return $this->redirect(Url::previous());
}
// TODO: improve detection
$isPivot = strstr('$id', ',');
if ($isPivot == true) {
return $this->redirect(Url::previous());
} elseif (isset(\Yii::$app->session['__crudReturnUrl']) && \Yii::$app->session['__crudReturnUrl'] != '/') {
Url::remember(null);
$url = \Yii::$app->session['__crudReturnUrl'];
\Yii::$app->session['__crudReturnUrl'] = null;
return $this->redirect($url);
} else {
return $this->redirect(['index']);
}
}
/**
* Finds the WidgetTemplate model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
*
* @throws HttpException if the model cannot be found
* @param integer $id
* @return WidgetTemplate the loaded model
*/
protected function findModel($id) {
if (($model = WidgetTemplate::findOne($id)) !== null) {
return $model;
} else {
throw new HttpException(404, 'The requested page does not exist.');
}
}
}
<?php
namespace hrzg\widget\crud\models;
use Yii;
use \hrzg\widget\crud\models\base\Widget as BaseWidget;
/**
* This is the model class for table "app_hrzg_widget".
*/
class Widget extends BaseWidget
{
}
<?php
namespace hrzg\widget\crud\models;
use Yii;
use \hrzg\widget\crud\models\base\WidgetTemplate as BaseWidgetTemplate;
/**
* This is the model class for table "app_hrzg_widget_template".
*/
class WidgetTemplate extends BaseWidgetTemplate
{
}
<?php
// This class was automatically generated by a giiant build task
// You should not change it manually as it will be overwritten on next build
namespace hrzg\widget\crud\models\base;
use Yii;
/**
* This is the base-model class for table "app_hrzg_widget".
*
* @property integer $id
* @property string $status
* @property string $class_name
* @property string $default_properties_json
* @property string $default_content_json
* @property string $name_id
* @property string $container_id
* @property string $rank
* @property string $route
* @property string $request_param
* @property string $access_owner
* @property string $access_domain
* @property string $access_read
* @property string $access_update
* @property string $access_delete
* @property string $created_at
* @property string $updated_at
* @property string $aliasModel
*/
abstract class Widget extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'app_hrzg_widget';
}
/**
* Alias name of table for crud viewsLists all Area models.
* Change the alias name manual if needed later
* @return string
*/
public function getAliasModel($plural=false)
{
if($plural){
return Yii::t('app', 'Widgets');
}else{
return Yii::t('app', 'Widget');
}
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['status', 'class_name', 'container_id', 'route'], 'required'],
[['default_properties_json', 'default_content_json'], 'string'],
[['created_at', 'updated_at'], 'safe'],
[['status'], 'string', 'max' => 32],
[['class_name', 'container_id', 'route'], 'string', 'max' => 128],
[['name_id'], 'string', 'max' => 64],
[['rank', 'access_owner'], 'string', 'max' => 11],
[['request_param', 'access_read', 'access_update', 'access_delete'], 'string', 'max' => 255],
[['access_domain'], 'string', 'max' => 8]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('app', 'ID'),
'status' => Yii::t('app', 'Status'),
'class_name' => Yii::t('app', 'Class Name'),
'default_properties_json' => Yii::t('app', 'Default Properties Json'),
'default_content_json' => Yii::t('app', 'Default Content Json'),
'name_id' => Yii::t('app', 'Name ID'),
'container_id' => Yii::t('app', 'Container ID'),
'rank' => Yii::t('app', 'Rank'),
'route' => Yii::t('app', 'Route'),
'request_param' => Yii::t('app', 'Request Param'),
'access_owner' => Yii::t('app', 'Access Owner'),
'access_domain' => Yii::t('app', 'Access Domain'),
'access_read' => Yii::t('app', 'Access Read'),
'access_update' => Yii::t('app', 'Access Update'),
'access_delete' => Yii::t('app', 'Access Delete'),
'created_at' => Yii::t('app', 'Created At'),
'updated_at' => Yii::t('app', 'Updated At'),
];
}
/**
* @inheritdoc
*/
public function attributeHints()
{
return array_merge(
parent::attributeHints(),
[
'id' => Yii::t('app', 'ID'),
'status' => Yii::t('app', 'Status'),
'class_name' => Yii::t('app', 'Class Name'),
'default_properties_json' => Yii::t('app', 'Default Properties Json'),
'default_content_json' => Yii::t('app', 'Default Content Json'),
'name_id' => Yii::t('app', 'Name Id'),
'container_id' => Yii::t('app', 'Container Id'),
'rank' => Yii::t('app', 'Rank'),
'route' => Yii::t('app', 'Route'),
'request_param' => Yii::t('app', 'Request Param'),
'access_owner' => Yii::t('app', 'Access Owner'),
'access_domain' => Yii::t('app', 'Access Domain'),
'access_read' => Yii::t('app', 'Access Read'),
'access_update' => Yii::t('app', 'Access Update'),
'access_delete' => Yii::t('app', 'Access Delete'),
'created_at' => Yii::t('app', 'Created At'),
'updated_at' => Yii::t('app', 'Updated At'),
]);
}
/**
* @inheritdoc
* @return \hrzg\widget\crud\models\query\WidgetQuery the active query used by this AR class.
*/
public static function find()
{
return new \hrzg\widget\crud\models\query\WidgetQuery(get_called_class());
}
}
<?php
// This class was automatically generated by a giiant build task
// You should not change it manually as it will be overwritten on next build
namespace hrzg\widget\crud\models\base;
use Yii;
/**
* This is the base-model class for table "app_hrzg_widget_template".
*
* @property integer $id
* @property string $name
* @property string $json_schema
* @property string $editor_settings
* @property string $form
* @property string $aliasModel
*/
abstract class WidgetTemplate extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'app_hrzg_widget_template';
}
/**
* Alias name of table for crud viewsLists all Area models.
* Change the alias name manual if needed later
* @return string
*/
public function getAliasModel($plural=false)
{
if($plural){
return Yii::t('app', 'WidgetTemplates');
}else{
return Yii::t('app', 'WidgetTemplate');
}
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['name', 'json_schema'], 'required'],
[['json_schema', 'editor_settings', 'form'], 'string'],
[['name'], 'string', 'max' => 255]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('app', 'ID'),
'name' => Yii::t('app', 'Name'),
'json_schema' => Yii::t('app', 'Json Schema'),
'editor_settings' => Yii::t('app', 'Editor Settings'),
'form' => Yii::t('app', 'Form'),
];
}
/**
* @inheritdoc
*/
public function attributeHints()
{
return array_merge(
parent::attributeHints(),
[
'id' => Yii::t('app', 'ID'),
'name' => Yii::t('app', 'Name'),
'json_schema' => Yii::t('app', 'Json Schema'),
'editor_settings' => Yii::t('app', 'Editor Settings'),
'form' => Yii::t('app', 'Form'),
]);
}
/**
* @inheritdoc
* @return \hrzg\widget\crud\models\query\WidgetTemplateQuery the active query used by this AR class.
*/
public static function find()
{
return new \hrzg\widget\crud\models\query\WidgetTemplateQuery(get_called_class());
}
}
<?php
namespace hrzg\widget\crud\models\query;
/**
* This is the ActiveQuery class for [[\hrzg\widget\crud\models\Widget]].
*
* @see \hrzg\widget\crud\models\Widget
*/
class WidgetQuery extends \yii\db\ActiveQuery
{
/*public function active()
{
$this->andWhere('[[status]]=1');
return $this;
}*/
/**
* @inheritdoc
* @return \hrzg\widget\crud\models\Widget[]|array
*/
public function all($db = null)
{
return parent::all($db);
}
/**
* @inheritdoc
* @return \hrzg\widget\crud\models\Widget|array|null
*/
public function one($db = null)
{
return parent::one($db);
}
}
<?php
namespace hrzg\widget\crud\models\query;
/**
* This is the ActiveQuery class for [[\hrzg\widget\crud\models\WidgetTemplate]].
*
* @see \hrzg\widget\crud\models\WidgetTemplate
*/
class WidgetTemplateQuery extends \yii\db\ActiveQuery
{
/*public function active()
{
$this->andWhere('[[status]]=1');
return $this;
}*/
/**
* @inheritdoc
* @return \hrzg\widget\crud\models\WidgetTemplate[]|array
*/
public function all($db = null)
{
return parent::all($db);
}
/**
* @inheritdoc
* @return \hrzg\widget\crud\models\WidgetTemplate|array|null
*/
public function one($db = null)
{
return parent::one($db);
}
}
<?php
/**
* /app/src/../runtime/giiant/e0080b9d6ffa35acb85312bf99a557f2
*
* @package default
*/
namespace hrzg\widget\crud\models\search;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use hrzg\widget\crud\models\Widget as WidgetModel;
/**
* Widget represents the model behind the search form about `hrzg\widget\crud\models\Widget`.
*/
class Widget extends WidgetModel
{
/**
*
* @inheritdoc
* @return unknown
*/
public function rules() {
return [
[['id'], 'integer'],
[['status', 'class_name', 'default_properties_json', 'default_content_json', 'name_id', 'container_id', 'rank', 'route', 'request_param', 'access_owner', 'access_domain', 'access_read', 'access_update', 'access_delete', 'created_at', 'updated_at'], 'safe'],
];
}
/**
*
* @inheritdoc
* @return unknown
*/
public function scenarios() {
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
*
* @param array $params
* @return ActiveDataProvider
*/
public function search($params) {
$query = WidgetModel::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'status', $this->status])
->andFilterWhere(['like', 'class_name', $this->class_name])
->andFilterWhere(['like', 'default_properties_json', $this->default_properties_json])
->andFilterWhere(['like', 'default_content_json', $this->default_content_json])
->andFilterWhere(['like', 'name_id', $this->name_id])
->andFilterWhere(['like', 'container_id', $this->container_id])
->andFilterWhere(['like', 'rank', $this->rank])
->andFilterWhere(['like', 'route', $this->route])
->andFilterWhere(['like', 'request_param', $this->request_param])
->andFilterWhere(['like', 'access_owner', $this->access_owner])
->andFilterWhere(['like', 'access_domain', $this->access_domain])
->andFilterWhere(['like', 'access_read', $this->access_read])
->andFilterWhere(['like', 'access_update', $this->access_update])
->andFilterWhere(['like', 'access_delete', $this->access_delete]);
return $dataProvider;
}
}
<?php
/**
* /app/src/../runtime/giiant/e0080b9d6ffa35acb85312bf99a557f2
*
* @package default
*/
namespace hrzg\widget\crud\models\search;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use hrzg\widget\crud\models\WidgetTemplate as WidgetTemplateModel;
/**
* WidgetTemplate represents the model behind the search form about `hrzg\widget\crud\models\WidgetTemplate`.
*/
class WidgetTemplate extends WidgetTemplateModel
{
/**
*
* @inheritdoc
* @return unknown
*/
public function rules() {
return [
[['id'], 'integer'],
[['name', 'json_schema', 'editor_settings', 'form'], 'safe'],
];
}
/**
*
* @inheritdoc
* @return unknown
*/
public function scenarios() {
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
*
* @param array $params
* @return ActiveDataProvider
*/
public function search($params) {
$query = WidgetTemplateModel::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
]);
$query->andFilterWhere(['like', 'name', $this->name])
->andFilterWhere(['like', 'json_schema', $this->json_schema])
->andFilterWhere(['like', 'editor_settings', $this->editor_settings])
->andFilterWhere(['like', 'form', $this->form]);
return $dataProvider;
}
}
......@@ -2,11 +2,11 @@
use yii\db\Migration;
class m160401_152059_add_widgets2_table extends Migration
class m160401_152059_add_widget_table extends Migration
{
public function up()
{
$this->createTable('{{%hrzg_widgets2}}', [
$this->createTable('{{%hrzg_widget}}', [
'id' => 'pk',
'status' => 'VARCHAR(32) NOT NULL',
'class_name' => 'VARCHAR(128) NOT NULL',
......@@ -29,7 +29,7 @@ class m160401_152059_add_widgets2_table extends Migration
public function down()
{
$this->dropTable('{{%hrzg_widgets2}}');
$this->dropTable('{{%hrzg_widget}}');
}
}
......@@ -2,26 +2,26 @@
use yii\db\Migration;
class m160401_152910_add_widgets2_auth_item extends Migration
class m160401_152910_add_widget_auth_item extends Migration
{
public function up()
{
$auth = Yii::$app->authManager;
if ($auth instanceof \yii\rbac\DbManager) {
$permission1 = $auth->createPermission('widgets2_crud_widget');
$permission1->description = 'Widgets2 CRUD';
$permission1 = $auth->createPermission('widget_crud_widget');
$permission1->description = 'widget CRUD';
$auth->add($permission1);
$permission2 = $auth->createPermission('widgets2_widget');
$permission2->description = 'Widgets2 CRUD (JSON Data)';
$permission2 = $auth->createPermission('widget_widget');
$permission2->description = 'widget CRUD (JSON Data)';
$auth->add($permission2);
$widgets2 = $auth->createPermission('widgets2');
$widgets2->description = 'Widgets2 Module';
$auth->add($widgets2);
$auth->addChild($widgets2, $permission1);
$auth->addChild($widgets2, $permission2);
$widget = $auth->createPermission('widget');
$widget->description = 'widget Module';
$auth->add($widget);
$auth->addChild($widget, $permission1);
$auth->addChild($widget, $permission2);
}
}
......@@ -30,9 +30,9 @@ class m160401_152910_add_widgets2_auth_item extends Migration
$auth = Yii::$app->authManager;
if ($auth instanceof \yii\rbac\DbManager) {
$auth->remove($auth->getPermission('widgets2_widget'));
$auth->remove($auth->getPermission('widgets2_widget'));
$auth->remove($auth->getChildren('widgets2'));
$auth->remove($auth->getPermission('widget_widget'));
$auth->remove($auth->getPermission('widget_widget'));
$auth->remove($auth->getChildren('widget'));
} else {
throw new \yii\base\Exception('Application authManager must be an instance of \yii\rbac\DbManager');
}
......
......@@ -2,11 +2,11 @@
use yii\db\Migration;
class m160401_153933_add_widgets2_editor_table extends Migration
class m160401_153933_add_widget_editor_table extends Migration
{
public function up()
{
$this->createTable('{{%hrzg_widget2_template}}', [
$this->createTable('{{%hrzg_widget_template}}', [
'id' => 'pk',
'name' => 'VARCHAR(255) NOT NULL',
'json_schema' => 'TEXT NOT NULL',
......@@ -17,7 +17,7 @@ class m160401_153933_add_widgets2_editor_table extends Migration
public function down()
{
$this->dropTable('{{%hrzg_widget2_template}}');
$this->dropTable('{{%hrzg_widget_template}}');
}
}
<?php
namespace hrzg\widgets2\traits;
namespace hrzg\widget\traits;
trait ActiveRecordDbConnectionTrait
{
......
......@@ -16,18 +16,18 @@ services:
- mariadb
- seleniumfirefox
environment:
APP_NAME: hrzg-widgets2
APP_TITLE: 'hrzg/yii2-widgets2-module'
APP_NAME: hrzg-widget
APP_TITLE: 'hrzg/yii2-widget-module'
YII_ENV: 'prod'
YII_DEBUG: 'false'
APP_CONFIG_FILE: /app/vendor/hrzg/yii2-widgets2-module/tests/_config/test.php
APP_CONFIG_FILE: /app/vendor/hrzg/yii2-widget-module/tests/_config/test.php
DB_PORT_3306_TCP_ADDR: mariadb
DB_PORT_3306_TCP_PORT: 3306
DB_ENV_MYSQL_ROOT_USER: root
DB_ENV_MYSQL_ROOT_PASSWORD: secretadmin
volumes:
- /app
- ../:/app/vendor/hrzg/yii2-widgets2-module
- ../:/app/vendor/hrzg/yii2-widget-module
#- ../tests/_config/local.php:/app/src/config/local.php
mariadb:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment