Skip to content

Commit 02c842e

Browse files
committed
💚 psr2
1 parent 030d405 commit 02c842e

File tree

2 files changed

+76
-70
lines changed

2 files changed

+76
-70
lines changed

src/Commands/GroupAdd.php

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,41 @@
88
/**
99
* PolicyAdd class.
1010
*/
11-
class GroupAdd extends Command {
12-
/**
13-
* The name and signature of the console command.
14-
*
15-
* @var string
16-
*/
17-
protected $signature = 'group:add
11+
class GroupAdd extends Command
12+
{
13+
/**
14+
* The name and signature of the console command.
15+
*
16+
* @var string
17+
*/
18+
protected $signature = 'group:add
1819
{policy : the rule separated by commas}';
1920

20-
/**
21-
* The console command description.
22-
*
23-
* @var string
24-
*/
25-
protected $description = 'Adds a role inheritance rule to the current policy.';
21+
/**
22+
* The console command description.
23+
*
24+
* @var string
25+
*/
26+
protected $description = 'Adds a role inheritance rule to the current policy.';
2627

27-
/**
28-
* Execute the console command.
29-
*
30-
* @return mixed
31-
*/
32-
public function handle() {
33-
$params = explode(',', $this->argument('policy'));
34-
array_walk($params, function (&$value) {
35-
$value = trim($value);
36-
});
37-
$ret = Enforcer::addGroupingPolicy(...$params);
38-
if ($ret) {
39-
$this->info('Grouping `' . implode(', ', $params) . '` created');
40-
} else {
41-
$this->error('Grouping `' . implode(', ', $params) . '` creation failed');
42-
}
28+
/**
29+
* Execute the console command.
30+
*
31+
* @return mixed
32+
*/
33+
public function handle()
34+
{
35+
$params = explode(',', $this->argument('policy'));
36+
array_walk($params, function (&$value) {
37+
$value = trim($value);
38+
});
39+
$ret = Enforcer::addGroupingPolicy(...$params);
40+
if ($ret) {
41+
$this->info('Grouping `' . implode(', ', $params) . '` created');
42+
} else {
43+
$this->error('Grouping `' . implode(', ', $params) . '` creation failed');
44+
}
4345

44-
return $ret ? 0 : 1;
45-
}
46+
return $ret ? 0 : 1;
47+
}
4648
}

src/LauthzServiceProvider.php

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,47 @@
66
use Lauthz\Models\Rule;
77
use Lauthz\Observers\RuleObserver;
88

9-
class LauthzServiceProvider extends ServiceProvider {
10-
/**
11-
* Perform post-registration booting of services.
12-
*/
13-
public function boot() {
14-
if ($this->app->runningInConsole()) {
15-
$this->publishes([__DIR__ . '/../database/migrations' => database_path('migrations')], 'laravel-lauthz-migrations');
16-
$this->publishes([__DIR__ . '/../config/lauthz-rbac-model.conf' => config_path('lauthz-rbac-model.conf')], 'laravel-lauthz-config');
17-
$this->publishes([__DIR__ . '/../config/lauthz.php' => config_path('lauthz.php')], 'laravel-lauthz-config');
18-
19-
$this->commands([
20-
Commands\GroupAdd::class,
21-
Commands\PolicyAdd::class,
22-
Commands\RoleAssign::class,
23-
]);
24-
}
25-
26-
$this->mergeConfigFrom(__DIR__ . '/../config/lauthz.php', 'lauthz');
27-
28-
$this->bootObserver();
29-
}
30-
31-
/**
32-
* Boot Observer.
33-
*
34-
* @return void
35-
*/
36-
protected function bootObserver() {
37-
Rule::observe(new RuleObserver());
38-
}
39-
40-
/**
41-
* Register bindings in the container.
42-
*/
43-
public function register() {
44-
$this->app->singleton('enforcer', function ($app) {
45-
return new EnforcerManager($app);
46-
});
47-
}
9+
class LauthzServiceProvider extends ServiceProvider
10+
{
11+
/**
12+
* Perform post-registration booting of services.
13+
*/
14+
public function boot()
15+
{
16+
if ($this->app->runningInConsole()) {
17+
$this->publishes([__DIR__ . '/../database/migrations' => database_path('migrations')], 'laravel-lauthz-migrations');
18+
$this->publishes([__DIR__ . '/../config/lauthz-rbac-model.conf' => config_path('lauthz-rbac-model.conf')], 'laravel-lauthz-config');
19+
$this->publishes([__DIR__ . '/../config/lauthz.php' => config_path('lauthz.php')], 'laravel-lauthz-config');
20+
21+
$this->commands([
22+
Commands\GroupAdd::class,
23+
Commands\PolicyAdd::class,
24+
Commands\RoleAssign::class,
25+
]);
26+
}
27+
28+
$this->mergeConfigFrom(__DIR__ . '/../config/lauthz.php', 'lauthz');
29+
30+
$this->bootObserver();
31+
}
32+
33+
/**
34+
* Boot Observer.
35+
*
36+
* @return void
37+
*/
38+
protected function bootObserver()
39+
{
40+
Rule::observe(new RuleObserver());
41+
}
42+
43+
/**
44+
* Register bindings in the container.
45+
*/
46+
public function register()
47+
{
48+
$this->app->singleton('enforcer', function ($app) {
49+
return new EnforcerManager($app);
50+
});
51+
}
4852
}

0 commit comments

Comments
 (0)