solutosoft/yii-settings
Composer 安装命令:
composer require solutosoft/yii-settings
包简介
The Shared Database used by all tenants
关键字:
README 文档
README
This extension provides support for persistent settings for Yii2.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist solutosoft/yii-settings
or add
"solutosoft/yii-settings": "*"
Configuration
To use the Setting Component, you need to configure the components array in your application configuration:
'components' => [ 'settings' => [ 'class' => 'solutosoft\settings\Settings', ], ],
Usage
$settings = Yii::$app->settings; $settings->set('key'); $settings->set('section.key'); // Checking existence of setting $settings->exists('key'); // Removes a setting $settings->remove('key'); // Removes all settings $settings->removeAll();
Events
You can use beforeExecute event to store extra values and apply extra conditions on command execution
<?php 'components' => [ 'settings' => [ 'class' => 'solutosoft\settings\Settings', 'on beforeExecute' => function ($event) { $event->data = ['user_id' => Yii::$app->user->id]; } ], ], $settings = Yii::$app->settings; //INSERT (`key`,`value`, `user_id`) INTO `setting` VALUES ('website', 'http://example.org', 1) $settings->set('website', 'http://example.org'); //SELECT `value` FROM `setting` WHER (`settings`.`key` = 'website' and `settings`.`user_id` = 1) $settings->get('website', 'http://example.org');
统计信息
- 总下载量: 1.95k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2019-04-29