-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added basic option to allow user configs, remove config from proxy
tabels #1639
- Loading branch information
Showing
7 changed files
with
110 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
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,16 @@ | ||
<?php | ||
|
||
namespace luya\admin\apis; | ||
|
||
/** | ||
* Config Controller. | ||
* | ||
* File has been created with `crud/create` command on LUYA version 1.0.0-dev. | ||
*/ | ||
class ConfigController extends \luya\admin\ngrest\base\Api | ||
{ | ||
/** | ||
* @var string The path to the model which is the provider for the rules and fields. | ||
*/ | ||
public $modelClass = 'luya\admin\models\Config'; | ||
} |
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
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,16 @@ | ||
<?php | ||
|
||
namespace luya\admin\controllers; | ||
|
||
/** | ||
* Config Controller. | ||
* | ||
* File has been created with `crud/create` command on LUYA version 1.0.0-dev. | ||
*/ | ||
class ConfigController extends \luya\admin\ngrest\base\Controller | ||
{ | ||
/** | ||
* @var string The path to the model which is the provider for the rules and fields. | ||
*/ | ||
public $modelClass = 'luya\admin\models\Config'; | ||
} |
25 changes: 25 additions & 0 deletions
25
modules/admin/src/migrations/m171129_104706_config_add_system_type.php
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,25 @@ | ||
<?php | ||
|
||
use yii\db\Migration; | ||
|
||
/** | ||
* Class m171129_104706_config_add_system_type | ||
*/ | ||
class m171129_104706_config_add_system_type extends Migration | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function safeUp() | ||
{ | ||
$this->addColumn('admin_config', 'is_system', $this->boolean()->defaultValue(true)); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function safeDown() | ||
{ | ||
$this->dropColumn('admin_config', 'is_system'); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
use yii\db\ActiveRecord; | ||
use luya\traits\RegistryTrait; | ||
use luya\admin\ngrest\base\NgRestModel; | ||
|
||
/** | ||
* This is the model class for table "admin_config". | ||
|
@@ -14,7 +15,7 @@ | |
* @author Basil Suter <[email protected]> | ||
* @since 1.0.0 | ||
*/ | ||
final class Config extends ActiveRecord | ||
final class Config extends NgRestModel | ||
{ | ||
use RegistryTrait; | ||
|
||
|
@@ -32,6 +33,14 @@ public static function tableName() | |
return 'admin_config'; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public static function ngRestApiEndpoint() | ||
{ | ||
return 'api-admin-config'; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
|
@@ -40,6 +49,7 @@ public function rules() | |
return [ | ||
[['name', 'value'], 'required'], | ||
[['name'], 'unique'], | ||
[['is_system'], 'integer'], | ||
]; | ||
} | ||
|
||
|
@@ -51,6 +61,39 @@ public function attributeLabels() | |
return [ | ||
'name' => 'Name', | ||
'value' => 'Value', | ||
'is_system' => 'System Config', | ||
]; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function ngRestAttributeTypes() | ||
{ | ||
return [ | ||
'value' => 'text', | ||
'name' => 'slug', | ||
'is_system' => ['hidden', 'value' => 0], | ||
]; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function ngRestScopes() | ||
{ | ||
return [ | ||
[['list'], ['name', 'value']], | ||
[['create', 'update'], ['name', 'value', 'is_system']], | ||
[['delete'], true], | ||
]; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public static function ngRestFind() | ||
{ | ||
return parent::ngRestFind()->where(['is_system' => false]); | ||
} | ||
} |