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
5860e1b7
Commit
5860e1b7
authored
Oct 26, 2014
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Plain Diff
Fixing merge conflicts
parents
81f878ae
994a3656
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
216 additions
and
194 deletions
+216
-194
BaseSidebarViewComposer.php
Modules/Core/Composers/BaseSidebarViewComposer.php
+16
-0
InstallCommand.php
Modules/Core/Console/InstallCommand.php
+168
-175
Authentication.php
Modules/Core/Contracts/Authentication.php
+7
-0
sidebar-nav.blade.php
Modules/Core/Resources/views/partials/sidebar-nav.blade.php
+25
-19
No files found.
Modules/Core/Composers/BaseSidebarViewComposer.php
0 → 100644
View file @
5860e1b7
<?php
namespace
Modules\Core\Composers
;
use
Modules\Core\Contracts\Authentication
;
abstract
class
BaseSidebarViewComposer
{
/**
* @var Authentication
*/
protected
$auth
;
public
function
__construct
(
Authentication
$auth
)
{
$this
->
auth
=
$auth
;
}
}
Modules/Core/Console/InstallCommand.php
View file @
5860e1b7
...
...
@@ -8,68 +8,68 @@ use Modules\User\Repositories\UserRepository;
class
InstallCommand
extends
Command
{
/**
* The console command name.
*
* @var string
*/
protected
$name
=
'platform:install'
;
/**
* The console command description.
*
* @var string
*/
protected
$description
=
'Install the Platform CMS'
;
/**
* @var UserRepository
*/
private
$user
;
/**
* @var Filesystem
*/
private
$finder
;
/**
* Create a new command instance.
*
* @param UserRepository $user
* @param Filesystem $finder
* @return \Modules\Core\Console\InstallCommand
*/
public
function
__construct
(
$user
,
Filesystem
$finder
)
{
parent
::
__construct
();
$this
->
user
=
$user
;
$this
->
finder
=
$finder
;
}
/**
* Execute the actions
*
* @return mixed
*/
public
function
fire
()
{
$this
->
info
(
'Starting the installation process...'
);
$this
->
configureDatabase
();
/**
* The console command name.
*
* @var string
*/
protected
$name
=
'platform:install'
;
/**
* The console command description.
*
* @var string
*/
protected
$description
=
'Install the Platform CMS'
;
/**
* @var UserRepository
*/
private
$user
;
/**
* @var Filesystem
*/
private
$finder
;
/**
* Create a new command instance.
*
* @param UserRepository $user
* @param Filesystem $finder
* @return \Modules\Core\Console\InstallCommand
*/
public
function
__construct
(
$user
,
Filesystem
$finder
)
{
parent
::
__construct
();
$this
->
user
=
$user
;
$this
->
finder
=
$finder
;
}
/**
* Execute the actions
*
* @return mixed
*/
public
function
fire
()
{
$this
->
info
(
'Starting the installation process...'
);
$this
->
configureDatabase
();
if
(
$this
->
confirm
(
'Do you wish to init sentinel and create its first user? [yes|no]'
))
{
$this
->
runUserCommands
();
}
$this
->
runMigrations
();
$this
->
runMigrations
();
$this
->
publishAssets
();
$this
->
publishAssets
();
$this
->
blockMessage
(
'Success!'
,
'Platform ready! You can now login with your username and password at /backend'
);
}
$this
->
blockMessage
(
'Success!'
,
'Platform ready! You can now login with your username and password at /backend'
);
}
/**
*
...
...
@@ -83,140 +83,133 @@ class InstallCommand extends Command
$this
->
info
(
'User commands done.'
);
}
/**
* Create the first user that'll have admin access
*/
private
function
createFirstUser
()
{
$this
->
line
(
'Creating an Admin user account...'
);
$firstname
=
$this
->
ask
(
'Enter your first name'
);
$lastname
=
$this
->
ask
(
'Enter your last name'
);
$email
=
$this
->
ask
(
'Enter your email address'
);
$password
=
$this
->
secret
(
'Enter a password'
);
$userInfo
=
[
'first_name'
=>
$firstname
,
'last_name'
=>
$lastname
,
'email'
=>
$email
,
'password'
=>
Hash
::
make
(
$password
),
];
$this
->
user
->
createWithRoles
(
$userInfo
,
[
'admin'
]);
$this
->
info
(
'Admin account created!'
);
}
/**
* Create the first user that'll have admin access
*/
private
function
createFirstUser
()
{
$this
->
line
(
'Creating an Admin user account...'
);
$firstname
=
$this
->
ask
(
'Enter your first name'
);
$lastname
=
$this
->
ask
(
'Enter your last name'
);
$email
=
$this
->
ask
(
'Enter your email address'
);
$password
=
$this
->
secret
(
'Enter a password'
);
$userInfo
=
[
'first_name'
=>
$firstname
,
'last_name'
=>
$lastname
,
'email'
=>
$email
,
'password'
=>
Hash
::
make
(
$password
),
];
$this
->
user
->
createWithRoles
(
$userInfo
,
[
'admin'
]);
$this
->
info
(
'Admin account created!'
);
}
/**
* Run migrations specific to Sentinel
*/
*/
private
function
runSentinelMigrations
()
{
$this
->
call
(
'migrate'
,
[
'--package'
=>
'cartalyst/sentinel'
]);
}
/**
* Run the migrations
*/
private
function
runMigrations
()
{
$this
->
call
(
'module:migrate'
,
[
'module'
=>
'Setting'
]);
/**
* Run the migrations
*/
private
function
runMigrations
()
{
$this
->
call
(
'module:migrate'
,
[
'module'
=>
'Setting'
]);
$this
->
info
(
'Application migrated!'
);
}
$this
->
info
(
'Application migrated!'
);
}
private
function
runUserSeeds
()
{
$this
->
call
(
'module:seed'
,
[
'module'
=>
'User'
]);
}
/**
* Run the seeds
*/
private
function
runSeeds
()
{
$this
->
info
(
'Application seeded!'
);
}
/**
* Symfony style block messages
* @param $title
* @param $message
* @param string $style
*/
protected
function
blockMessage
(
$title
,
$message
,
$style
=
'info'
)
{
$formatter
=
$this
->
getHelperSet
()
->
get
(
'formatter'
);
$errorMessages
=
[
$title
,
$message
];
$formattedBlock
=
$formatter
->
formatBlock
(
$errorMessages
,
$style
,
true
);
$this
->
line
(
$formattedBlock
);
}
/**
* Publish the CMS assets
*/
private
function
publishAssets
()
{
$this
->
call
(
'module:publish'
,
[
'module'
=>
'Core'
]);
}
/**
* Configuring the database information
*/
private
function
configureDatabase
()
{
// Ask for credentials
$databaseName
=
$this
->
ask
(
'Enter your database name'
);
$databaseUsername
=
$this
->
ask
(
'Enter your database username'
);
$databasePassword
=
$this
->
secret
(
'Enter your database password'
);
$this
->
setLaravelConfiguration
(
$databaseName
,
$databaseUsername
,
$databasePassword
);
$this
->
configureEnvironmentFile
(
$databaseName
,
$databaseUsername
,
$databasePassword
);
}
/**
* Writing the environment file
* @param $databaseName
* @param $databaseUsername
* @param $databasePassword
*/
private
function
configureEnvironmentFile
(
$databaseName
,
$databaseUsername
,
$databasePassword
)
{
Dotenv
::
makeMutable
();
$environmentFile
=
$this
->
finder
->
get
(
'.env.example'
);
$search
=
[
"DB_USERNAME=homestead"
,
"DB_PASSWORD=homestead"
];
/**
* Symfony style block messages
* @param $title
* @param $message
* @param string $style
*/
protected
function
blockMessage
(
$title
,
$message
,
$style
=
'info'
)
{
$formatter
=
$this
->
getHelperSet
()
->
get
(
'formatter'
);
$errorMessages
=
[
$title
,
$message
];
$formattedBlock
=
$formatter
->
formatBlock
(
$errorMessages
,
$style
,
true
);
$this
->
line
(
$formattedBlock
);
}
/**
* Publish the CMS assets
*/
private
function
publishAssets
()
{
$this
->
call
(
'module:publish'
,
[
'module'
=>
'Core'
]);
}
/**
* Configuring the database information
*/
private
function
configureDatabase
()
{
// Ask for credentials
$databaseName
=
$this
->
ask
(
'Enter your database name'
);
$databaseUsername
=
$this
->
ask
(
'Enter your database username'
);
$databasePassword
=
$this
->
secret
(
'Enter your database password'
);
$this
->
setLaravelConfiguration
(
$databaseName
,
$databaseUsername
,
$databasePassword
);
$this
->
configureEnvironmentFile
(
$databaseName
,
$databaseUsername
,
$databasePassword
);
}
/**
* Writing the environment file
* @param $databaseName
* @param $databaseUsername
* @param $databasePassword
*/
private
function
configureEnvironmentFile
(
$databaseName
,
$databaseUsername
,
$databasePassword
)
{
Dotenv
::
makeMutable
();
$environmentFile
=
$this
->
finder
->
get
(
'.env.example'
);
$search
=
[
"DB_USERNAME=homestead"
,
"DB_PASSWORD=homestead"
];
$replace
=
[
"DB_USERNAME=
$databaseUsername
"
,
"DB_PASSWORD=
$databasePassword
"
.
PHP_EOL
];
$newEnvironmentFile
=
str_replace
(
$search
,
$replace
,
$environmentFile
);
$newEnvironmentFile
.=
"DB_NAME=
$databaseName
"
;
// Write the new environment file
$this
->
finder
->
put
(
'.env'
,
$newEnvironmentFile
);
// Delete the old environment file
$this
->
finder
->
delete
(
'env.example'
);
$this
->
info
(
'Environment file written'
);
Dotenv
::
makeImmutable
();
}
/**
* Set DB credentials to laravel config
* @param $databaseName
* @param $databaseUsername
* @param $databasePassword
*/
private
function
setLaravelConfiguration
(
$databaseName
,
$databaseUsername
,
$databasePassword
)
{
$this
->
laravel
[
'config'
][
'database.connections.mysql.database'
]
=
$databaseName
;
$this
->
laravel
[
'config'
][
'database.connections.mysql.username'
]
=
$databaseUsername
;
$this
->
laravel
[
'config'
][
'database.connections.mysql.password'
]
=
$databasePassword
;
}
$replace
=
[
"DB_USERNAME=
$databaseUsername
"
,
"DB_PASSWORD=
$databasePassword
"
.
PHP_EOL
];
$newEnvironmentFile
=
str_replace
(
$search
,
$replace
,
$environmentFile
);
$newEnvironmentFile
.=
"DB_NAME=
$databaseName
"
;
// Write the new environment file
$this
->
finder
->
put
(
'.env'
,
$newEnvironmentFile
);
// Delete the old environment file
$this
->
finder
->
delete
(
'env.example'
);
$this
->
info
(
'Environment file written'
);
Dotenv
::
makeImmutable
();
}
/**
* Set DB credentials to laravel config
* @param $databaseName
* @param $databaseUsername
* @param $databasePassword
*/
private
function
setLaravelConfiguration
(
$databaseName
,
$databaseUsername
,
$databasePassword
)
{
$this
->
laravel
[
'config'
][
'database.connections.mysql.database'
]
=
$databaseName
;
$this
->
laravel
[
'config'
][
'database.connections.mysql.username'
]
=
$databaseUsername
;
$this
->
laravel
[
'config'
][
'database.connections.mysql.password'
]
=
$databasePassword
;
}
}
Modules/Core/Contracts/Authentication.php
View file @
5860e1b7
...
...
@@ -61,4 +61,11 @@ interface Authentication
* @return bool
*/
public
function
completeResetPassword
(
$user
,
$code
,
$password
);
/**
* Determines if the current user has access to given permission
* @param $permission
* @return bool
*/
public
function
hasAccess
(
$permission
);
}
Modules/Core/Resources/views/partials/sidebar-nav.blade.php
View file @
5860e1b7
...
...
@@ -6,26 +6,32 @@
<?php
$items
=
\Modules\Core\Navigation\NavigationOrdener
::
order
(
$items
);
?>
<?php
foreach
(
$items
as
$i
=>
$item
)
:
?>
<?php
if
(
is_object
(
$item
))
:
?>
<li
class=
"treeview {{ $item[0]['request'] ? 'active' : ''}}"
>
<a
href=
"#"
>
<i
class=
"{{ $item[0]['icon-class'] }}"
></i>
<span>
{{ $item[0]['title'] }}
</span>
<i
class=
"fa fa-angle-left pull-right"
></i>
</a>
<?php
$item
->
shift
();
?>
<ul
class=
"treeview-menu"
>
<?php
foreach
(
$item
as
$subItem
)
:
?>
<li
class=
"{{ Request::is($subItem['request']) ? 'active' : ''}}"
>
<a
href=
"{{ URL::route($subItem['route']) }}"
><i
class=
"{{$subItem['icon-class']}}"
></i>
{{ $subItem['title'] }}
</a>
</li>
<?php
endforeach
;
?>
</ul>
</li>
<?php
if
(
$item
[
0
][
'permission'
])
:
?>
<li
class=
"treeview {{ $item[0]['request'] ? 'active' : ''}}"
>
<a
href=
"#"
>
<i
class=
"{{ $item[0]['icon-class'] }}"
></i>
<span>
{{ $item[0]['title'] }}
</span>
<i
class=
"fa fa-angle-left pull-right"
></i>
</a>
<?php
$item
->
shift
();
?>
<ul
class=
"treeview-menu"
>
<?php
foreach
(
$item
as
$subItem
)
:
?>
<?php
if
(
$subItem
[
'permission'
])
:
?>
<li
class=
"{{ Request::is($subItem['request']) ? 'active' : ''}}"
>
<a
href=
"{{ URL::route($subItem['route']) }}"
><i
class=
"{{$subItem['icon-class']}}"
></i>
{{ $subItem['title'] }}
</a>
</li>
<?php
endif
;
?>
<?php
endforeach
;
?>
</ul>
</li>
<?php
endif
;
?>
<?php
else
:
?>
<li
class=
"{{ Request::is($item['request']) ? 'active' : ''}}"
>
<a
href=
"{{ URL::route($item['route']) }}"
>
<i
class=
"{{ $item['icon-class'] }}"
></i>
<span>
{{ $item['title'] }}
</span>
</a>
</li>
<?php
if
(
$item
[
'permission'
])
:
?>
<li
class=
"{{ Request::is($item['request']) ? 'active' : ''}}"
>
<a
href=
"{{ URL::route($item['route']) }}"
>
<i
class=
"{{ $item['icon-class'] }}"
></i>
<span>
{{ $item['title'] }}
</span>
</a>
</li>
<?php
endif
;
?>
<?php
endif
;
?>
<?php
endforeach
;
?>
</ul>
...
...
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