1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
|-------------------------------------------------------------------------- |
5
|
|
|
| Application Routes |
6
|
|
|
|-------------------------------------------------------------------------- |
7
|
|
|
| |
8
|
|
|
| Here is where you can register all of the routes for an application. |
9
|
|
|
| It's a breeze. Simply tell Laravel the URIs it should respond to |
10
|
|
|
| and give it the Closure to execute when that URI is requested. |
11
|
|
|
| |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
use Assetic\Factory\AssetFactory; |
15
|
|
|
use Assetic\Filter\CoffeeScriptFilter; |
16
|
|
|
use Assetic\Filter\CssMinFilter; |
17
|
|
|
use Assetic\Filter\GoogleClosure\CompilerApiFilter; |
18
|
|
|
use Assetic\Filter\LessphpFilter; |
19
|
|
|
use Assetic\Filter\PhpCssEmbedFilter; |
20
|
|
|
use Assetic\Filter\ScssphpFilter; |
21
|
|
|
use Assetic\FilterManager; |
22
|
|
|
|
23
|
|
|
View::composer('layouts._header', function ($view) { |
24
|
|
|
$posts = App::make('Flaviozantut\Storage\Posts\PostRepositoryInterface'); |
25
|
|
|
$view->with('pages', $posts->all('page')); |
26
|
|
|
}); |
27
|
|
|
|
28
|
|
|
Route::group(['before' => 'cache', 'after' => 'cache'], function () { |
29
|
|
|
Route::get('/', 'PostController@articles'); |
30
|
|
|
Route::get('/{type}/{permalink}', 'PostController@get')->where('type', 'article|page|draft'); |
31
|
|
|
}); |
32
|
|
|
|
33
|
|
|
Route::get('{args}', [function ($args = null) { |
34
|
|
|
$filters = explode(',', Input::get('f')); |
35
|
|
|
$putLocation = public_path().'/'.$args; |
36
|
|
|
|
37
|
|
|
$assets = explode('|', preg_replace_callback("/assets\/(.*)\.(css|js)/", function ($matches) { |
38
|
|
|
$t = explode('/', $matches[1]); |
39
|
|
|
|
40
|
|
|
return "$matches[1]/*.".Config::get('skorry.assets.types.'.$t[0])."|$t[0]|$matches[2]"; |
41
|
|
|
}, $args)); |
42
|
|
|
$files[] = $assets[0]; |
43
|
|
|
$type = $assets[1]; |
44
|
|
|
$ext = $assets[2]; |
45
|
|
|
|
46
|
|
|
if (in_array($type, ['less', 'scss', 'coffee'])) { |
47
|
|
|
array_push($filters, $type); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
if ($ext == 'js') { |
51
|
|
|
$type = 'text/javascript; charset=UTF-8'; |
52
|
|
|
array_push($filters, '?js_min'); |
53
|
|
|
} elseif ($ext == 'css') { |
54
|
|
|
$type = 'text/css; charset=UTF-8'; |
55
|
|
|
array_push($filters, 'embed'); |
56
|
|
|
array_push($filters, '?css_min'); |
57
|
|
|
} else { |
58
|
|
|
App:abort(404); |
59
|
|
|
} |
60
|
|
|
$fm = new FilterManager(app_path().'/assets/'); |
|
|
|
|
61
|
|
|
$fm->set('less', new LessphpFilter()); |
62
|
|
|
$fm->set('scss', new ScssphpFilter()); |
63
|
|
|
$fm->set('embed', new PhpCssEmbedFilter()); |
64
|
|
|
$fm->set('coffee', new CoffeeScriptFilter()); |
65
|
|
|
$fm->set('css_min', new CssMinFilter()); |
66
|
|
|
$fm->set('js_min', new CompilerApiFilter()); |
67
|
|
|
|
68
|
|
|
$factory = new AssetFactory(app_path().'/assets/'); |
69
|
|
|
$factory->setFilterManager($fm); |
70
|
|
|
$factory->setDebug((App::environment() == 'local') ? true : false); |
71
|
|
|
$content = $factory->createAsset($files, array_filter($filters)); |
72
|
|
|
|
73
|
|
|
if (App::environment() != 'local') { |
74
|
|
|
if (!File::isDirectory(dirname($putLocation))) { |
75
|
|
|
File::makeDirectory(dirname($putLocation), 0777, true); |
76
|
|
|
} |
77
|
|
|
File::put($putLocation, $content->dump()); |
78
|
|
|
|
79
|
|
|
return Redirect::to($args); |
80
|
|
|
} else { |
81
|
|
|
File::deleteDirectory(public_path().'/assets'); |
82
|
|
|
} |
83
|
|
|
$response = Response::make($content->dump()); |
84
|
|
|
$response->header('content-type', $type); |
85
|
|
|
|
86
|
|
|
return $response; |
87
|
|
|
|
88
|
|
|
}])->where('args', 'assets/(.*)'); |
89
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.