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
363ed194
Unverified
Commit
363ed194
authored
Jul 14, 2017
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create a CollectingAssets hook.
Page module hooking into CollectingAssets to add iCheck
parent
5f9684d4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
0 deletions
+83
-0
AssetsViewComposer.php
Modules/Core/Composers/AssetsViewComposer.php
+2
-0
CollectingAssets.php
Modules/Core/Events/CollectingAssets.php
+65
-0
PageServiceProvider.php
Modules/Page/Providers/PageServiceProvider.php
+16
-0
No files found.
Modules/Core/Composers/AssetsViewComposer.php
View file @
363ed194
...
...
@@ -4,6 +4,7 @@ namespace Modules\Core\Composers;
use
Illuminate\Contracts\View\View
;
use
Illuminate\Http\Request
;
use
Modules\Core\Events\CollectingAssets
;
use
Modules\Core\Events\EditorIsRendering
;
use
Modules\Core\Foundation\Asset\Manager\AssetManager
;
use
Modules\Core\Foundation\Asset\Pipeline\AssetPipeline
;
...
...
@@ -50,6 +51,7 @@ class AssetsViewComposer
$this
->
assetPipeline
->
requireJs
(
config
(
'asgard.core.core.admin-required-assets.js'
));
event
(
$editor
=
new
EditorIsRendering
(
$this
->
assetPipeline
));
event
(
new
CollectingAssets
(
$this
->
assetPipeline
));
$view
->
with
(
'cssFiles'
,
$this
->
assetPipeline
->
allCss
());
$view
->
with
(
'jsFiles'
,
$this
->
assetPipeline
->
allJs
());
...
...
Modules/Core/Events/CollectingAssets.php
0 → 100644
View file @
363ed194
<?php
namespace
Modules\Core\Events
;
use
Modules\Core\Foundation\Asset\Pipeline\AssetPipeline
;
class
CollectingAssets
{
/**
* @var AssetPipeline
*/
private
$assetPipeline
;
public
function
__construct
(
AssetPipeline
$assetPipeline
)
{
$this
->
assetPipeline
=
$assetPipeline
;
}
/**
* @param string $asset
* @return AssetPipeline
*/
public
function
requireJs
(
$asset
)
{
return
$this
->
assetPipeline
->
requireJs
(
$asset
);
}
/**
* @param string $asset
* @return AssetPipeline
*/
public
function
requireCss
(
$asset
)
{
return
$this
->
assetPipeline
->
requireCss
(
$asset
);
}
/**
* Match a single route
* @param string|array $route
* @return bool
*/
public
function
onRoute
(
$route
)
{
$request
=
request
();
return
str_is
(
$route
,
$request
->
route
()
->
getName
());
}
/**
* Match multiple routes
* @param array $routes
* @return bool
*/
public
function
onRoutes
(
array
$routes
)
{
$request
=
request
();
foreach
(
$routes
as
$route
)
{
if
(
str_is
(
$route
,
$request
->
route
()
->
getName
())
===
true
)
{
return
true
;
}
}
return
false
;
}
}
Modules/Page/Providers/PageServiceProvider.php
View file @
363ed194
...
...
@@ -4,6 +4,7 @@ namespace Modules\Page\Providers;
use
Illuminate\Support\Facades\Config
;
use
Illuminate\Support\ServiceProvider
;
use
Modules\Core\Events\CollectingAssets
;
use
Modules\Core\Traits\CanPublishConfiguration
;
use
Modules\Page\Entities\Page
;
use
Modules\Page\Repositories\Cache\CachePageDecorator
;
...
...
@@ -38,6 +39,8 @@ class PageServiceProvider extends ServiceProvider
$this
->
app
[
TagManager
::
class
]
->
registerNamespace
(
new
Page
());
$this
->
loadMigrationsFrom
(
__DIR__
.
'/../Database/Migrations'
);
$this
->
handleAssets
();
}
/**
...
...
@@ -69,4 +72,17 @@ class PageServiceProvider extends ServiceProvider
}
);
}
/**
* Require iCheck on edit and create pages
*/
private
function
handleAssets
()
{
$this
->
app
[
'events'
]
->
listen
(
CollectingAssets
::
class
,
function
(
CollectingAssets
$event
)
{
if
(
$event
->
onRoutes
([
'*page*create'
,
'*page*edit'
]))
{
$event
->
requireCss
(
'icheck.blue.css'
);
$event
->
requireJs
(
'icheck.js'
);
}
});
}
}
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