-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#6] Fix assets directly call using Url::assert
- Loading branch information
Showing
4 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Cyd293\BackendSkin; | ||
|
||
use Cyd293\BackendSkin\Router\UrlGenerator; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
class RoutingServiceProvider extends ServiceProvider | ||
{ | ||
public function register() | ||
{ | ||
$this->registerUrlGenerator(); | ||
} | ||
|
||
protected function registerUrlGenerator() | ||
{ | ||
$this->app->singleton('url', function ($app) { | ||
$routes = $app['router']->getRoutes(); | ||
$app->instance('routes', $routes); | ||
|
||
$url = new UrlGenerator( | ||
$routes, | ||
$app->rebinding( | ||
'request', | ||
$this->requestRebinder() | ||
) | ||
); | ||
|
||
$url->setSessionResolver(function () { | ||
return $this->app['session']; | ||
}); | ||
|
||
$app->rebinding('routes', function ($app, $routes) { | ||
$app['url']->setRoutes($routes); | ||
}); | ||
|
||
return $url; | ||
}); | ||
} | ||
|
||
protected function requestRebinder() | ||
{ | ||
return function ($app, $request) { | ||
$app['url']->setRequest($request); | ||
}; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Cyd293\BackendSkin\Router; | ||
|
||
use Backend\Classes\Skin as AbstractSkin; | ||
use October\Rain\Router\UrlGenerator as Base; | ||
use Cyd293\BackendSkin\Classes\Skin; | ||
|
||
class UrlGenerator extends Base | ||
{ | ||
public function asset($path, $secure = null) | ||
{ | ||
if (!starts_with($path, '/themes') && !starts_with($path, '/backendskins')) { | ||
$publicSkinAssetPath = $this->getActiveSkin()->publicSkinPath . '/views/' . ltrim($path, '/'); | ||
$skinAssetPath = $this->getActiveSkin()->skinPath . '/views/' . ltrim($path, '/'); | ||
if (file_exists($skinAssetPath)) { | ||
$path = $publicSkinAssetPath; | ||
} | ||
} | ||
return parent::asset($path, $secure); | ||
} | ||
|
||
/** | ||
* @return \Cyd293\BackendSkin\Skin\BackendSkin | ||
*/ | ||
private function getActiveSkin() | ||
{ | ||
return AbstractSkin::getActive(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ | |
1.1.0: | ||
- Add separation of backendskin and theme | ||
- Add new method on defining skin code | ||
1.1.1: | ||
- Fix Aseet Maker |