Giter VIP home page Giter VIP logo

Comments (6)

arisk avatar arisk commented on August 22, 2024

Hi. Can you post the relevant code for your model and controller? In many cases you may not need to clear the cache manually as it's done in the model's afterSave and afterDelete methods. You're welcome by the way :)

from yii2-settings.

dub34 avatar dub34 commented on August 22, 2024

use backend\models\Settings;
use pheme\settings\SettingsAction;
class SettingsController extends \yii\web\Controller
{

public function actions()
{
    return [
        'index' => [
            'class' => SettingsAction::className(),
            'modelClass' => Settings::className(),
            'viewName' => 'index'
        ]
    ];
}

}

class Settings extends Model
{

public $system_tariffs;
public $order_distance;
....
public function formName()
{
return 'AdminSettings';
}

public function rules()
{
    return [
        [
            [
                'system_tariffs',
                'tariff_price_blocked_wheel',
                'tariff_price_blocked_steering_wheel',
                'tariff_price_truck_blocked_wheel',
                'tariff_price_truck_blocked_steering_wheel',
                'tariff_included_mileage',
                'urgent_order_time',
                'search_vehicle_timeout',
                'send_all_timeout',
                'vehicle_loading_timeout',
                'driver_app_version',
                'default_tariff_type',
                'agent_order_timeout',
                'intercity_service_commission',
                'auto_discount_time'
            ],
            'integer',
            'min' => 0
        ],
        [
            [
                'order_distance',
                'commission',
                'tariff_discount_website',
                'first_send_distance',
                'agent_order_commission',
                'agent_order_timeout',
                'sms_price'
            ],
            'double',
            'min' => 0
        ],
        ['credit_card_commission', 'double', 'min' => 0, 'max' => 100],
        [
            ['first_send_distance', 'send_all_timeout', 'vehicle_loading_timeout', 'driver_app_version'],
            'default',
            'value' => 0
        ],
        [['disable_agent_orders', 'check_driver_app_version'], 'boolean'],
        [['service_phone'], 'string'],
    ];
}

}

I override Settings component class. And override method get to hardcode section param beacause i want to get on backend only backend settings, and on frontend only user settings. And i do it through section.

namespace common\components\settings;
use backend\models\Settings as SettingsModel;

class Settings extends \pheme\settings\components\Settings
{
public function get($key, $section = null, $default = null)
{
return parent::get($key, (new SettingsModel)->formName(), $default);
}
}

from yii2-settings.

arisk avatar arisk commented on August 22, 2024

You may want to configure the component's modelClass. By default it's pheme\settings\models\BaseSetting which is not what you seem to be using. If you do, don't forget to implement pheme\settings\models\SettingInterface. That should fix your problem.

from yii2-settings.

dub34 avatar dub34 commented on August 22, 2024

by default Settings component use model pheme\settings\models\Setting. I don`t override it. If you mean, i need to create my own model and hardcode section in it, but it not fix problem with settings view.

from yii2-settings.

arisk avatar arisk commented on August 22, 2024

How are you clearing the cache? Since you're using your own controller and view for the UI it shouldn't be anything related to the component. Are there any errors in the your logs? Cache component can read and write correctly?

from yii2-settings.

dub34 avatar dub34 commented on August 22, 2024

Hi. I understand the problem. I have 2 projects with this module on 1 server with memcache. And both they use default cache key in settings. Thats why i get settings rawConfig from other project :(
Set custom cache key to config and all work. Thanks

from yii2-settings.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.