12345678910111213141516171819202122232425262728293031323334 |
- <?php
- namespace DeviceBundle\Utils;
- trait ChoiceTrait
- {
- /**
- * @return array
- */
- static function getConstants()
- {
- $oClass = new \ReflectionClass(__CLASS__);
- return $oClass->getConstants();
- }
- /**
- * Retorna un array con todas las constantes de la clase
- * para utilizar en campos de tipo choice en forms
- *
- * @return array
- */
- public static function getChoices()
- {
- $choices = array();
- foreach (self::getConstants() as $constant) {
- $choices[$constant] = $constant;
- }
- return $choices;
- }
- }
|