2017 © Pedro Peláez
 

symfony-bundle settings-bundle

Just a Symfony settings bundle.

image

phpmob/settings-bundle

Just a Symfony settings bundle.

  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 18 % Grown

The README.md

PhpMob Settings

Scrutinizer Code Quality Code Coverage Build Status Latest Stable Version Latest Unstable Version, (*1)

Just a Settings Library., (*2)

Installation

Install via composer., (*3)

$ composer require phpmob/settings-bundle

Using with cache, (*4)

$ composer require cache/filesystem-adapter

Now you can use built-in \PhpMob\Settings\Manager\CachedManager., (*5)

Alternative using built-int symfony framework cache see - framework/cache, (*6)

Sample config


# use with doctrine orm doctrine: orm: mappings: PhpMobSettings: type: xml is_bundle: false prefix: PhpMob\Settings\Model dir: '%kernel.project_dir%/vendor/phpmob/settings-bundle/src/Resources/config/doctrine/model' phpmob_settings: cache: service: cache.flysystem schemas: section1: label: Section1 settings: key1: ~ section2: label: Section2 settings: key1: value: key1Value key2: label: SectionKey2 value: key2value blueprint: options: label: SectionKey2Label constraints: NotBlank: ~ gender: label: Gender value: f blueprint: type: Symfony\Component\Form\Extension\Core\Type\ChoiceType options: required: true choices: Man: m Feman: f birthday: type: date label: Birthday value: "1988-02-10" blueprint: type: Symfony\Component\Form\Extension\Core\Type\BirthdayType datetime: type: datetime label: DateTime value: ~ blueprint: type: Symfony\Component\Form\Extension\Core\Type\DateTimeType

Ownered settings

Configuration for owner (user) aware settings. Controller used PhpMobSettingsBundle:Update:userUpdate., (*7)

phpmob_settings:
    schemas:
        section1:
            owner_aware: true
            label: Section1
            settings:
                key1: ~

Updater Routing

See example routing in src/Resources/config/routing.xml or you can customize with:, (*8)

your_route_name:
    path: /settings/{section}
    defaults:
        _controller: PhpMobSettingsBundle:Update:globalUpdate
        _template: @yourtemplate # default @PhpMobSetting/default.html.twig
        _flash: ~ # flash message after update
        _redirect: ~ # redirect after update

Custom form type to display description setting in form view.

<?php

namespace YourBundle\Form\Type;

use PhpMob\SettingsBundle\Form\Type\AbstractBlueprintType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;

class YourSettingType extends AbstractBlueprintType
{
    /**
     * {@inheritdoc}
     */
    public function getParentType(): string
    {
        return CheckboxType::class;
    }
}

And in setting configuration., (*9)

phpmob_settings:
    schemas:
        section1:
            owner_aware: true
            label: Section1
            settings:
                key1:
                    type: boolean
                    label: 'Key 1'
                    value: true
                    blueprint:
                        type: YourBundle\Form\Type\YourSettingType

using in twig

Getter setting, (*10)

{{ settings_get('section.key') }}

{# owner aware setting #}
{{ settings_get('section.key', app.user) }}

Setter setting, (*11)

{{ settings_set('section.key', 'value') }}

{# owner aware setting #}
{{ settings_set('section.key', 'value', app.user) }}

Sample Admin Screen

screen, (*12)

Contributing

Would like to help us and build the developer-friendly php code? Just follow our Coding Standards and test your code — see tests, spec., (*13)

Let Fork and PR now!, (*14)

Coding Standards

When contributing code to PhpMob, you must follow its coding standards., (*15)

PhpMob follows the standards defined in the PSR-0, PSR-1 and PSR-2 documents., (*16)

$ ./bin/ecs check src --fix

Tests

$ ./bin/phpunit

LICENSE

MIT, (*17)

The Versions