2017 © Pedro Peláez
 

symfony-bundle option-bundle

A bundle to manage options

image

creavo/option-bundle

A bundle to manage options

  • Thursday, May 3, 2018
  • by cklm
  • Repository
  • 1 Watchers
  • 0 Stars
  • 30 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 3 % Grown

The README.md

CREAVO Option-Bundle

SensioLabsInsight Packagist, (*1)

Installation

please use composer with, (*2)

composer require creavo/option-bundle

Add the bundle to your app/AppKernel.php with, (*3)

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            [...],
            new Creavo\OptionBundle\CreavoOptionBundle(),
        ];

        return $bundles;
    }

    [...]
}

Update the doctrine-schema - use, (*4)

php bin/console doctrine:schema:update

or do a migration:, (*5)

php bin/console doctrine:migration:diff
php bin/console doctrine:migration:migrate

Configuration

add the following lines to your app/config/config.yml:, (*6)

creavo_option:
    fetch_all: false
    simple_cache_service: null
  • fetch_all: true/false - when true, all settings are fetched from the database on initializing the bundle - depending on your use-case it might be more efficient to fetch all settings in a single query instead of fetching them later, when used (which leads to more queries)
  • simple_cache_service: inject a simple-cache here (something that implements Psr\SimpleCache\CacheInterface) - when null an ArrayCache for the request is used

Usage

as service

set a setting, (*7)

$container->get('crv.option')->set('option-name', $optionValue, $optionType, $section);

get a setting (cached):, (*8)

$optionValue=$container->get('crv.option')->get('option-name');

get a setting (uncached - will fetch value freshly from database without the cache), (*9)

$optionValue=$container->get('crv.option')->getUnCached('option-name'); 

in twig

to get a value in twig use, (*10)

{{ crv_ob_setting('option-name') }}

use console-commands

set a setting with php bin/console crv:ob:set name value [type] [section] type and section are optional - if you omit them, the type will be a string and section null., (*11)

$ php bin/console crv:ob:set test1 "2017-09-16 12:00:00" dateTime parameters

setting the hash of the last-commit, (*12)

php bin/console crv:ob:set app_version `git rev-parse --short HEAD`

to get a setting use get:, (*13)

$ php bin/console crv:ob:get test1
+-----------+---------------------+
| Element   | Value               |
+-----------+---------------------+
| name      | test1               |
| type      | dateTime            |
| section   | parameters          |
| updatedAt | 2017-09-16 12:30:17 |
| value     | 2017-09-16 12:00:00 |
+-----------+---------------------+

The Versions

03/05 2018

dev-master

9999999-dev

A bundle to manage options

  Sources   Download

MIT

The Requires

 

by Christoph Keßeler

tasks notify symfony bundle

03/05 2018

0.3.5

0.3.5.0

A bundle to manage options

  Sources   Download

MIT

The Requires

 

by Christoph Keßeler

tasks notify symfony bundle

03/05 2018

0.3.4

0.3.4.0

A bundle to manage options

  Sources   Download

MIT

The Requires

 

by Christoph Keßeler

tasks notify symfony bundle

03/05 2018

0.3.3

0.3.3.0

A bundle to manage options

  Sources   Download

MIT

The Requires

 

by Christoph Keßeler

tasks notify symfony bundle

03/05 2018

0.3.2

0.3.2.0

A bundle to manage options

  Sources   Download

MIT

The Requires

 

by Christoph Keßeler

tasks notify symfony bundle

19/09 2017

0.3.1

0.3.1.0

A bundle to manage options

  Sources   Download

MIT

The Requires

 

by Christoph Keßeler

tasks notify symfony bundle

18/09 2017

0.3

0.3.0.0

A bundle to manage options

  Sources   Download

MIT

The Requires

 

by Christoph Keßeler

tasks notify symfony bundle

17/09 2017

0.2

0.2.0.0

A bundle to manage options

  Sources   Download

MIT

The Requires

 

by Christoph Keßeler

tasks notify symfony bundle

17/09 2017

0.1

0.1.0.0

A bundle to manage options

  Sources   Download

MIT

The Requires

 

by Christoph Keßeler

tasks notify symfony bundle