2017 © Pedro Peláez
 

library enum-bundle

Integrates greg0ire/enum in a Symfony2 project

image

greg0ire/enum-bundle

Integrates greg0ire/enum in a Symfony2 project

  • Friday, April 29, 2016
  • by greg0ire
  • Repository
  • 2 Watchers
  • 6 Stars
  • 8,085 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

This package is abandoned in favor of [greg0ire/enum][1], (*1)

EnumBundle

Integrates [greg0ire/enum][1] in a Symfony2 project. This actually not a real bundle yet but :, (*2)

  • it has a dependency on symfony/form
  • it could become a real bundle someday, if something needs to be configured

![Build Status][2], (*3)

Installation

composer require greg0ire/enum-bundle

Usage

The bundle provides its own BaseEnum class. It inherits from greg0ire/enum's BaseEnum class and provides an additional method, getChoices(), which is meant to be used as value for the choices option of a choice widget. It has a mandatory parameter, which is a sprintf format string and let's you choose how to generate your labels., (*4)

<?php
use Greg0ire\EnumBundle\BaseEnum;

final class ColorType extends BaseEnum
{
    const
        BLACK_WHITE = 'black-white',
        COLOR       = 'color',
        COLORIZED   = 'colorized' ;
}

A few moments later, in another file…, (*5)

<?php

class MyType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add(
            'aspect_ratio',
            'choice',
            array('choices' => ColorType::getChoices('color_type_%s'))
        );
    }
}

You then need to create translations for :, (*6)

  • color_type_black-white
  • color_type_color
  • color_type_colorized

The first argument to getChoices() is optional, and the value will be used directly as a label should you choose not to specify it. This makes sense if you decide to have a translation catalogue just for your enumeration. The second argument, choicesAsValues only takes effect if your symfony version is < 3.0 and >= 2.7. It defaults to false for the moment, so that B.C. is kept. If you use symfony >= 2.8 and < 3.0, you will get a deprecation notice unless you set it to true and set choices_as_values option to true., (*7)

The Versions

29/04 2016

dev-master

9999999-dev

Integrates greg0ire/enum in a Symfony2 project

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

by Grégoire Paris

enum enumeration

25/04 2016

v3.0.0

3.0.0.0

Integrates greg0ire/enum in a Symfony2 project

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

by Grégoire Paris

enum enumeration

07/02 2016

v2.1.0

2.1.0.0

Integrates greg0ire/enum in a Symfony2 project

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

by Grégoire Paris

enum enumeration

08/06 2015

dev-flug-configuration-bundle

dev-flug-configuration-bundle

Integrates greg0ire/enum in a Symfony2 project

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

by Grégoire Paris

enum enumeration

03/06 2015

v2.0.0

2.0.0.0

Integrates greg0ire/enum in a Symfony2 project

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

by Grégoire Paris

enum enumeration

03/06 2015

v1.2.2

1.2.2.0

Integrates greg0ire/enum in a Symfony2 project

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

by Grégoire Paris

enum enumeration

31/10 2014

v1.2.1

1.2.1.0

Integrates greg0ire/enum in a Symfony2 project

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

by Grégoire Paris

enum enumeration

31/10 2014

v1.1.0

1.1.0.0

Integrates greg0ire/enum in a Symfony2 project

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

by Grégoire Paris

enum enumeration

31/10 2014

v1.2.0

1.2.0.0

Integrates greg0ire/enum in a Symfony2 project

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

by Grégoire Paris

enum enumeration

25/07 2014

1.0.0

1.0.0.0

Integrates greg0ire/enum in a Symfony2 project

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

by Grégoire Paris