maddoger / yii2-cms-core
此软件包最新版本(v1.1.0)没有可用的许可信息。
Yii2 CMS 核心扩展。
v1.1.0
2016-01-26 14:48 UTC
Requires
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2024-09-14 19:03:53 UTC
README
maddoger 的 Yii2 核心模块
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一
php composer.phar require --prefer-dist maddoger/yii2-cms-core "*"
或者
"maddoger/yii2-cms-core": "*"
将以下内容添加到你的 composer.json
文件的 require 部分。
日志记录到数据库
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
'db' => [
'class' => 'yii\log\DbTarget',
'levels' => ['error', 'warning'],
'except'=>['yii\web\HttpException:*', 'yii\i18n\I18N\*'],
'prefix'=>function () {
$url = !Yii::$app->request->isConsoleRequest ? Yii::$app->request->getUrl() : null;
return sprintf('[%s][%s]', Yii::$app->id, $url);
},
'logTable' => '{{%core_log}}',
],
],
],
配置
模块中的配置 - 属性 - 模型(前端 & 后端)
使用方法:- 加载 - 读取接口(模型或属性)
编辑方法:- 视图 - 模型 - 加载/保存接口
ConfigurationBehavior
通用行为。
'configurationBehavior' => [
'class' => ConfigurationBehavior::className(),
'key' => $this->id.'_custom', //owner class by default
//Reading
'attributes' => [
//Default values
'logoText' => $this->logoText,
'logoImageUrl' => $this->logoImageUrl,
'sortNumber' => $this->sortNumber,
],
'saveToOwnerProperties' => true, // if true all attributes will be written in owner properties
// otherwise configuration model/array will be available through getConfiguration()
//Editing
'view' => $this->getViewPath() . DIRECTORY_SEPARATOR . 'configuration.php',
//Model for user
'modelClass' => 'maddoger\admin\model\Configuration.php',
//OR
'dynamicModel' => [
'formName' => $this->id,
'rules' => [
[['logoText', 'logoImageUrl'], 'string'],
[['logoText', 'logoImageUrl', 'sortNumber'], 'default', ['value' => null]],
],
]
]