From c4a7368d043f26ad1ca510b13c112fa2ccdba74f Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 29 Jun 2016 13:07:06 +0200 Subject: php-zendframework-zend-mvc-plugin-prg: 1.0.0 (New Package) --- .../doc/book/index.html | 93 ++++++++++++++++++++++ .../doc/book/index.md | 1 + 2 files changed, 94 insertions(+) create mode 100644 zend-mvc-plugin-prg-8c7ccb9f0004e92ff258b483447d914f42cb7448/doc/book/index.html create mode 120000 zend-mvc-plugin-prg-8c7ccb9f0004e92ff258b483447d914f42cb7448/doc/book/index.md (limited to 'zend-mvc-plugin-prg-8c7ccb9f0004e92ff258b483447d914f42cb7448/doc/book') 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 @@ +
+
+

zend-mvc-plugin-prg

+ +

Post/Redirect/Get plugin for zend-mvc controllers.

+ +
$ composer require zendframework/zend-mvc-plugin-prg
+
+
+ +
+
+
+
+
+

Installation

+
+ +
+

+ Install via composer: +

+ +

+$ composer require zendframework/zend-mvc-plugin-prg
+          
+ +

+ If you are using the zend-component-installer, + you're done! +

+ +

+ If not, you will need to add the component as a module to your + application. Add the entry 'Zend\Mvc\Plugin\Prg' to + your list of modules in your application configuration (typically + one of config/application.config.php or + config/modules.config.php). +

+
+
+
+ +
+

Usage

+ +

+ 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. +

+ +

This plugin can be invoked with two arguments:

+ +
    +
  • $redirect, a string containing the redirect location, + which can either be a named route or a URL, based on the contents of + the second parameter.
  • +
  • $redirectToUrl, a boolean that when set to + TRUE, 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 FALSE.
  • +
+ +

When no arguments are provided, the current matched route is used.

+ +

Example Usage

+ +

+// 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
+      
+
+
+
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 -- cgit