anklimsk / cakephp-config-plugin
Initialize and get the plugin configuration for the CakePHP 2.x
Installs: 1 147
Dependents: 5
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:cakephp-plugin
Requires
- php: >=5.4
- anklimsk/cakephp-extended-test: ^1.0.0
- composer/installers: ^1.5.0
This package is auto-updated.
Last update: 2024-10-29 05:34:17 UTC
README
Initialize and get the plugin configuration.
This plugin provides next features:
- Initialize and get the plugin configuration.
Installation
-
Install the Plugin using composer:
composer require anklimsk/cakephp-config-plugin
-
Add the next line to the end of the file
app/Config/bootstrap.php
:CakePlugin::load('CakeConfigPlugin', ['bootstrap' => true]);
Using this plugin
-
Include in the
AppModel
model of your plugin the behaviorInitConfig
:public $actsAs = [ 'CakeConfigPlugin.InitConfig' => [ 'pluginName' => 'SomePluginName', 'checkPath' => 'SomePluginName.param' ] ];
-
Create a configuration file in the
Config
directory of your plug-in, e.g.:somepluginname.php
-
Fill configuration file, e.g.:
$config['SomePluginName'] = [ 'param' => 'value' ... ];
-
If necessary, copy config file from 'app/Plugin/SomePluginName/Config/somepluginname.php' to 'app/Config', and edit it.
-
If you need to overwrite the configuration parameter in the application, use:
Configure::write('SomePluginName.param', 'newValue'); // After, in Model call: $this->initConfig(true);
-
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);