|
1
|
|
|
<?php namespace Modules\Core\Console\Installers\Scripts\UserProviders; |
|
2
|
|
|
|
|
3
|
|
|
use Modules\Core\Console\Installers\SetupScript; |
|
4
|
|
|
|
|
5
|
|
|
class SentinelInstaller extends ProviderInstaller implements SetupScript |
|
6
|
|
|
{ |
|
7
|
|
|
/** |
|
8
|
|
|
* Check if the user driver is correctly registered. |
|
9
|
|
|
* @return bool |
|
10
|
|
|
*/ |
|
11
|
|
|
public function checkIsInstalled() |
|
12
|
|
|
{ |
|
13
|
|
|
return class_exists('Cartalyst\Sentinel\Laravel\SentinelServiceProvider'); |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Not called |
|
18
|
|
|
* @return mixed |
|
19
|
|
|
*/ |
|
20
|
|
|
public function composer() |
|
21
|
|
|
{ |
|
22
|
|
|
$this->composer->enableOutput($this->command); |
|
23
|
|
|
$this->composer->install('cartalyst/sentinel:dev-feature/laravel-5'); |
|
24
|
|
|
$this->composer->remove('cartalyst/sentry'); |
|
25
|
|
|
$this->composer->dumpAutoload(); |
|
26
|
|
|
|
|
27
|
|
|
// Dynamically register the service provider, so we can use it during publishing |
|
28
|
|
|
$this->application->register('Cartalyst\Sentinel\Laravel\SentinelServiceProvider'); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @return mixed |
|
33
|
|
|
*/ |
|
34
|
|
View Code Duplication |
public function publish() |
|
|
|
|
|
|
35
|
|
|
{ |
|
36
|
|
|
if ($this->command->option('verbose')) { |
|
37
|
|
|
return $this->command->call('vendor:publish', ['--provider' => 'Cartalyst\Sentinel\Laravel\SentinelServiceProvider']); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
return $this->command->callSilent('vendor:publish', ['--provider' => 'Cartalyst\Sentinel\Laravel\SentinelServiceProvider']); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @return mixed |
|
45
|
|
|
*/ |
|
46
|
|
|
public function migrate() |
|
47
|
|
|
{ |
|
48
|
|
|
if ($this->command->option('verbose')) { |
|
49
|
|
|
return $this->command->call('migrate'); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
return $this->command->callSilent('migrate'); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @return mixed |
|
57
|
|
|
*/ |
|
58
|
|
|
public function configure() |
|
59
|
|
|
{ |
|
60
|
|
|
$this->replaceCartalystUserModelConfiguration( |
|
61
|
|
|
'Cartalyst\Sentinel\Users\EloquentUser', |
|
62
|
|
|
'Sentinel' |
|
63
|
|
|
); |
|
64
|
|
|
|
|
65
|
|
|
$this->changeDefaultUserProvider('Sentinel'); |
|
66
|
|
|
|
|
67
|
|
|
$this->bindUserRepositoryOnTheFly('Sentinel'); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @return mixed |
|
72
|
|
|
*/ |
|
73
|
|
View Code Duplication |
public function seed() |
|
|
|
|
|
|
74
|
|
|
{ |
|
75
|
|
|
if ($this->command->option('verbose')) { |
|
76
|
|
|
return $this->command->call('db:seed', ['--class' => 'Modules\User\Database\Seeders\SentinelGroupSeedTableSeeder']); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
return $this->command->callSilent('db:seed', ['--class' => 'Modules\User\Database\Seeders\SentinelGroupSeedTableSeeder']); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @param $password |
|
84
|
|
|
* @return mixed |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getHashedPassword($password) |
|
87
|
|
|
{ |
|
88
|
|
|
return $password; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @param $driver |
|
93
|
|
|
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException |
|
94
|
|
|
*/ |
|
95
|
|
|
private function changeDefaultUserProvider($driver) |
|
96
|
|
|
{ |
|
97
|
|
|
$path = base_path('config/asgard.user.users.php'); |
|
98
|
|
|
$config = $this->finder->get($path); |
|
99
|
|
|
$config = str_replace('Sentry', $driver, $config); |
|
100
|
|
|
$this->finder->put($path, $config); |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.