Skip to content

Commit f556e3e

Browse files
committed
Add ability to extend handlers via config
Resolve #50
1 parent dc0811a commit f556e3e

15 files changed

+437
-75
lines changed

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
tests
2+
travis.yml
3+
.php_cs
4+
.phplint.yml
5+
phpunit.xml
6+
CODE_OF_CONDUCT.md

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
composer.phar
33
/vendor/
44
composer.lock
5+
/build
56

.php_cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
$finder = PhpCsFixer\Finder::create()
3+
->in(__DIR__ . '/src')
4+
->in(__DIR__ . '/config')
5+
->in(__DIR__ . '/tests')
6+
->name('*.php')
7+
->ignoreDotFiles(true)
8+
->ignoreVCS(true);
9+
10+
return PhpCsFixer\Config::create()
11+
->setRules(array(
12+
'@PHP56Migration' => true,
13+
'@Symfony' => true,
14+
'align_multiline_comment' => true,
15+
'array_indentation' => true,
16+
'array_syntax' => ['syntax' => 'short'],
17+
))
18+
->setFinder($finder);

.phplint.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
path: ./
2+
jobs: 5
3+
cache: build/phplint.cache
4+
extensions:
5+
- php
6+
exclude:
7+
- vendor

CONTRIBUTING.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ upload and progress.
1010
## Pull Requests
1111

1212
- **Use the [PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md).**
13-
The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
13+
The easiest way to apply the conventions is to use `composer run lint:fix`.
1414

1515
- **Consider our release cycle.** We try to follow [SemVer v2.0.0](http://semver.org/).
1616

@@ -20,6 +20,14 @@ upload and progress.
2020
- **Create feature branches.** Don't ask us to pull from your master branch.
2121

2222
- **One pull request per feature.** If you want to do more than one thing, send multiple pull requests.
23+
24+
### Before pull-request do:
25+
26+
1. Rebase your changes on master branch
27+
2. Lint project `composer run lint`
28+
3. Run tests `composer run test`
29+
4. (recommended) Write tests
30+
5. (optinal) Rebase your commits to fewer commits
2331

2432
**Thank you!**
2533

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"scripts": {
1212
"lint:fix": "./vendor/bin/php-cs-fixer fix --config=.php_cs --using-cache false",
1313
"lint:check": "./vendor/bin/phplint",
14-
"lint": "composer run-script lint-fix && composer run-script lint-check"
14+
"lint": "composer run-script lint:fix && composer run-script lint:check",
15+
"test": "./vendor/bin/phpunit"
1516
},
1617
"require": {
1718
"illuminate/http": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.*",
@@ -22,7 +23,7 @@
2223
"require-dev": {
2324
"laravel/laravel": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.*",
2425
"phpunit/phpunit": "5.7 || 6.0 || 7.0",
25-
"mockery/mockery": "^0.9.9",
26+
"mockery/mockery": "^1.1.0",
2627
"friendsofphp/php-cs-fixer": "^2.12",
2728
"overtrue/phplint": "^1.1"
2829
},

config/chunk-upload.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,12 @@
3030
],
3131
],
3232
],
33+
'handlers' => [
34+
// A list of handlers/providers that will be appended to existing list of handlers
35+
'custom' => [],
36+
// Overrides the list of handlers - use only what you really want
37+
'override' => [
38+
// \Pion\Laravel\ChunkUpload\Handler\DropZoneUploadHandler::class
39+
],
40+
],
3341
];

phpcs.xml

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/Config/AbstractConfig.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ public static function config()
1616
return app(AbstractConfig::class);
1717
}
1818

19+
/**
20+
* Returns a list custom handlers (custom, override).
21+
*
22+
* @return array
23+
*/
24+
abstract public function handlers();
25+
1926
/**
2027
* Returns the disk name to use for the chunk storage.
2128
*

src/Config/FileConfig.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ class FileConfig extends AbstractConfig
1414
*/
1515
const FILE_NAME = 'chunk-upload';
1616

17+
/**
18+
* Returns a list custom handlers (custom, override).
19+
*
20+
* @return array
21+
*/
22+
public function handlers()
23+
{
24+
return $this->get('hanlders', []);
25+
}
26+
1727
/**
1828
* Returns the disk name to use for the chunk storage.
1929
*

0 commit comments

Comments
 (0)