Bladeren bron

added headers in injection

develop
Robin Thoni 8 jaren geleden
bovenliggende
commit
3c50e51b00
1 gewijzigde bestanden met toevoegingen van 24 en 0 verwijderingen
  1. 24
    0
      src/Utils/Controller/LuRoute.php

+ 24
- 0
src/Utils/Controller/LuRoute.php Bestand weergeven

@@ -77,8 +77,30 @@ class LuRoute {
77 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 100
     public function execute(LuRouteDbo $route, $parameters)
81 101
     {
102
+        $parameters["_headers"] = static::getHeaders();
103
+
82 104
         $middlewares = [];
83 105
         /**
84 106
          * @var $middlewareDbo LuMiddlewareDbo
@@ -92,6 +114,7 @@ class LuRoute {
92 114
 
93 115
             $args = array_merge($middlewareDbo->getParameters(), $route->getParameters());
94 116
             $args["_route"] = $route;
117
+            $args["_headers"] = $parameters["_headers"];
95 118
             $args["_parameters"] = $parameters;
96 119
             $args["_all"] = $args;
97 120
 
@@ -113,6 +136,7 @@ class LuRoute {
113 136
 
114 137
             $args = array_merge($middlewareDbo->getParameters(), $route->getParameters());
115 138
             $args["_route"] = $route;
139
+            $args["_headers"] = $parameters["_headers"];
116 140
             $args["_parameters"] = $parameters;
117 141
             $args["_result"] = $result;
118 142
             $args["_all"] = $args;

Laden…
Annuleren
Opslaan