-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
1,825 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# yii console command | ||
/yii | ||
|
||
# phpstorm project files | ||
.idea | ||
|
||
# netbeans project files | ||
nbproject | ||
|
||
# zend studio for eclipse project files | ||
.buildpath | ||
.project | ||
.settings | ||
|
||
# windows thumbnail cache | ||
Thumbs.db | ||
|
||
# composer vendor dir | ||
#!/vendor | ||
#/vendor/* | ||
#!/vendor/mdmsoft | ||
/vendor | ||
|
||
# composer itself is not needed | ||
composer.phar | ||
|
||
# Mac DS_Store Files | ||
.DS_Store | ||
|
||
# phpunit itself is not needed | ||
phpunit.phar | ||
# local phpunit config | ||
/phpunit.xml | ||
|
||
# vagrant runtime | ||
/.vagrant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ | |
* @author Misbahul D Munir <[email protected]> | ||
* @since 1.0 | ||
*/ | ||
class Configs extends \yii\base\Object | ||
class Configs extends \yii\base\BaseObject | ||
{ | ||
const CACHE_TAG = 'izyue.admin'; | ||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/** | ||
* @link http://www.yiiframework.com/ | ||
* @copyright Copyright (c) 2008 Yii Software LLC | ||
* @license http://www.yiiframework.com/license/ | ||
*/ | ||
|
||
namespace izyue\admin\generators\controller; | ||
|
||
use yii\gii\generators\controller\Generator as BaseGenerator; | ||
|
||
/** | ||
* This generator will generate a controller and one or a few action view files. | ||
* | ||
* @property array $actionIDs An array of action IDs entered by the user. This property is read-only. | ||
* @property string $controllerFile The controller class file path. This property is read-only. | ||
* @property string $controllerID The controller ID. This property is read-only. | ||
* @property string $controllerNamespace The namespace of the controller class. This property is read-only. | ||
* @property string $controllerSubPath The controller sub path. This property is read-only. | ||
* | ||
* @author Qiang Xue <[email protected]> | ||
* @since 2.0 | ||
*/ | ||
class Generator extends BaseGenerator | ||
{ | ||
/** | ||
* @var string the controller class name | ||
*/ | ||
public $controllerClass; | ||
/** | ||
* @var string the controller's view path | ||
*/ | ||
public $viewPath; | ||
/** | ||
* @var string the base class of the controller | ||
*/ | ||
public $baseClass = 'backend\controllers\Controller'; | ||
/** | ||
* @var string list of action IDs separated by commas or spaces | ||
*/ | ||
public $actions = 'index'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
/** | ||
* This is the template for generating a controller class file. | ||
*/ | ||
|
||
use yii\helpers\Inflector; | ||
use yii\helpers\StringHelper; | ||
|
||
/* @var $this yii\web\View */ | ||
/* @var $generator yii\gii\generators\controller\Generator */ | ||
|
||
echo "<?php\n"; | ||
?> | ||
|
||
namespace <?= $generator->getControllerNamespace() ?>; | ||
|
||
class <?= StringHelper::basename($generator->controllerClass) ?> extends <?= '\\' . trim($generator->baseClass, '\\') . "\n" ?> | ||
{ | ||
<?php foreach ($generator->getActionIDs() as $action): ?> | ||
public function action<?= Inflector::id2camel($action) ?>() | ||
{ | ||
return $this->render('<?= $action ?>'); | ||
} | ||
|
||
<?php endforeach; ?> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
/** | ||
* This is the template for generating an action view file. | ||
*/ | ||
|
||
/* @var $this yii\web\View */ | ||
/* @var $generator yii\gii\generators\controller\Generator */ | ||
/* @var $action string the action ID */ | ||
|
||
echo "<?php\n"; | ||
?> | ||
/* @var $this yii\web\View */ | ||
<?= "?>" ?> | ||
|
||
<h1><?= $generator->getControllerSubPath() . $generator->getControllerID() . '/' . $action ?></h1> | ||
|
||
<p> | ||
You may change the content of this page by modifying | ||
the file <code><?= '<?=' ?> __FILE__; ?></code>. | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
/* @var $this yii\web\View */ | ||
/* @var $form yii\widgets\ActiveForm */ | ||
/* @var $generator yii\gii\generators\controller\Generator */ | ||
|
||
echo $form->field($generator, 'controllerClass'); | ||
echo $form->field($generator, 'actions'); | ||
echo $form->field($generator, 'viewPath'); | ||
echo $form->field($generator, 'baseClass'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* @link http://www.yiiframework.com/ | ||
* @copyright Copyright (c) 2008 Yii Software LLC | ||
* @license http://www.yiiframework.com/license/ | ||
*/ | ||
|
||
namespace izyue\admin\generators\crud; | ||
|
||
use yii\gii\generators\crud\Generator as BaseGenerator; | ||
|
||
/** | ||
* Generates CRUD | ||
* | ||
* @property array $columnNames Model column names. This property is read-only. | ||
* @property string $controllerID The controller ID (without the module ID prefix). This property is | ||
* read-only. | ||
* @property string $nameAttribute This property is read-only. | ||
* @property array $searchAttributes Searchable attributes. This property is read-only. | ||
* @property bool|\yii\db\TableSchema $tableSchema This property is read-only. | ||
* @property string $viewPath The controller view path. This property is read-only. | ||
* | ||
* @author Qiang Xue <[email protected]> | ||
* @since 2.0 | ||
*/ | ||
class Generator extends BaseGenerator | ||
{ | ||
public $modelClass = 'backend\models\\'; | ||
public $controllerClass = 'backend\controllers\\'; | ||
public $viewPath; | ||
public $baseControllerClass = 'backend\controllers\Controller'; | ||
public $indexWidgetType = 'grid'; | ||
public $searchModelClass = 'backend\models\searchs\\'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
<?php | ||
/** | ||
* This is the template for generating a CRUD controller class file. | ||
*/ | ||
|
||
use yii\db\ActiveRecordInterface; | ||
use yii\helpers\StringHelper; | ||
|
||
|
||
/* @var $this yii\web\View */ | ||
/* @var $generator yii\gii\generators\crud\Generator */ | ||
|
||
$controllerClass = StringHelper::basename($generator->controllerClass); | ||
$modelClass = StringHelper::basename($generator->modelClass); | ||
$searchModelClass = StringHelper::basename($generator->searchModelClass); | ||
if ($modelClass === $searchModelClass) { | ||
$searchModelAlias = $searchModelClass . 'Search'; | ||
} | ||
|
||
/* @var $class ActiveRecordInterface */ | ||
$class = $generator->modelClass; | ||
$pks = $class::primaryKey(); | ||
$urlParams = $generator->generateUrlParams(); | ||
$actionParams = $generator->generateActionParams(); | ||
$actionParamComments = $generator->generateActionParamComments(); | ||
|
||
echo "<?php\n"; | ||
?> | ||
|
||
namespace <?= StringHelper::dirname(ltrim($generator->controllerClass, '\\')) ?>; | ||
|
||
use Yii; | ||
use <?= ltrim($generator->modelClass, '\\') ?>; | ||
<?php if (!empty($generator->searchModelClass)): ?> | ||
use <?= ltrim($generator->searchModelClass, '\\') . (isset($searchModelAlias) ? " as $searchModelAlias" : "") ?>; | ||
<?php else: ?> | ||
use yii\data\ActiveDataProvider; | ||
<?php endif; ?> | ||
use <?= ltrim($generator->baseControllerClass, '\\') ?>; | ||
use yii\web\NotFoundHttpException; | ||
use yii\filters\VerbFilter; | ||
|
||
/** | ||
* <?= $controllerClass ?> implements the CRUD actions for <?= $modelClass ?> model. | ||
*/ | ||
class <?= $controllerClass ?> extends <?= StringHelper::basename($generator->baseControllerClass) . "\n" ?> | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function behaviors() | ||
{ | ||
return [ | ||
'verbs' => [ | ||
'class' => VerbFilter::className(), | ||
'actions' => [ | ||
'delete' => ['POST'], | ||
], | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* Lists all <?= $modelClass ?> models. | ||
* @return mixed | ||
*/ | ||
public function actionIndex() | ||
{ | ||
<?php if (!empty($generator->searchModelClass)): ?> | ||
$searchModel = new <?= isset($searchModelAlias) ? $searchModelAlias : $searchModelClass ?>(); | ||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
|
||
return $this->render('index', [ | ||
'searchModel' => $searchModel, | ||
'dataProvider' => $dataProvider, | ||
]); | ||
<?php else: ?> | ||
$dataProvider = new ActiveDataProvider([ | ||
'query' => <?= $modelClass ?>::find(), | ||
]); | ||
|
||
return $this->render('index', [ | ||
'dataProvider' => $dataProvider, | ||
]); | ||
<?php endif; ?> | ||
} | ||
|
||
/** | ||
* Displays a single <?= $modelClass ?> model. | ||
* <?= implode("\n * ", $actionParamComments) . "\n" ?> | ||
* @return mixed | ||
* @throws NotFoundHttpException if the model cannot be found | ||
*/ | ||
public function actionView(<?= $actionParams ?>) | ||
{ | ||
return $this->render('view', [ | ||
'model' => $this->findModel(<?= $actionParams ?>), | ||
]); | ||
} | ||
|
||
/** | ||
* Creates a new <?= $modelClass ?> model. | ||
* If creation is successful, the browser will be redirected to the 'view' page. | ||
* @return mixed | ||
*/ | ||
public function actionCreate() | ||
{ | ||
$model = new <?= $modelClass ?>(); | ||
|
||
if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
return $this->redirect(['view', <?= $urlParams ?>]); | ||
} | ||
|
||
return $this->render('create', [ | ||
'model' => $model, | ||
]); | ||
} | ||
|
||
/** | ||
* Updates an existing <?= $modelClass ?> model. | ||
* If update is successful, the browser will be redirected to the 'view' page. | ||
* <?= implode("\n * ", $actionParamComments) . "\n" ?> | ||
* @return mixed | ||
* @throws NotFoundHttpException if the model cannot be found | ||
*/ | ||
public function actionUpdate(<?= $actionParams ?>) | ||
{ | ||
$model = $this->findModel(<?= $actionParams ?>); | ||
|
||
if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
return $this->redirect(['view', <?= $urlParams ?>]); | ||
} | ||
|
||
return $this->render('update', [ | ||
'model' => $model, | ||
]); | ||
} | ||
|
||
/** | ||
* Deletes an existing <?= $modelClass ?> model. | ||
* If deletion is successful, the browser will be redirected to the 'index' page. | ||
* <?= implode("\n * ", $actionParamComments) . "\n" ?> | ||
* @return mixed | ||
* @throws NotFoundHttpException if the model cannot be found | ||
*/ | ||
public function actionDelete(<?= $actionParams ?>) | ||
{ | ||
$this->findModel(<?= $actionParams ?>)->delete(); | ||
|
||
return $this->redirect(['index']); | ||
} | ||
|
||
/** | ||
* Finds the <?= $modelClass ?> model based on its primary key value. | ||
* If the model is not found, a 404 HTTP exception will be thrown. | ||
* <?= implode("\n * ", $actionParamComments) . "\n" ?> | ||
* @return <?= $modelClass ?> the loaded model | ||
* @throws NotFoundHttpException if the model cannot be found | ||
*/ | ||
protected function findModel(<?= $actionParams ?>) | ||
{ | ||
<?php | ||
if (count($pks) === 1) { | ||
$condition = '$id'; | ||
} else { | ||
$condition = []; | ||
foreach ($pks as $pk) { | ||
$condition[] = "'$pk' => \$$pk"; | ||
} | ||
$condition = '[' . implode(', ', $condition) . ']'; | ||
} | ||
?> | ||
if (($model = <?= $modelClass ?>::findOne(<?= $condition ?>)) !== null) { | ||
return $model; | ||
} | ||
|
||
throw new NotFoundHttpException(<?= $generator->generateString('The requested page does not exist.') ?>); | ||
} | ||
} |
Oops, something went wrong.