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
35b8c056
Commit
35b8c056
authored
Sep 26, 2014
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add core module that cannot be disabled
parent
664f11eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
8 deletions
+47
-8
ModulesController.php
Http/Controllers/ModulesController.php
+46
-7
index.blade.php
Resources/views/admin/modules/index.blade.php
+1
-1
No files found.
Http/Controllers/ModulesController.php
View file @
35b8c056
<?php
namespace
Modules\Workshop\Http\Controllers
;
use
Illuminate\Support\Facades\Config
;
use
Illuminate\Support\Facades\Redirect
;
use
Illuminate\Support\Facades\View
;
use
Laracasts\Flash\Flash
;
...
...
@@ -23,14 +24,14 @@ class ModulesController extends AdminBaseController
public
function
index
()
{
$modules
=
$this
->
module
->
all
();
$coreModules
=
$this
->
getCoreModules
();
return
View
::
make
(
'workshop::admin.modules.index'
,
compact
(
'modules'
));
return
View
::
make
(
'workshop::admin.modules.index'
,
compact
(
'modules'
,
'coreModules'
));
}
public
function
store
(
ModulesRequest
$request
)
{
$enabledModules
=
$this
->
module
->
enabled
();
$enabledModules
=
array_flip
(
$enabledModules
);
$enabledModules
=
$this
->
getFlippedEnabledModules
();
$modules
=
$request
->
modules
;
foreach
(
$modules
as
$module
=>
$value
)
{
...
...
@@ -40,15 +41,53 @@ class ModulesController extends AdminBaseController
}
}
// Disabled not needed modules
$this
->
disableModules
(
$enabledModules
);
// Enable new modules
$this
->
enableModules
(
$modules
);
Flash
::
success
(
'Modules configuration saved!'
);
return
Redirect
::
route
(
'dashboard.modules.index'
);
}
/**
* @return array
*/
private
function
getCoreModules
()
{
$coreModules
=
Config
::
get
(
'core::config.CoreModules'
);
$coreModules
=
array_flip
(
$coreModules
);
return
$coreModules
;
}
/**
* @return array
*/
private
function
getFlippedEnabledModules
()
{
$enabledModules
=
$this
->
module
->
enabled
();
$enabledModules
=
array_flip
(
$enabledModules
);
return
$enabledModules
;
}
private
function
disableModules
(
$enabledModules
)
{
$coreModules
=
$this
->
getCoreModules
();
foreach
(
$enabledModules
as
$moduleToDisable
=>
$value
)
{
if
(
isset
(
$coreModules
[
$moduleToDisable
]))
{
continue
;
}
$this
->
module
->
disable
(
$moduleToDisable
);
}
// Enable new modules
}
/**
* @param $modules
*/
private
function
enableModules
(
$modules
)
{
foreach
(
$modules
as
$moduleToEnable
=>
$value
)
{
$this
->
module
->
enable
(
$moduleToEnable
);
}
Flash
::
success
(
'Modules configuration saved!'
);
return
Redirect
::
route
(
'dashboard.modules.index'
);
}
}
\ No newline at end of file
Resources/views/admin/modules/index.blade.php
View file @
35b8c056
...
...
@@ -30,7 +30,7 @@
<li>
<div class="
checkbox
">
<label for="
{{
$module
}}
">
<input id="
{{
$module
}}
" name="
modules
[{{
$module
}}]
" type="
checkbox
" class="
flat
-
blue
" <?php echo Module::active(
$module
) ? 'checked' : '' ?> value="
true
" /> {{
$module
}}
<input id="
{{
$module
}}
" name="
modules
[{{
$module
}}]
" type="
checkbox
" class="
flat
-
blue
" <?php echo Module::active(
$module
) ? 'checked' : '' ?>
<?php echo isset(
$coreModules[$module]
) ? 'disabled' : ''; ?>
value="
true
" /> {{
$module
}}
</label>
</div>
</li>
...
...
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