suver/yii2-settings

You settings

Installs: 64

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

1.0.10 2018-07-26 12:29 UTC

This package is not auto-updated.

Last update: 2024-11-23 20:47:51 UTC


README

Your Settings

Installation

Either run

php composer.phar require suver/yii2-settings

or add

"suver/yii2-settings": "*"

Install migrations

yii migrate --migrationPath=@vendor/suver/yii2-settings/migrations

How USE

/**
 * Configure setting 
 */
 
Settings::get('param-int')->configure(Settings::TYPE_INT);
//=> true

Settings::get('param-array')->configure(Settings::TYPE_ARRAY);
//=> true

Settings::get('param-param')->configure(Settings::TYPE_PARAM, [1 => ['text'=>'one'],2 => ['text'=>'two'],3 => ['text'=>'threa']]);
//=> true



/**
 * Set and configure setting 
 */
 
Settings::get('param-int')->configure(Settings::TYPE_INT)->set(4);
//=> true

Settings::get('param-varchar')->configure(Settings::TYPE_VARCHAR)->set("string");
//=> true

Settings::get('param-text')->configure(Settings::TYPE_TEXT)->set("text");
//=> true

Settings::get('param-array')->configure(Settings::TYPE_ARRAY)->set([1,2,3,4]);
//=> true

Settings::get('param-param')->configure(Settings::TYPE_PARAM, [1 => ['text'=>'one'],2 => ['text'=>'two'],3 => ['text'=>'threa']])->set(3);
//=> true

Settings::get('param-option')->configure(Settings::TYPE_OPTIONS, [1=>'one', 2=>'two'])->set(2);
//=> true

Settings::get('param-param')->configure(Settings::TYPE_PARAM, [1 => ['text'=>'one'],2 => ['text'=>'two'],3 => ['text'=>'threa']])->set(5);
//=> Exception



/**
 * Set setting 
 */
 
Settings::get('param-int')->set(4);
//=> true

Settings::get('param-varchar')->set("string");
//=> true


/**
 * Return value 
 */

print Settings::get('param-option-notset')->value(1);
//=> one

print Settings::get('param-option')->value(1);
//=> two

var_dump(Settings::get('param-option')->value(1));
//=> ['text'=>'threa']


var_dump(Settings::get('param-option')->param(1));
//=> 3


/**
 * Delete setting 
 */
 
Settings::get('param-int')->delete();
//=> true



/**
 * Clear setting 
 */
Settings::get('param-varchar')->set("value");
//=> true

Settings::get('param-varchar')->value();
//=> value


Settings::get('param-varchar')->clear(");
//=> true


Settings::get('param-varchar')->value();
//=> null