Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Platform
Commits
2408eea6
Commit
2408eea6
authored
Nov 26, 2014
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prepare first pass at file search and replaces
parent
f6881dfa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
12 deletions
+74
-12
InstallCommand.php
Modules/Core/Console/InstallCommand.php
+74
-12
No files found.
Modules/Core/Console/InstallCommand.php
View file @
2408eea6
...
...
@@ -2,6 +2,7 @@
use
Dotenv
;
use
Illuminate\Console\Command
;
use
Illuminate\Contracts\Foundation\Application
;
use
Illuminate\Filesystem\Filesystem
;
use
Illuminate\Support\Facades\Hash
;
use
Modules\User\Repositories\UserRepository
;
...
...
@@ -31,19 +32,24 @@ class InstallCommand extends Command
* @var Filesystem
*/
private
$finder
;
/**
* @var Application
*/
private
$app
;
/**
* Create a new command instance.
*
* @param UserRepository $user
* @param Filesystem $finder
* @
return \Modules\Core\Console\InstallCommand
* @
param Application $app
*/
public
function
__construct
(
$user
,
Filesystem
$finder
)
public
function
__construct
(
$user
,
Filesystem
$finder
,
Application
$app
)
{
parent
::
__construct
();
$this
->
user
=
$user
;
$this
->
finder
=
$finder
;
$this
->
app
=
$app
;
}
/**
...
...
@@ -57,9 +63,9 @@ class InstallCommand extends Command
$this
->
configureDatabase
();
if
(
$this
->
confirm
(
'Do you wish to init sentinel and create its first user? [yes|no]'
))
{
$this
->
runUserCommands
()
;
}
$userDriver
=
$this
->
choice
(
'Which user driver do you wish to use?'
,
[
'Sentinel'
,
'Sentry'
],
'Sentry'
);
$userDriver
=
"run
{
$userDriver
}
UserCommands"
;
$this
->
$userDriver
();
$this
->
runMigrations
();
...
...
@@ -74,10 +80,22 @@ class InstallCommand extends Command
/**
*
*/
private
function
runUserCommands
()
private
function
run
Sentinel
UserCommands
()
{
$this
->
runSentinelMigrations
();
$this
->
runUserSeeds
();
$this
->
call
(
'db:seed'
,
[
'--class'
=>
'Modules\User\Database\Seeders\SentinelGroupSeedTableSeeder'
]);
$this
->
replaceUserRepositoryBindings
(
'Sentinel'
);
# optional for sentinel
$this
->
bindUserRepositoryOnTheFly
(
'Sentinel'
);
$this
->
call
(
'publish:config'
,
[
'package'
=>
'cartalyst/sentinel'
]);
$this
->
replaceCartalystUserModelConfiguration
(
'Cartalyst\Sentinel\Users\EloquentUser'
,
'Sentinel'
);
dd
(
'Config changed'
);
// Search and replace SP and Alias in config/app.php
$this
->
createFirstUser
();
$this
->
info
(
'User commands done.'
);
...
...
@@ -126,11 +144,6 @@ class InstallCommand extends Command
$this
->
info
(
'Application migrated!'
);
}
private
function
runUserSeeds
()
{
$this
->
call
(
'module:seed'
,
[
'module'
=>
'User'
]);
}
/**
* Symfony style block messages
* @param $title
...
...
@@ -216,4 +229,53 @@ class InstallCommand extends Command
$this
->
laravel
[
'config'
][
'database.connections.mysql.password'
]
=
$databasePassword
;
}
/**
* Find and replace the correct repository bindings with the given driver
* @param string $driver
* @throws \Illuminate\Filesystem\FileNotFoundException
*/
private
function
replaceUserRepositoryBindings
(
$driver
)
{
$path
=
'Modules/User/Providers/UserServiceProvider.php'
;
$userServiceProvider
=
$this
->
finder
->
get
(
$path
);
$userServiceProvider
=
str_replace
(
'Sentinel'
,
$driver
,
$userServiceProvider
);
$this
->
finder
->
put
(
$path
,
$userServiceProvider
);
}
/**
* Set the correct repository binding on the fly for the current request
* @param $driver
*/
private
function
bindUserRepositoryOnTheFly
(
$driver
)
{
$this
->
app
->
bind
(
'Modules\User\Repositories\UserRepository'
,
"Modules
\\
User
\\
Repositories
\\
$driver
\\
{
$driver
}
UserRepository"
);
$this
->
app
->
bind
(
'Modules\User\Repositories\RoleRepository'
,
"Modules
\\
User
\\
Repositories
\\
$driver
\\
{
$driver
}
RoleRepository"
);
$this
->
app
->
bind
(
'Modules\Core\Contracts\Authentication'
,
"Modules
\\
User
\\
Repositories
\\
$driver
\\
{
$driver
}
Authentication"
);
}
/**
* Replaced the model in the cartalyst configuration file
* @param string $search
* @param string $Driver
* @throws \Illuminate\Filesystem\FileNotFoundException
*/
private
function
replaceCartalystUserModelConfiguration
(
$search
,
$Driver
)
{
$driver
=
strtolower
(
$Driver
);
$path
=
"config/packages/cartalyst/
{
$driver
}
/config.php"
;
$config
=
$this
->
finder
->
get
(
$path
);
$config
=
str_replace
(
$search
,
"Modules
\\
User
\\
Entities
\\
{
$Driver
}
User"
,
$config
);
$this
->
finder
->
put
(
$path
,
$config
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment