|
@@ -0,0 +1,34 @@
|
|
|
+<?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;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|