2017 © Pedro Peláez
 

symfony-bundle config-bundle

Database-stored settings that are administrable in Sonata Admin Bundle.

image

dhorchler/config-bundle

Database-stored settings that are administrable in Sonata Admin Bundle.

  • Saturday, November 22, 2014
  • by DHorchler
  • Repository
  • 2 Watchers
  • 1 Stars
  • 61 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 2 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Information

Compatible with Symfony 2.5 (under construction), (*1)

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., (*2)

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., (*3)

Installation

Get the bundle

Let Composer download and install the bundle by first adding it to your composer.json, (*4)


{
    "require": {
        "dhorchler/config-bundle": "dev-master"
    }
}

and then running, (*5)

php composer.phar update dhorchler/config-bundle

Enable the bundle

in app/AppKernel.php, (*6)

public function registerBundles() {
    $bundles = array(
        // ...
        new DHorchler\ConfigBundle\DHorchlerConfigBundle(),
    );
    // ...
}

Create the settings table

You can do this by calling, (*7)

php app/console doctrine:migrations:diff
php app/console doctrine:migrations:migrate

or, (*8)

php app/console doctrine:schema:update

or how ever you like., (*9)

Configuration

In your app/config/config.yml add, (*10)

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., (*11)

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:

Screen shot list settings, (*12)

Screen shot edit integer settings, (*13)

Screen shot edit date settings, (*14)

Todo:

  • add more tests
  • client side validation

The Versions

22/11 2014

dev-master

9999999-dev https://github.com/Dhorchler/DhorchlerConfigBundle

Database-stored settings that are administrable in Sonata Admin Bundle.

  Sources   Download

MIT

The Requires

 

by Detlef Horchler

settings config symfony2 sonata admin

21/11 2014

2.1.x-dev

2.1.9999999.9999999-dev https://github.com/Dhorchler/DhorchlerConfigBundle

Database-stored settings that are administrable in Sonata Admin Bundle.

  Sources   Download

MIT

The Requires

 

by Detlef Horchler

settings config symfony2 sonata admin