Browse Source

added headers in injection

develop
Robin Thoni 8 years ago
parent
commit
3c50e51b00
1 changed files with 24 additions and 0 deletions
  1. 24
    0
      src/Utils/Controller/LuRoute.php

+ 24
- 0
src/Utils/Controller/LuRoute.php View File

77
         $this->_dispatcher = new DispatcherGroupCountBased($routeCollector->getData());
77
         $this->_dispatcher = new DispatcherGroupCountBased($routeCollector->getData());
78
     }
78
     }
79
 
79
 
80
+    public static function getHeaders()
81
+    {
82
+        if (!function_exists('getallheaders')) {
83
+            $out = [];
84
+            foreach ($_SERVER as $key => $value) {
85
+                if (substr($key, 0, 5) == "HTTP_") {
86
+                    $key = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($key, 5)))));
87
+                    $out[$key] = $value;
88
+                }
89
+                else {
90
+                    $out[$key] = $value;
91
+                }
92
+            }
93
+            return $out;
94
+        }
95
+        else {
96
+            return getallheaders();
97
+        }
98
+    }
99
+
80
     public function execute(LuRouteDbo $route, $parameters)
100
     public function execute(LuRouteDbo $route, $parameters)
81
     {
101
     {
102
+        $parameters["_headers"] = static::getHeaders();
103
+
82
         $middlewares = [];
104
         $middlewares = [];
83
         /**
105
         /**
84
          * @var $middlewareDbo LuMiddlewareDbo
106
          * @var $middlewareDbo LuMiddlewareDbo
92
 
114
 
93
             $args = array_merge($middlewareDbo->getParameters(), $route->getParameters());
115
             $args = array_merge($middlewareDbo->getParameters(), $route->getParameters());
94
             $args["_route"] = $route;
116
             $args["_route"] = $route;
117
+            $args["_headers"] = $parameters["_headers"];
95
             $args["_parameters"] = $parameters;
118
             $args["_parameters"] = $parameters;
96
             $args["_all"] = $args;
119
             $args["_all"] = $args;
97
 
120
 
113
 
136
 
114
             $args = array_merge($middlewareDbo->getParameters(), $route->getParameters());
137
             $args = array_merge($middlewareDbo->getParameters(), $route->getParameters());
115
             $args["_route"] = $route;
138
             $args["_route"] = $route;
139
+            $args["_headers"] = $parameters["_headers"];
116
             $args["_parameters"] = $parameters;
140
             $args["_parameters"] = $parameters;
117
             $args["_result"] = $result;
141
             $args["_result"] = $result;
118
             $args["_all"] = $args;
142
             $args["_all"] = $args;

Loading…
Cancel
Save