summaryrefslogtreecommitdiffstats
path: root/zend-mvc-plugin-prg-8c7ccb9f0004e92ff258b483447d914f42cb7448/doc/book
diff options
context:
space:
mode:
Diffstat (limited to 'zend-mvc-plugin-prg-8c7ccb9f0004e92ff258b483447d914f42cb7448/doc/book')
-rw-r--r--zend-mvc-plugin-prg-8c7ccb9f0004e92ff258b483447d914f42cb7448/doc/book/index.html93
l---------zend-mvc-plugin-prg-8c7ccb9f0004e92ff258b483447d914f42cb7448/doc/book/index.md1
2 files changed, 94 insertions, 0 deletions
diff --git a/zend-mvc-plugin-prg-8c7ccb9f0004e92ff258b483447d914f42cb7448/doc/book/index.html b/zend-mvc-plugin-prg-8c7ccb9f0004e92ff258b483447d914f42cb7448/doc/book/index.html
new file mode 100644
index 0000000..64f69c9
--- /dev/null
+++ b/zend-mvc-plugin-prg-8c7ccb9f0004e92ff258b483447d914f42cb7448/doc/book/index.html
@@ -0,0 +1,93 @@
+<div class="container">
+ <div class="jumbotron">
+ <h1>zend-mvc-plugin-prg</h1>
+
+ <p>Post/Redirect/Get plugin for zend-mvc controllers.</p>
+
+ <pre><code class="language-bash">$ composer require zendframework/zend-mvc-plugin-prg</code></pre>
+ </div>
+</div>
+
+<div class="container">
+ <div class="row">
+ <div class="col-xs-12 col-sm-6">
+ <div class="panel panel-info">
+ <div class="panel-heading">
+ <h2 class="panel-title">Installation</h2>
+ </div>
+
+ <div class="panel-body">
+ <p>
+ Install via composer:
+ </p>
+
+ <pre><code class="lang-bash" data-trim>
+$ composer require zendframework/zend-mvc-plugin-prg
+ </code></pre>
+
+ <p>
+ If you are using the <a href="https://zendframework.github.io/zend-component-installer">zend-component-installer</a>,
+ you're done!
+ </p>
+
+ <p>
+ If not, you will need to add the component as a module to your
+ application. Add the entry <code>'Zend\Mvc\Plugin\Prg'</code> to
+ your list of modules in your application configuration (typically
+ one of <code>config/application.config.php</code> or
+ <code>config/modules.config.php</code>).
+ </p>
+ </div>
+ </div>
+ </div>
+
+ <div class="col-xs-12 col-sm-6">
+ <h2>Usage</h2>
+
+ <p>
+ When a user sends a POST request (e.g. after submitting a form), their
+ browser will try to protect them from sending the POST again, breaking
+ the back button, causing browser warnings and pop-ups, and sometimes
+ reposting the form. Instead, when receiving a POST, we should store the
+ data in a session container and redirect the user to a GET request.
+ </p>
+
+ <p>This plugin can be invoked with two arguments:</p>
+
+ <ul>
+ <li><code>$redirect</code>, a string containing the redirect location,
+ which can either be a named route or a URL, based on the contents of
+ the second parameter.</li>
+ <li><code>$redirectToUrl</code>, a boolean that when set to
+ <code>TRUE</code>, causes the first parameter to be treated as a URL
+ instead of a route name (this is required when redirecting to a URL
+ instead of a route). This argument defaults to <code>FALSE</code>.</li>
+ </ul>
+
+ <p>When no arguments are provided, the current matched route is used.</p>
+
+ <h3>Example Usage</h3>
+
+ <pre><code class="lang-php" data-trim>
+// Pass in the route/url you want to redirect to after the POST
+$prg = $this->prg('/user/register', true);
+
+if ($prg instanceof \Zend\Http\PhpEnvironment\Response) {
+ // Returned a response to redirect us.
+ return $prg;
+}
+
+if ($prg === false) {
+ // This wasn't a POST request, but there were no params in the flash
+ // messenger; this is probably the first time the form was loaded.
+ return ['form' => $myForm];
+}
+
+// $prg is an array containing the POST params from the previous request
+$form->setData($prg);
+
+// ... your form processing code here
+ </code></pre>
+ </div>
+ </div>
+</div>
diff --git a/zend-mvc-plugin-prg-8c7ccb9f0004e92ff258b483447d914f42cb7448/doc/book/index.md b/zend-mvc-plugin-prg-8c7ccb9f0004e92ff258b483447d914f42cb7448/doc/book/index.md
new file mode 120000
index 0000000..fe84005
--- /dev/null
+++ b/zend-mvc-plugin-prg-8c7ccb9f0004e92ff258b483447d914f42cb7448/doc/book/index.md
@@ -0,0 +1 @@
+../../README.md \ No newline at end of file