kpPropelSettingsPlugin - 0.0.1
Manage user-controlled site settings.
You are currently browsing
the website for symfony 1
Much like the sfConfig::get() method, use kpSettings::get() to call dynamic, user-defined settings. An admin generator interface allows easy administration.
It is csSettingsPlugin by Brent Shaffer which was converted by me to utilize Propel library.
Symfony Propel Settings Plugin
|Krzysztof Pyrkosz||lead||lp.2o <<ta>> zsokryp|
Copyright (c) 2007 Brent Shaffer
Copyright (c) 2010 Krzysztof Pyrkosz
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Much like the
sfConfig::get() method, use
kpSettings::get() to call dynamic, user-defined settings.
An admin generator interface allows easy administration.
All settings are cached when first loaded, and the cache is refreshed whenever a setting is changed or added.
After the settings have been loaded, retrieve them with
(returns a string value) or
kpSettings::getSetting() (returns a kpSetting object)
To create a setting, you can add one in using a fixture, or using the DIY admin module interface (see below)
# in YAML fixture: kpSetting: test_setting: name: My Fake Setting type: yesno # optional: defaults to 'input' setting_default: 'yes' # optional, defaults to empty string widget_options: class=my-fake-setting # optional, more on this below
You can pull your setting into your project with the class method
get. This takes
either the name of your setting or the inflected name of your setting.
$value = kpSettings::get('My Fake Setting'); // The name of your setting $value = kpSettings::get('my_fake_setting'); // This will also work
You can also use kpSettings to call settings in your app.yml. By default, if the value passed
get method is null,
sfConfig is called:
$value = kpSettings::get('this_setting_does_not_exist'); // If a kpSetting does not exist with this name, this returns the same as: $value = kpConfig::get('app_this_setting_does_not_exist'); // This also works: $value = kpSettings::get('This Setting Does Not Exist');
Alternatively, the entire
kpSetting object can be returned by calling the class method
$setting = kpSettings::getSetting('my_fake_setting');
An admin module also exists for managing the settings in the database. you must enable the module in order to access it
# /apps/myapp/config/settings.yml all: .settings: enabled_modules: [default, kpSettings]
This module can be used to edit the variables as the plugin was originally built with the value for the setting being on the list page and editable from there, or it can behave like a normal admin-generated page. By default, you must be authenticated to edit the setting configurations themselves.
If you want to prevent validated users from editing the setting configurations, you can override the authMethod setting in your app.yml:
# /config/app.yml all: kpSettingsPlugin: authMethod: isSuperAdmin # or whatever method you want called on myUser.
Customize the cache handler for your settings using your app.yml. By default, sfNoCache is used.
[yaml] # /config/app.yml all: kpSettingsPlugin: cache: class: sfNoCache options: 
Please contact firstname.lastname@example.org for any questions or suggestions.