foreverglory / setting-bundle
Symfony SettingBundle
Installs: 36
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- symfony/symfony: ~2.3
This package is not auto-updated.
Last update: 2024-11-04 07:43:48 UTC
README
Symfony SettingBundle
Introduction
Composer
Add to composer.json
in your project to require
section:
{ "foreverglory/setting-bundle": "~0.1" }
Add this bundle to your application's kernel
//app/AppKernel.php public function registerBundles() { return array( // ... new Glory\Bundle\SettingBundle\GlorySettingBundle(), // ... ); }
Configure service in your YAML configuration
#app/config/config.yml glory_setting: driver:~ #default %database_driver% manager:~ #service id, default if driver is 'pdo_mysql', manager is @doctrine.orm.default_entity_manager model:~ #model class,default if driver is 'pdo_mysql', model is Glory\Bundle\SettingBundle\Entity\Setting
php code
$settingManager = $container->get('glory_setting.manager'); $settingManager->value('name'); $settingManager->value('name','default-value'); $settingManager->value('name.key'); $settingManager->value('name.key','default-value'); $settingManager->save('name','value'); $settingManager->save('name',array('key'=>'value'));
twig code
{# string #} {{setting('name')}} {{setting('name','default-value')}} {# array #} {{setting('name.key')}} {{setting('name.key','default-value')}} {% set value=setting('name') %} {{value.key}} {# Warning #} {# if setting('name') is array use {{setting('name')}} will throw Exception("Notice: Array to string conversion") #}