Explorar el Código

Se agrego clase con devicetypes

Guillermo Espinoza hace 8 años
padre
commit
d3d8b2be63
Se han modificado 2 ficheros con 49 adiciones y 0 borrados
  1. 34 0
      Utils/ChoiceTrait.php
  2. 15 0
      Utils/DeviceTypes.php

+ 34 - 0
Utils/ChoiceTrait.php

@@ -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;
+    }
+
+}

+ 15 - 0
Utils/DeviceTypes.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace DeviceBundle\Utils;
+
+class DeviceTypes
+{
+
+    use ChoiceTrait;
+
+    const FTTH_OLT = 'FTTHBundle\Entity\OLT';
+
+    const FTTH_ONU = 'FTTHBundle\Entity\ONU';
+
+
+}