Zend_Controller-Plugins-PutHandler.xml 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect3 id="zend.controller.plugins.standard.puthandler">
  4. <title>Zend_Controller_Plugin_PutHandler</title>
  5. <para>
  6. <classname>Zend_Controller_Plugin_PutHandler</classname> provides a drop-in
  7. plugin for marshalling <constant>PUT</constant> request bodies into request parameters, just
  8. like <constant>POST</constant> request bodies. It will inspect the request and, if
  9. <constant>PUT</constant>, will use parse_str to parse the raw <constant>PUT</constant> body
  10. into an array of params which is then set on the request. E.g.,
  11. </para>
  12. <programlisting language="txt"><![CDATA[
  13. PUT /notes/5.xml HTTP/1.1
  14. title=Hello&body=World
  15. ]]></programlisting>
  16. <para>
  17. To receive the 'title' and 'body' params as regular request params,
  18. register the plugin:
  19. </para>
  20. <programlisting language="php"><![CDATA[
  21. $front = Zend_Controller_Front::getInstance();
  22. $front->registerPlugin(new Zend_Controller_Plugin_PutHandler());
  23. ]]></programlisting>
  24. <para>
  25. Then you can access the <constant>PUT</constant> body params by name from the request inside
  26. your controller:
  27. </para>
  28. <programlisting language="php"><![CDATA[
  29. ...
  30. public function putAction()
  31. {
  32. $title = $this->getRequest()->getParam('title'); // $title = "Hello"
  33. $body = $this->getRequest()->getParam('body'); // $body = "World"
  34. }
  35. ...
  36. ]]></programlisting>
  37. </sect3>