dhorchler / config-bundle
Database-stored settings that are administrable in Sonata Admin Bundle.
Installs: 70
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 2
Open Issues: 2
Type:symfony-bundle
Requires
- php: >=5.3.3
- sonata-project/admin-bundle: 2.3.*@dev
- symfony/symfony: 2.*
This package is not auto-updated.
Last update: 2022-02-01 12:24:07 UTC
README
#Information
Compatible with Symfony 2.5 (under construction)
DHorchlerConfigBundle stores configuration settings in an ORM database and makes them administrable in Sonata Admin Bundle. These settings can be used anywhere in your project and can be modified at runtime by a Sonata admin user.
#Features:
- individual validations for different data types
- individual constrains with easily customizable error texts
- jQuery supported form field default values
###Currently supported data types: string, integer, float, date, datetime, choice, multiplechoice.
#Installation
##Get the bundle
Let Composer download and install the bundle by first adding it to your composer.json
{ "require": { "dhorchler/config-bundle": "dev-master" } }
and then running
php composer.phar update dhorchler/config-bundle
##Enable the bundle in app/AppKernel.php
public function registerBundles() { $bundles = array( // ... new DHorchler\ConfigBundle\DHorchlerConfigBundle(), ); // ... }
##Create the settings table
You can do this by calling
php app/console doctrine:migrations:diff php app/console doctrine:migrations:migrate
or
php app/console doctrine:schema:update
or how ever you like.
#Configuration
In your app/config/config.yml add
sonata_block: default_contexts: [cms] blocks: sonata.admin.block.admin_list: contexts: [admin] sonata.block.service.text: sonata.block.service.rss: sonata_admin: title: Sonata Project title_logo: /bundles/sonataadmin/logo_title.png templates: layout: SonataAdminBundle::standard_layout.html.twig ajax: SonataAdminBundle::ajax_layout.html.twig list: SonataAdminBundle:CRUD:list.html.twig show: SonataAdminBundle:CRUD:show.html.twig edit: DHorchlerConfigBundle::edit.html.twig dashboard: blocks: - { position: left, type: sonata.admin.block.admin_list } services: sonata.dh.admin.settings: class: DHorchler\ConfigBundle\Admin\ConfigAdmin tags: - { name: sonata.admin, manager_type: orm, group: 'settings', label: Settings } arguments: - null - DHorchler\ConfigBundle\Entity\Settings - DHorchlerConfigBundle:Admin
After all this start managing your settings from the Sonata Admin backend.
#Usage example:
$this->em = $this->getDoctrine()->getEntityManager(); $settingsRaw = $this->em->createQueryBuilder() ->select('s.name, s.currentValue') ->from('DHorchlerConfigBundle:Settings', 's') ->getQuery() ->getResult(); foreach ($settingsRaw AS $setting) $settings[$setting['name']] = $setting['currentValue']
#Preview:
#Todo:
- add more tests
- client side validation