diff --git a/CHANGELOG.md b/CHANGELOG.md index 426f70c..c46f581 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,28 @@ All notable changes to this project will be documented in this file, in reverse chronological order by release. +## 1.1.1 - TBD + +### Added + +- Nothing. + +### Changed + +- Nothing. + +### Deprecated + +- Nothing. + +### Removed + +- Nothing. + +### Fixed + +- Nothing. + ## 1.1.0 - 2018-04-30 ### Added diff --git a/README.md b/README.md index 9f7d41d..bec0b44 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # zend-mvc-plugin-fileprg +> ## Repository abandoned 2019-12-31 +> +> This repository has moved to [laminas/laminas-mvc-plugin-fileprg](https://github.com/laminas/laminas-mvc-plugin-fileprg). + [](https://secure.travis-ci.org/zendframework/zend-mvc-plugin-fileprg) [](https://coveralls.io/github/zendframework/zend-mvc-plugin-fileprg?branch=master) @@ -10,5 +14,28 @@ versions 3.0 and up, specifically for submissions that include file uploads. If you want a generic PRG plugin without file upload support, see [zend-mvc-plugin-prg](https://docs.zendframework.com/zend-mvc-plugin-prg). -- File issues at https://github.com/zendframework/zend-mvc-plugin-fileprg/issues -- Documentation is at https://docs.zendframework.com/zend-mvc-plugin-fileprg/ +## Installation + +Run the following to install this library: + +```bash +$ composer require zendframework/zend-mvc-plugin-fileprg +``` + +If you are using the [zend-component-installer](https://docs.zendframework.com/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\FilePrg'` to +your list of modules in your application configuration (typically +one of `config/application.config.php` or `config/modules.config.php`). + +## Documentation + +Browse the documentation online at https://docs.zendframework.com/zend-mvc-plugin-fileprg/ + +## Support + +* [Issues](https://github.com/zendframework/zend-mvc-plugin-fileprg/issues/) +* [Chat](https://zendframework-slack.herokuapp.com/) +* [Forum](https://discourse.zendframework.com/) diff --git a/docs/book/index.html b/docs/book/index.html deleted file mode 100644 index dcaa05f..0000000 --- a/docs/book/index.html +++ /dev/null @@ -1,139 +0,0 @@ -
Post/Redirect/Get plugin with file upload handling for zend-mvc controllers.
- -$ composer require zendframework/zend-mvc-plugin-fileprg
- - Install via composer: -
- -
-$ composer require zendframework/zend-mvc-plugin-fileprg
-
-
- - 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\FilePrg'
to
- your list of modules in your application configuration (typically
- one of config/application.config.php
or
- config/modules.config.php
).
-
- While similar to the Post/Redirect/Get - Plugin, the File PRG Plugin will work for forms with file inputs. - The difference is in the behavior: The File PRG Plugin will interact - directly with your form instance and the file inputs, rather than - only returning the POST params from the previous request. -
- -
- By interacting directly with the form, the File PRG Plugin will turn off any
- file inputs required
flags for already uploaded files (for a partially valid
- form state), as well as run the file input filters to move the uploaded files
- into a new location (configured by the user).
-
-- -Files must be relocated on upload
- -- You must attach a filter for moving the uploaded files to a new location, such as the - RenameUpload Filter, - or else your files will be removed upon the redirect. -
-
- This plugin is invoked with three arguments: -
- -$form
: the Zend\Form\Form
instance.$redirect
: (Optional) a string containing the redirect
- location, which can either be a named route or a URL, based on the
- contents of the third parameter. If this argument is not provided, it
- will default to the current matched route.$redirectToUrl
: (Optional) a boolean that when set to
- TRUE
, causes the second 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
.
-$myForm = new Zend\Form\Form('my-form');
-$myForm->add([
- 'type' => 'Zend\Form\Element\File',
- 'name' => 'file',
-]);
-
-// NOTE: Without a filter to move the file,
-// our files will disappear between the requests
-$myForm->getInputFilter()->getFilterChain()->attach(
- new Zend\Filter\File\RenameUpload([
- 'target' => './data/tmpuploads/file',
- 'randomize' => true,
- ])
-);
-
-// Pass in the form and optional the route/url you want to redirect to after the POST
-$prg = $this->fileprg($myForm, '/user/profile-pic', true);
-
-if ($prg instanceof \Zend\Http\PhpEnvironment\Response) {
- // Returned a response to redirect us.
- return $prg;
-}
-
-if ($prg === false) {
- // First time the form was loaded.
- return array('form' => $myForm);
-}
-
-// Form was submitted.
-// $prg is now an array containing the POST params from the previous request,
-// but we don't have to apply it to the form since that has already been done.
-
-// Process the form
-if ($form->isValid()) {
- // ...Save the form...
- return $this->redirect()->toRoute('/user/profile-pic/success');
-}
-
-// Form not valid, but file uploads might be valid and uploaded
-$fileErrors = $form->get('file')->getMessages();
-if (empty($fileErrors)) {
- $tempFile = $form->get('file')->getValue();
-}
-
-