Skip to content

Commit

Permalink
Add a filter for router
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Popadko committed Jul 27, 2014
1 parent d1a53b8 commit 8971eb8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/vendor
/.idea
composer.phar
composer.lock
.DS_Store
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Run ``` php artisan config:publish joecwallace/artisan ```

Edit the ``` 'handles' ``` option. This sets the URI that Web Artisan should respond to, so ``` 'handles' => 'admin' ``` would set the package to respond to ``` http://my.awesome.app/admin ```, ``` http://my.awesome.app/admin/help+migrate ```, etc.

Edit the ``` 'filter' ``` option. Filter provide a convenient way of limiting access to a command run.

## Usage

1. Take an artisan task: ``` php artisan config:publish joecwallace/artisan ```
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"require": {
"php": ">=5.3.0",
"illuminate/support": "4.0.x"
"illuminate/support": "~4.0"
},
"autoload": {
"psr-0": {
Expand Down
19 changes: 10 additions & 9 deletions src/Joecwallace/Artisan/routes.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?php

use Joecwallace\Artisan\ArtisanRunner as Runner;
use Joecwallace\Artisan\HtmlOutput;

Route::get(Config::get('artisan::handles').'{uri}', function($uri = '')
{
$args = array();
Route::get(Config::get('artisan::handles') . '{uri}', array(
'before' => Config::get('artisan::filter'),
function($uri = '') {
$args = array();

if ( ! empty($uri)) {
$args = explode('+', trim($uri, '/'));
}
if ( ! empty($uri)) {
$args = explode('+', trim($uri, '/'));
}

Runner::run($args);
})->where('uri', '^($|\/.*)');
Runner::run($args);
}
))->where('uri', '^($|\/.*)');
2 changes: 2 additions & 0 deletions src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@

'handles' => 'artisan',

'filter' => '',

);

0 comments on commit 8971eb8

Please sign in to comment.