Переглянути джерело

Se agrego clase con devicetypes

Guillermo Espinoza 8 роки тому
батько
коміт
d3d8b2be63
2 змінених файлів з 49 додано та 0 видалено
  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';
+
+
+}