Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request #151 from davidyell/develop
Browse files Browse the repository at this point in the history
Merge for release
  • Loading branch information
davidyell committed Oct 22, 2015
2 parents e14c8d5 + ed10a69 commit b4e3e23
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 0 additions & 2 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ In your terminal you can use
$ composer require 'davidyell/proffer:~0.4'
```

If you would rather edit your `composer.json` you can add it to your `composer.json` in your require section `"davidyell/proffer": "dev-master"` and then run `composer update`.

It's always advised to lock your dependencies to a specific version number. You can [check the releases](https://github.com/davidyell/CakePHP3-Proffer/releases),
or [read more about versions on Composer.org](https://getcomposer.org/doc/01-basic-usage.md#package-versions). For more information about [installing plugins with CakePHP](http://book.cakephp.org/3.0/en/plugins.html#installing-a-plugin-with-composer), check the book.

Expand Down
18 changes: 16 additions & 2 deletions docs/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ This manual page deals with how to use the included ProfferRules validation prov
your application.

##Built-in validation provider
Proffer comes with some basic validation rules which you can use to validate your uploads. In order to use these you
will need to load the validation rules and apply them to your field.
Proffer comes an extra validation rule to check the dimensions of an uploaded image. Other rules are provided by the core and are listed below.

In your validation function in your table class you'll need to add the validator as a provider and then apply the rules.

Expand All @@ -25,5 +24,20 @@ $validator->provider('proffer', 'Proffer\Model\Validation\ProfferRules');

You can [read more about custom validation providers in the book](http://book.cakephp.org/3.0/en/core-libraries/validation.html#adding-validation-providers).

If you need to validate other aspects of the uploaded file, there are a number of core validation methods you might find helpful.
* [Extension](http://api.cakephp.org/3.0/class-Cake.Validation.Validation.html#_extension)
* [File size](http://api.cakephp.org/3.0/class-Cake.Validation.Validation.html#_fileSize)
* [Mime type](http://api.cakephp.org/3.0/class-Cake.Validation.Validation.html#_mimeType)

## Basic validation rules
If you want your users to submit a file when creating a record, but not when updating it, you can configure this using the basic Cake rules.

```php
$validator
->requirePresence('image', 'create')
->allowEmpty('image', 'update');
```

So now your users do not need to upload a file every time they update a record.

[< Configuration](configuration.md) | [Customisation >](customisation.md)
2 changes: 1 addition & 1 deletion src/Shell/ProfferShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function generate($table)
}

if (!empty($this->param('image-class'))) {
$class = (string)$this->param('image_class');
$class = (string)$this->param('image-class');
$transform = new $class($this->Table, $path);
} else {
$transform = new ImageTransform($this->Table, $path);
Expand Down

0 comments on commit b4e3e23

Please sign in to comment.