Giter VIP home page Giter VIP logo

config's Introduction

Config Plugin for CakePHP

for cake 2.X

Plugin Puprose

Plugin is supposed to be used as site configuration storage. Plugin provide db storage for site configuration.

Plugin should loaded next way: CakePlugin::load('Config', array('bootstrap' => true)); Plugin need to load with bootstrap file, that will loads configuration data into the memory.

Edit and save configuration

Lets define simplest form with one setting parameter where we will store default site language.

<?php
	echo $this->Form->create('Config', array('url' => $this->here));

	echo $this->Form->input('Config.Default.language', array(
		'label' => __('Default language', true)));

	echo $this->Form->end(__('Save these settings', true));

Please mention that in te edit form need to use value name with "Config." preffx.

Best way to have new setting pages for plugin separated from Configs plugin is use cakephp convantion about plugin views overloading. So 'default.ctp' edit view page possible to place in app/View/Plugin/Config/Configs folder. After that default settings will available using /admin/config/configs/edit/default url.

Configuration usage

Configuration values accessible using Configure class. So if you have value Default.language stored in database you will able to read it using Configure::read('Default.language') call.

Tracking Configuration Changes

Config model dispatches CakeEvent named 'Config.Config.change' in its write() method, if any of key/value pairs was added or changed, and puts associative arrays with previous and new key/value pairs to its data property. Example usage with global event manager:

  • AppController
<?php
	App::uses('Post', 'Model');

	class AppController extends Controller {

		public function beforeFilter() {
			CakeEventManager::instance()->attach('Post::changeSettings', 'Config.Config.change', array('passParams' => true));
		}
	}
  • Post model
<?php
	App::uses('AppModel', 'Model');

	class Post extends AppModel {

		public static function changeSettings($old, $new) {
			// do your magic here
		}
	}

Requirements

  • PHP version: PHP 5.2+
  • CakePHP version: Cakephp 2.0

License

Copyright 2009-2012, Cake Development Corporation

Licensed under The MIT License
Redistributions of files must retain the above copyright notice.

Branch strategy

Build Status The master branch holds the STABLE latest version of the plugin.

Build Status Develop branch is UNSTABLE and used to test new features before releasing them.

Previous maintenance versions are named after the CakePHP compatible version, for example, branch 1.3 is the maintenance version compatible with CakePHP 1.3. All versions are updated with security patches.

Contributing to this Plugin

Please feel free to contribute to the plugin with new issues, requests, unit tests and code fixes or new features. If you want to contribute some code, create a feature branch from develop, and send us your pull request. Unit tests for new features and issues detected are mandatory to keep quality high.

Copyright

Copyright 2009-2012
Cake Development Corporation
1785 E. Sahara Avenue, Suite 490-423
Las Vegas, Nevada 89104
http://cakedc.com

config's People

Contributors

lorenzo avatar predominant avatar real34 avatar skie avatar steinkel avatar stork avatar yeliparra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

config's Issues

Security/Blackholed every time on POST

I've just updated to the latest commits (and moved the default view into my main app to override as instructed).

When I submit the config form it's being Blackholed everytime. If I remove the line

public $components = array('Security');

from ConfigAppController.php then it POSTs and updates the config data correctly. I believe I've had to do the same in the past.

Is this an issue related to the plugin or something I'm doing - I can't tell. Is there something that'll clearly tell me what's triggering the blackhole?

I can guess it's related to the fact that all the fields are user generate perhaps: http://book.cakephp.org/2.0/en/core-libraries/components/security-component.html

ConfigsController missing App::uses()

I wanted to extend ConfigsController in my application, but in order to do so the following line needed to be added to ConfigsController.php:

App::uses('ConfigAppController', 'Config.Controller');

It could also be added in my extending controller, but I think it belongs in ConfigsController.

I can fork and make a pull request if needed--just wanted to make sure you were aware. Thanks!

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.