Skip to content

Instantly share code, notes, and snippets.

@DracoBlue
Created September 24, 2012 20:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DracoBlue/3778104 to your computer and use it in GitHub Desktop.
Save DracoBlue/3778104 to your computer and use it in GitHub Desktop.
Override the request method in agavi, in case of a POST form.
Index: agavi/src/request/AgaviWebRequest.class.php
===================================================================
--- agavi/src/request/AgaviWebRequest.class.php (revision 4918)
+++ agavi/src/request/AgaviWebRequest.class.php (working copy)
@@ -353,7 +353,16 @@
// map REQUEST_METHOD value to a method name, or fall back to the default in $sourceDefaults.
// if someone set a static value as default for a source that does not have a mapping, then he's really asking for it, and thus out of luck
$this->setMethod($this->getParameter(sprintf('method_names[%s]', $REQUEST_METHOD), $this->getParameter(sprintf('method_names[%s]', $sourceDefaults['REQUEST_METHOD']))));
-
+
+ if ($this->getMethod() === $methods['POST'] && isset($_REQUEST['_method']))
+ {
+ $force_method_name = strtoupper($_REQUEST['_method']);
+ if (in_array($force_method_name, array_keys($methods)))
+ {
+ $this->setMethod($this->getParameter(sprintf('method_names[%s]', $force_method_name)));
+ }
+ }
+
$this->protocol = self::getSourceValue($sources['SERVER_PROTOCOL'], $sourceDefaults['SERVER_PROTOCOL']);
// "on" (e.g. Apache or IIS) or "https" (e.g. Amazon EC2 Elastic Load Balancer) or "1" or integer 1 or true (e.g. statically set from a config file)
@@ -534,4 +543,4 @@
}
}
-?>
\ No newline at end of file
+?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment