Skip to content

Commit

Permalink
rename controller properties, update README
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-chepurnoi committed Nov 10, 2016
1 parent 56d6b62 commit 4ab2c48
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,18 @@ To access the module, you need to configure the modules array in your applicatio
'modules' => [
'settings' => [
'class' => 'yii2mod\settings\Module',
// Some controller properties maybe need to change.
// Also you can override some controller properties in following way:
'controllerMap' => [
'default' => [
'class' => 'yii2mod\settings\controllers\DefaultController',
'searchClass' => [
'class' => 'yii2mod\settings\models\search\SettingSearch',
'pageSize' => 25
],
'modelClass' => 'Your own cms model class',
'indexView' => 'custom path to index view file',
'settingSearchClass' => 'Your own search model class'
'createView' => 'custom path to create view file',
'updateView' => 'custom path to update view file',
]
]
],
Expand Down
14 changes: 7 additions & 7 deletions controllers/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ class DefaultController extends Controller
public $updateView = '@vendor/yii2mod/yii2-settings/views/default/update';

/**
* @var string search class name for settings search
* @var string search class name for searching
*/
public $settingSearchClass = 'yii2mod\settings\models\search\SettingSearch';
public $searchClass = 'yii2mod\settings\models\search\SettingSearch';

/**
* @var string settings model class name for CRUD operations
* @var string model class name for CRUD operations
*/
public $settingModelClass = 'yii2mod\settings\models\SettingModel';
public $modelClass = 'yii2mod\settings\models\SettingModel';

/**
* Returns a list of behaviors that this component should behave as.
Expand Down Expand Up @@ -83,7 +83,7 @@ public function actions()
*/
public function actionIndex()
{
$searchModel = Yii::createObject($this->settingSearchClass);
$searchModel = Yii::createObject($this->searchClass);
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);

return $this->render($this->indexView, [
Expand All @@ -101,7 +101,7 @@ public function actionIndex()
*/
public function actionCreate()
{
$model = Yii::createObject($this->settingModelClass);
$model = Yii::createObject($this->modelClass);

if ($model->load(Yii::$app->request->post()) && $model->save()) {
Yii::$app->session->setFlash('success', Yii::t('yii2mod.settings', 'Setting has been created.'));
Expand Down Expand Up @@ -162,7 +162,7 @@ public function actionDelete($id)
*/
protected function findModel($id)
{
$settingModelClass = $this->settingModelClass;
$settingModelClass = $this->modelClass;

if (($model = $settingModelClass::findOne($id)) !== null) {
return $model;
Expand Down
7 changes: 6 additions & 1 deletion models/search/SettingSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
*/
class SettingSearch extends SettingModel
{
/**
* @var int the default page size.
*/
public $pageSize = 10;

/**
* @inheritdoc
*/
Expand All @@ -35,7 +40,7 @@ public function search($params)
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSize' => 10
'pageSize' => $this->pageSize
]
]);

Expand Down

0 comments on commit 4ab2c48

Please sign in to comment.