@@ -6,7 +6,7 @@ |
||
6 | 6 | ]; |
7 | 7 | |
8 | 8 | foreach ($controllers as $key => $class) { |
9 | - $container[$key] = function ($container) use ($class) { |
|
9 | + $container[$key] = function($container) use ($class) { |
|
10 | 10 | return new $class($container); |
11 | 11 | }; |
12 | 12 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | |
8 | 8 | $sentinel = (new Sentinel(new SentinelBootstrapper(__DIR__ . '/../config/sentinel.php')))->getSentinel(); |
9 | 9 | |
10 | -Manager::schema()->create('user', function (Blueprint $table) { |
|
10 | +Manager::schema()->create('user', function(Blueprint $table) { |
|
11 | 11 | $table->increments('id'); |
12 | 12 | $table->string('username')->unique(); |
13 | 13 | $table->string('email')->unique(); |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | $table->timestamps(); |
20 | 20 | }); |
21 | 21 | |
22 | -Manager::schema()->create('activations', function (Blueprint $table) { |
|
22 | +Manager::schema()->create('activations', function(Blueprint $table) { |
|
23 | 23 | $table->increments('id'); |
24 | 24 | $table->unsignedInteger('user_id'); |
25 | 25 | $table->string('code'); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | $table->foreign('user_id')->references('id')->on('user'); |
30 | 30 | }); |
31 | 31 | |
32 | -Manager::schema()->create('persistences', function (Blueprint $table) { |
|
32 | +Manager::schema()->create('persistences', function(Blueprint $table) { |
|
33 | 33 | $table->increments('id'); |
34 | 34 | $table->unsignedInteger('user_id'); |
35 | 35 | $table->string('code')->unique(); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $table->foreign('user_id')->references('id')->on('user'); |
38 | 38 | }); |
39 | 39 | |
40 | -Manager::schema()->create('reminders', function (Blueprint $table) { |
|
40 | +Manager::schema()->create('reminders', function(Blueprint $table) { |
|
41 | 41 | $table->increments('id'); |
42 | 42 | $table->unsignedInteger('user_id'); |
43 | 43 | $table->string('code'); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $table->foreign('user_id')->references('id')->on('user'); |
48 | 48 | }); |
49 | 49 | |
50 | -Manager::schema()->create('roles', function (Blueprint $table) { |
|
50 | +Manager::schema()->create('roles', function(Blueprint $table) { |
|
51 | 51 | $table->increments('id'); |
52 | 52 | $table->string('slug')->unique(); |
53 | 53 | $table->string('name'); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $table->timestamps(); |
56 | 56 | }); |
57 | 57 | |
58 | -Manager::schema()->create('role_users', function (Blueprint $table) { |
|
58 | +Manager::schema()->create('role_users', function(Blueprint $table) { |
|
59 | 59 | $table->unsignedInteger('user_id'); |
60 | 60 | $table->unsignedInteger('role_id'); |
61 | 61 | $table->timestamps(); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $table->foreign('role_id')->references('id')->on('roles'); |
65 | 65 | }); |
66 | 66 | |
67 | -Manager::schema()->create('throttle', function (Blueprint $table) { |
|
67 | +Manager::schema()->create('throttle', function(Blueprint $table) { |
|
68 | 68 | $table->increments('id'); |
69 | 69 | $table->integer('user_id')->unsigned()->nullable(); |
70 | 70 | $table->string('type'); |
@@ -15,12 +15,12 @@ discard block |
||
15 | 15 | * |
16 | 16 | * https://www.slimframework.com/docs/objects/router.html#route-strategies |
17 | 17 | */ |
18 | -$container['foundHandler'] = function () { |
|
18 | +$container['foundHandler'] = function() { |
|
19 | 19 | return new RequestResponseArgs(); |
20 | 20 | }; |
21 | 21 | |
22 | -$container['csrfFailureHandler'] = function ($container) { |
|
23 | - return function (Request $request, Response $response, callable $next) use ($container) { |
|
22 | +$container['csrfFailureHandler'] = function($container) { |
|
23 | + return function(Request $request, Response $response, callable $next) use ($container) { |
|
24 | 24 | $container['monolog']->error(sprintf('Failed CSRF check on "%s /%s"', $request->getMethod(), $request->getUri()->getPath())); |
25 | 25 | |
26 | 26 | $container['flash']->addMessage('error', 'Failed CSRF check'); |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | }; |
34 | 34 | }; |
35 | 35 | |
36 | -$container['notFoundHandler'] = function ($container) { |
|
37 | - return function (Request $request, Response $response) use ($container) { |
|
36 | +$container['notFoundHandler'] = function($container) { |
|
37 | + return function(Request $request, Response $response) use ($container) { |
|
38 | 38 | $container['monolog']->error(sprintf('No route found for "%s /%s"', $request->getMethod(), $request->getUri()->getPath())); |
39 | 39 | |
40 | 40 | if ('prod' === $container['env']) { |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | }; |
46 | 46 | }; |
47 | 47 | |
48 | -$container['notAllowedHandler'] = function ($container) { |
|
49 | - return function (Request $request, Response $response, array $methods) use ($container) { |
|
48 | +$container['notAllowedHandler'] = function($container) { |
|
49 | + return function(Request $request, Response $response, array $methods) use ($container) { |
|
50 | 50 | $container['monolog']->error(sprintf( |
51 | 51 | 'No route found for "%s /%s": Method not allowed (Allow: %s)', |
52 | 52 | $request->getMethod(), |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | }; |
63 | 63 | }; |
64 | 64 | |
65 | -$container['accessDeniedHandler'] = function ($container) { |
|
66 | - return function (Request $request, Response $response, AccessDeniedException $exception) use ($container) { |
|
65 | +$container['accessDeniedHandler'] = function($container) { |
|
66 | + return function(Request $request, Response $response, AccessDeniedException $exception) use ($container) { |
|
67 | 67 | $container['monolog']->debug('Access denied, the user does not have access to this section', [ |
68 | 68 | 'exception' => $exception |
69 | 69 | ]); |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | }; |
73 | 73 | }; |
74 | 74 | |
75 | -$container['errorHandler'] = function ($container) { |
|
76 | - return function (Request $request, Response $response, Exception $exception) use ($container) { |
|
75 | +$container['errorHandler'] = function($container) { |
|
76 | + return function(Request $request, Response $response, Exception $exception) use ($container) { |
|
77 | 77 | if ($exception instanceof AccessDeniedException) { |
78 | 78 | return $container['accessDeniedHandler']($request, $response, $exception); |
79 | 79 | } |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | }; |
91 | 91 | }; |
92 | 92 | |
93 | -$container['phpErrorHandler'] = function ($container) { |
|
94 | - return function (Request $request, Response $response, Throwable $error) use ($container) { |
|
93 | +$container['phpErrorHandler'] = function($container) { |
|
94 | + return function(Request $request, Response $response, Throwable $error) use ($container) { |
|
95 | 95 | $container['monolog']->critical('Uncaught PHP Exception ' . get_class($error), [ |
96 | 96 | 'exception' => $error |
97 | 97 | ]); |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$app->group('', function () { |
|
3 | +$app->group('', function() { |
|
4 | 4 | $this->map(['GET', 'POST'], '/login', 'auth.controller:login')->setName('login'); |
5 | 5 | $this->map(['GET', 'POST'], '/register', 'auth.controller:register')->setName('register'); |
6 | 6 | })->add($container['guest.middleware']); |
@@ -3,12 +3,12 @@ |
||
3 | 3 | use Security\Middleware\AuthMiddleware; |
4 | 4 | use Security\Middleware\GuestMiddleware; |
5 | 5 | |
6 | -$container['guest.middleware'] = function ($container) { |
|
6 | +$container['guest.middleware'] = function($container) { |
|
7 | 7 | return new GuestMiddleware($container['router'], $container['auth']); |
8 | 8 | }; |
9 | 9 | |
10 | -$container['auth.middleware'] = function ($container) { |
|
11 | - return function ($role = null) use ($container) { |
|
10 | +$container['auth.middleware'] = function($container) { |
|
11 | + return function($role = null) use ($container) { |
|
12 | 12 | return new AuthMiddleware($container['router'], $container['flash'], $container['auth'], $role); |
13 | 13 | }; |
14 | 14 | }; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | if (!$input->getArgument('username')) { |
86 | 86 | $question = new Question('Please choose a username:'); |
87 | - $question->setValidator(function ($username) { |
|
87 | + $question->setValidator(function($username) { |
|
88 | 88 | if (empty($username)) { |
89 | 89 | throw new \Exception('Username can not be empty'); |
90 | 90 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | |
97 | 97 | if (!$input->getArgument('email')) { |
98 | 98 | $question = new Question('Please choose an email:'); |
99 | - $question->setValidator(function ($email) { |
|
99 | + $question->setValidator(function($email) { |
|
100 | 100 | if (empty($email)) { |
101 | 101 | throw new \Exception('Email can not be empty'); |
102 | 102 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | if (!$input->getArgument('password')) { |
111 | 111 | $question = new Question('Please choose a password:'); |
112 | - $question->setValidator(function ($password) { |
|
112 | + $question->setValidator(function($password) { |
|
113 | 113 | if (empty($password)) { |
114 | 114 | throw new \Exception('Password can not be empty'); |
115 | 115 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$app->group('/admin', function () use ($container) { |
|
3 | +$app->group('/admin', function() use ($container) { |
|
4 | 4 | $this->get('', 'admin.controller:home') |
5 | 5 | ->setName('admin.home'); |
6 | 6 | })->add($container['auth.middleware']('admin')); |
@@ -23,21 +23,21 @@ discard block |
||
23 | 23 | $capsule->setAsGlobal(); |
24 | 24 | $capsule->bootEloquent(); |
25 | 25 | |
26 | -$container['db'] = function () use ($capsule) { |
|
26 | +$container['db'] = function() use ($capsule) { |
|
27 | 27 | return $capsule; |
28 | 28 | }; |
29 | 29 | |
30 | -$container['auth'] = function () { |
|
30 | +$container['auth'] = function() { |
|
31 | 31 | $sentinel = new Sentinel(new SentinelBootstrapper(__DIR__ . '/config/sentinel.php')); |
32 | 32 | |
33 | 33 | return $sentinel->getSentinel(); |
34 | 34 | }; |
35 | 35 | |
36 | -$container['flash'] = function () { |
|
36 | +$container['flash'] = function() { |
|
37 | 37 | return new Messages(); |
38 | 38 | }; |
39 | 39 | |
40 | -$container['csrf'] = function ($container) { |
|
40 | +$container['csrf'] = function($container) { |
|
41 | 41 | $guard = new Guard(); |
42 | 42 | $guard->setFailureCallable($container['csrfFailureHandler']); |
43 | 43 | |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | }; |
46 | 46 | |
47 | 47 | // https://github.com/awurth/slim-validation |
48 | -$container['validator'] = function () { |
|
48 | +$container['validator'] = function() { |
|
49 | 49 | return new Validator(); |
50 | 50 | }; |
51 | 51 | |
52 | -$container['view'] = function ($container) { |
|
52 | +$container['view'] = function($container) { |
|
53 | 53 | $config = $container['config']; |
54 | 54 | |
55 | 55 | $view = new Twig( |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | return $view; |
76 | 76 | }; |
77 | 77 | |
78 | -$container['monolog'] = function ($container) { |
|
78 | +$container['monolog'] = function($container) { |
|
79 | 79 | $config = $container['config']['monolog']; |
80 | 80 | |
81 | 81 | $logger = new Logger($config['name']); |