Giter Site home page Giter Site logo

settingsbundle's Introduction

FbeenSettingsBundle

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:

  1. Add "fbeen/settingsbundle": "dev-master" to the require section of your composer.json project file.
    "require": {
        ...
        "fbeen/settingsbundle": "dev-master"
    },
  1. run composer update:

    $ composer update

  2. Add the bundle to the app/AppKernel.php:

        $bundles = array(
            ...
            new Fbeen\SettingsBundle\FbeenSettingsBundle(),
        );
  1. add routes to app/config/routing.yml
fbeen_settings:
    resource: "@FbeenSettingsBundle/Resources/config/routing.yml"
    prefix:   /admin
  1. add routes to app/config/routing_dev.yml
_fbeen_settings:
    resource: "@FbeenSettingsBundle/Resources/config/routing_dev.yml"
    prefix:   /admin
  1. Enable Translation in app/config/config.yml
parameters:
    locale: en

framework:
    translator:      { fallbacks: ["%locale%"] }
  1. 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
  1. Update your database schema
$ bin/console doctrine:schema:update --force
  1. Login with an account that has ROLE_SUPER_ADMIN.

  2. 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

  3. 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);

settingsbundle's People

Contributors

fbeen avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.