File: Zend_Controller-Plugins-PutHandler.xml

package info (click to toggle)
zendframework 1.12.9%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 133,584 kB
  • sloc: xml: 1,311,829; php: 570,173; sh: 170; makefile: 125; sql: 121
file content (44 lines) | stat: -rw-r--r-- 1,477 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect3 id="zend.controller.plugins.standard.puthandler">
    <title>Zend_Controller_Plugin_PutHandler</title>

    <para>
        <classname>Zend_Controller_Plugin_PutHandler</classname> provides a drop-in
        plugin for marshalling <constant>PUT</constant> request bodies into request parameters, just
        like <constant>POST</constant> request bodies. It will inspect the request and, if
        <constant>PUT</constant>, will use parse_str to parse the raw <constant>PUT</constant> body
        into an array of params which is then set on the request. E.g.,
    </para>

    <programlisting language="txt"><![CDATA[
PUT /notes/5.xml HTTP/1.1

title=Hello&body=World
]]></programlisting>

    <para>
        To receive the 'title' and 'body' params as regular request params,
        register the plugin:
    </para>

    <programlisting language="php"><![CDATA[
$front = Zend_Controller_Front::getInstance();
$front->registerPlugin(new Zend_Controller_Plugin_PutHandler());
]]></programlisting>

    <para>
        Then you can access the <constant>PUT</constant> body params by name from the request inside
        your controller:
    </para>

    <programlisting language="php"><![CDATA[
...
public function putAction()
{
    $title = $this->getRequest()->getParam('title'); // $title = "Hello"
    $body = $this->getRequest()->getParam('body'); // $body = "World"
}
...
]]></programlisting>
</sect3>