anklimsk/cakephp-config-plugin

Initialize and get the plugin configuration for the CakePHP 2.x

v1.0.1 2018-11-19 09:16 UTC

This package is auto-updated.

Last update: 2024-11-29 05:39:04 UTC


README

Build Status Coverage Status Latest Stable Version License

Initialize and get the plugin configuration.

This plugin provides next features:

  • Initialize and get the plugin configuration.

Installation

  1. Install the Plugin using composer: composer require anklimsk/cakephp-config-plugin

  2. Add the next line to the end of the file app/Config/bootstrap.php:

    CakePlugin::load('CakeConfigPlugin', ['bootstrap' => true]);

Using this plugin

  1. Include in the AppModel model of your plugin the behavior InitConfig:

        public $actsAs = [
            'CakeConfigPlugin.InitConfig' => [
                'pluginName' => 'SomePluginName',
                'checkPath' => 'SomePluginName.param'
            ]
        ];
  2. Create a configuration file in the Config directory of your plug-in, e.g.: somepluginname.php

  3. Fill configuration file, e.g.:

        $config['SomePluginName'] = [
            'param' => 'value'
            ...
        ];
  4. If necessary, copy config file from 'app/Plugin/SomePluginName/Config/somepluginname.php' to 'app/Config', and edit it.

  5. If you need to overwrite the configuration parameter in the application, use:

    Configure::write('SomePluginName.param', 'newValue');
    
    //  After, in Model call:
    $this->initConfig(true);
  6. For initialize plugin configuration, use:

    App::uses('InitConfig', 'CakeConfigPlugin.Utility');
    
    $pluginName = 'SomePluginName';
    $checkPath = 'SomePluginName.param';
    $configFile = 'somepluginname';
    $initConfig = new InitConfig($pluginName, $checkPath, $configFile);
    
    $force = false;
    $initConfig->initConfig($force);