Procházet zdrojové kódy

Meilleure gestion de réponse vide de la part des apis

Sevajol Bastien před 11 roky
rodič
revize
4ac0ef5216
1 změnil soubory, kde provedl 11 přidání a 8 odebrání
  1. 11 8
      src/Muzich/CoreBundle/lib/Api/Response.php

+ 11 - 8
src/Muzich/CoreBundle/lib/Api/Response.php Zobrazit soubor

@@ -30,20 +30,23 @@ class Response
30 30
       }
31 31
     }
32 32
     
33
-    if (array_key_exists($searched, $content))
33
+    if ($content)
34 34
     {
35
-      if ($not_empty)
35
+      if (array_key_exists($searched, $content))
36 36
       {
37
-        if ((is_null($content[$searched]) || !count($content[$searched]) || !$content[$searched]) && ($content[$searched] !== 0 && $content[$searched] !== '0'))
37
+        if ($not_empty)
38 38
         {
39
-          return false;
40
-        }
41
-        if (is_string($content[$searched]))
42
-        {
43
-          if (trim($content[$searched]) == '')
39
+          if ((is_null($content[$searched]) || !count($content[$searched]) || !$content[$searched]) && ($content[$searched] !== 0 && $content[$searched] !== '0'))
44 40
           {
45 41
             return false;
46 42
           }
43
+          if (is_string($content[$searched]))
44
+          {
45
+            if (trim($content[$searched]) == '')
46
+            {
47
+              return false;
48
+            }
49
+          }
47 50
         }
48 51
       }
49 52