fbeen / settingsbundle
This Bundle adds settings out of the database integration on top of the Symfony framework. It lets you design application-settings which can be maintained by the owner or administrator from the website.
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^5.5.9|^7.0
- symfony/framework-bundle: ^2.7|^3.3
This package is not auto-updated.
Last update: 2024-11-04 07:10:02 UTC
README
This Bundle adds global settings out of the database integration on top of the Symfony framework. It lets you design application-settings which can be maintained by the owner or administrator from the website.
Features include:
- Unlimmited setting fields
- Bootstrap ready pages and forms
- Settings can be made and deleted by you developer when you add yourself the ROLE_SUPER_ADMIN in a form
- The value of the setting fields can be changed by the users that have ROLE_ADMINISTRATOR in a form
- The value of the setting fields can be changed by the application
- Five formtypes: text, email, boolean, integer and decimal.
- Form validation dependend on the formtype.
Installation
Using composer:
- Add
"fbeen/settingsbundle": "dev-master"
to the require section of your composer.json project file.
"require": {
...
"fbeen/settingsbundle": "dev-master"
},
-
run composer update:
$ composer update
-
Add the bundle to the app/AppKernel.php:
$bundles = array(
...
new Fbeen\SettingsBundle\FbeenSettingsBundle(),
);
- add routes to app/config/routing.yml
fbeen_settings:
resource: "@FbeenSettingsBundle/Resources/config/routing.yml"
prefix: /admin
- add routes to app/config/routing_dev.yml
_fbeen_settings:
resource: "@FbeenSettingsBundle/Resources/config/routing_dev.yml"
prefix: /admin
- Enable Translation in
app/config/config.yml
parameters:
locale: en
framework:
translator: { fallbacks: ["%locale%"] }
- Configure
app/config/security.yml
so that ROLE_ADMIN and ROLE_SUPER_ADMIN do exist:
security:
# ...
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
- Update your database schema
$ bin/console doctrine:schema:update --force
-
Login with an account that has ROLE_SUPER_ADMIN.
-
Go to the route .../app_dev.php/admin/settings/developer and start to add settings. The form is very easy to use and does not require further explanations
-
Go to the route .../app_dev.php/admin/settings/edit and see how administrators can change values
Usage
Imagine that you made a setting with the identifier shipping_price and that you want to use the setting in your controller:
$value = $this->get('fbeen_settings.settings_helper')->getSetting('shipping_price');
Or that you want to render the setting in Twig:
{{ setting('shipping_price') }}
Update a setting:
$this->get('fbeen_settings.settings_helper')->updateSetting('shipping_price', $price);
Or maybe you want to use a setting as a page-view counter:
$helper = $this->get('fbeen_settings.settings_helper');
$counter = $helper->getSetting('page_views');
$helper->updateSetting('page_views', ++$counter);