Browse Source

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

Sevajol Bastien 11 years ago
parent
commit
4ac0ef5216
1 changed files with 11 additions and 8 deletions
  1. 11 8
      src/Muzich/CoreBundle/lib/Api/Response.php

+ 11 - 8
src/Muzich/CoreBundle/lib/Api/Response.php View File

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
             return false;
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