Add 'set' and 'bootstrap' methods to Env/Get/Post
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Tue, 25 Jan 2011 15:50:22 +0000 (16:50 +0100)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Tue, 25 Jan 2011 15:50:22 +0000 (16:50 +0100)
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
classes/env.php

index 57fe0d9..abfea48 100644 (file)
@@ -75,6 +75,18 @@ class Env
     {
         return array_map(array('Env', 'v'), $keys);
     }
+
+    public static function set($key, $value)
+    {
+        $_REQUEST[$key] =& $value;
+    }
+
+    public static function bootstrap($key, $value)
+    {
+        if (!Env::has($key)) {
+            Env::set($key, $value);
+        }
+    }
 }
 
 class Post
@@ -133,6 +145,18 @@ class Post
     {
         return array_map(array('Post', 'v'), $keys);
     }
+
+    public static function set($key, $value)
+    {
+        $_POST[$key] =& $value;
+    }
+
+    public static function bootstrap($key, $value)
+    {
+        if (!Post::has($key)) {
+            Post::set($key, $value);
+        }
+    }
 }
 
 class Get
@@ -191,6 +215,18 @@ class Get
     {
         return array_map(array('Get', 'v'), $keys);
     }
+
+    public static function set($key, $value)
+    {
+        $_GET[$key] =& $value;
+    }
+
+    public static function bootstrap($key, $value)
+    {
+        if (!Get::has($key)) {
+            Get::set($key, $value);
+        }
+    }
 }
 
 class Cookie