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
93cd5bd3
Commit
93cd5bd3
authored
Dec 05, 2016
by
Andrew Bekesh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add required minimum for extra view namespaces to work
parent
d08fe1de
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
131 additions
and
52 deletions
+131
-52
config.php
Modules/Core/Config/config.php
+20
-0
core.php
Modules/Core/Config/core.php
+43
-36
CoreServiceProvider.php
Modules/Core/Providers/CoreServiceProvider.php
+61
-16
helpers.php
Modules/Core/helpers.php
+7
-0
No files found.
Modules/Core/Config/config.php
View file @
93cd5bd3
...
@@ -14,4 +14,24 @@ return [
...
@@ -14,4 +14,24 @@ return [
'setting'
,
'setting'
,
'media'
,
'media'
,
],
],
/*
|--------------------------------------------------------------------------
| Load additional view namespaces for a module
|--------------------------------------------------------------------------
| You can specify place from which you would like to use module views.
| You can use any combination, but generally it's advisable to add only one,
| extra view namespace.
| Available places are: from within your current backend theme, from within
| your current frontend theme and from resources folder.
| By default every extra namespace will be set to false.
*/
'useViewNamespaces'
=>
[
// Read module views from /Themes/<backend-theme-name>/views/modules/asgard/<module-name>
'backend-theme'
=>
false
,
// Read module views from /Themes/<frontend-theme-name>/views/modules/asgard/<module-name>
'frontend-theme'
=>
false
,
// Read module views from /resources/views/asgard/<module-name>
'resources'
=>
false
,
],
];
];
Modules/Core/Config/core.php
View file @
93cd5bd3
...
@@ -148,4 +148,11 @@ return [
...
@@ -148,4 +148,11 @@ return [
'main.js'
,
'main.js'
,
],
],
],
],
/*
|--------------------------------------------------------------------------
| Enable module view overrides at theme locations
|--------------------------------------------------------------------------
*/
'enable-theme-overrides'
=>
false
,
];
];
Modules/Core/Providers/CoreServiceProvider.php
View file @
93cd5bd3
...
@@ -23,11 +23,6 @@ class CoreServiceProvider extends ServiceProvider
...
@@ -23,11 +23,6 @@ class CoreServiceProvider extends ServiceProvider
*/
*/
protected
$defer
=
false
;
protected
$defer
=
false
;
/**
* @var string
*/
protected
$prefix
=
'asgard'
;
/**
/**
* The filters base class name.
* The filters base class name.
*
*
...
@@ -45,15 +40,15 @@ class CoreServiceProvider extends ServiceProvider
...
@@ -45,15 +40,15 @@ class CoreServiceProvider extends ServiceProvider
public
function
boot
()
public
function
boot
()
{
{
$this
->
registerMiddleware
(
$this
->
app
[
'router'
]);
$this
->
registerModuleResourceNamespaces
();
$this
->
publishConfig
(
'core'
,
'available-locales'
);
$this
->
publishConfig
(
'core'
,
'available-locales'
);
$this
->
publishConfig
(
'core'
,
'config'
);
$this
->
publishConfig
(
'core'
,
'config'
);
$this
->
publishConfig
(
'core'
,
'core'
);
$this
->
publishConfig
(
'core'
,
'core'
);
$this
->
publishConfig
(
'core'
,
'settings'
);
$this
->
publishConfig
(
'core'
,
'settings'
);
$this
->
publishConfig
(
'core'
,
'permissions'
);
$this
->
publishConfig
(
'core'
,
'permissions'
);
$this
->
registerMiddleware
(
$this
->
app
[
'router'
]);
$this
->
registerModuleResourceNamespaces
();
$this
->
bladeDirectives
();
$this
->
bladeDirectives
();
}
}
...
@@ -119,6 +114,24 @@ class CoreServiceProvider extends ServiceProvider
...
@@ -119,6 +114,24 @@ class CoreServiceProvider extends ServiceProvider
return
new
ThemeManager
(
$app
,
$path
);
return
new
ThemeManager
(
$app
,
$path
);
});
});
$this
->
app
->
singleton
(
'asgard.ModulesList'
,
function
()
{
return
[
'block'
,
'blog'
,
'core'
,
'dashboard'
,
'media'
,
'menu'
,
'notification'
,
'page'
,
'setting'
,
'tag'
,
'translation'
,
'user'
,
'workshop'
,
];
});
}
}
/**
/**
...
@@ -126,8 +139,20 @@ class CoreServiceProvider extends ServiceProvider
...
@@ -126,8 +139,20 @@ class CoreServiceProvider extends ServiceProvider
*/
*/
private
function
registerModuleResourceNamespaces
()
private
function
registerModuleResourceNamespaces
()
{
{
$themes
=
[];
// Saves about 20ms-30ms at loading
if
(
$this
->
app
[
'config'
]
->
get
(
'asgard.core.core.enable-theme-overrides'
)
===
true
)
{
$themeManager
=
app
(
ThemeManager
::
class
);
$themes
=
[
'backend'
=>
$themeManager
->
find
(
config
(
'asgard.core.core.admin-theme'
))
->
getPath
(),
'frontend'
=>
$themeManager
->
find
(
setting
(
'core::template'
,
null
,
'Flatly'
))
->
getPath
(),
];
}
foreach
(
$this
->
app
[
'modules'
]
->
getOrdered
()
as
$module
)
{
foreach
(
$this
->
app
[
'modules'
]
->
getOrdered
()
as
$module
)
{
$this
->
registerViewNamespace
(
$module
);
$this
->
registerViewNamespace
(
$module
,
$themes
);
$this
->
registerLanguageNamespace
(
$module
);
$this
->
registerLanguageNamespace
(
$module
);
}
}
}
}
...
@@ -135,16 +160,36 @@ class CoreServiceProvider extends ServiceProvider
...
@@ -135,16 +160,36 @@ class CoreServiceProvider extends ServiceProvider
/**
/**
* Register the view namespaces for the modules
* Register the view namespaces for the modules
* @param Module $module
* @param Module $module
* @param array $themes
*/
*/
protected
function
registerViewNamespace
(
Module
$module
)
protected
function
registerViewNamespace
(
Module
$module
,
array
$themes
)
{
{
if
(
$module
->
getLowerName
()
==
'user'
)
{
$hints
=
[];
return
;
$moduleName
=
$module
->
getLowerName
();
if
(
is_core_module
(
$moduleName
))
{
$configFile
=
'config'
;
$configKey
=
'asgard.'
.
$moduleName
.
'.'
.
$configFile
;
$this
->
mergeConfigFrom
(
$module
->
getExtraPath
(
'Config'
.
DIRECTORY_SEPARATOR
.
$configFile
.
'.php'
),
$configKey
);
$moduleConfig
=
$this
->
app
[
'config'
]
->
get
(
$configKey
.
'.useViewNamespaces'
);
if
(
count
(
$themes
)
>
0
)
{
if
(
$themes
[
'backend'
]
!==
null
&&
array_get
(
$moduleConfig
,
'backend-theme'
)
===
true
)
{
$hints
[]
=
$themes
[
'backend'
]
.
'/views/modules/asgard/'
.
$moduleName
;
}
}
$this
->
app
[
'view'
]
->
addNamespace
(
if
(
$themes
[
'frontend'
]
!==
null
&&
array_get
(
$moduleConfig
,
'frontend-theme'
)
===
true
)
{
$module
->
getLowerName
(),
$hints
[]
=
$themes
[
'frontend'
]
.
'/views/modules/asgard/'
.
$moduleName
;
$module
->
getPath
()
.
'/Resources/views'
}
);
}
if
(
array_get
(
$moduleConfig
,
'resources'
)
===
true
)
{
$hints
[]
=
base_path
(
'resources/views/asgard/'
.
$moduleName
);
}
}
$hints
[]
=
$module
->
getPath
()
.
'/Resources/views'
;
$this
->
app
[
'view'
]
->
addNamespace
(
$moduleName
,
$hints
);
}
}
/**
/**
...
...
Modules/Core/helpers.php
View file @
93cd5bd3
...
@@ -26,3 +26,10 @@ if (! function_exists('is_module_enabled')) {
...
@@ -26,3 +26,10 @@ if (! function_exists('is_module_enabled')) {
return
array_key_exists
(
$module
,
app
(
'modules'
)
->
enabled
());
return
array_key_exists
(
$module
,
app
(
'modules'
)
->
enabled
());
}
}
}
}
if
(
!
function_exists
(
'is_core_module'
))
{
function
is_core_module
(
$module
)
{
return
in_array
(
strtolower
(
$module
),
app
(
'asgard.ModulesList'
));
}
}
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