Skip to content

Commit

Permalink
Improve asset manager and added min URL for common-css
Browse files Browse the repository at this point in the history
  • Loading branch information
puleeno committed Jan 1, 2024
1 parent 5393548 commit 65d49c1
Showing 4 changed files with 13 additions and 7 deletions.
5 changes: 3 additions & 2 deletions app/Core/Assets/CascadingStyleSheets.php
Original file line number Diff line number Diff line change
@@ -13,10 +13,11 @@ public function renderHtml()
echo HookManager::applyFilters(
'print_css_html',
sprintf(
'<link rel="stylesheet" href="%1$s" type="text/css" />',
'<link id="%2$s-css" rel="stylesheet" href="%1$s" type="text/css" />',
HookManager::applyFilters("asset_css_url", $this->getUrl(
Env::get("COMPRESSED_ASSETS", Env::get("DEBUG") === false)
), $this->id, $this)
), $this->id, $this),
$this->id
),
$this->getId(),
$this
5 changes: 3 additions & 2 deletions app/Core/Assets/JavaScript.php
Original file line number Diff line number Diff line change
@@ -17,10 +17,11 @@ public function renderHtml()
echo HookManager::applyFilters(
'print_js_html',
sprintf(
'<script src="%1$s"></script>',
'<script id="%2$s-js" src="%1$s"></script>',
HookManager::applyFilters("asset_js_url", $this->getUrl(
Env::get("COMPRESSED_ASSETS", Env::get("DEBUG") === false)
), $this->id, $this)
), $this->id, $this),
$this->id
),
$this->getId(),
$this
6 changes: 5 additions & 1 deletion app/Core/ExternalAsset.php
Original file line number Diff line number Diff line change
@@ -16,12 +16,16 @@ public function setUrl(AssetUrl $url): self
return $this;
}

public function getUrl($supportMinUrl = false)
public function getUrl($supportMinUrl = null)
{
if (empty($this->url)) {
return "";
}

if (is_null($supportMinUrl)) {
$supportMinUrl = Env::get('COMPRESSED_ASSETS', !Env::get('DEBUG', false));
}

return $this->url->getUrl($supportMinUrl);
}
}
4 changes: 2 additions & 2 deletions app/bootstrap.php
Original file line number Diff line number Diff line change
@@ -158,8 +158,8 @@ protected function setup()
protected function initAssets()
{
AssetManager::registerAsset(
'common-css',
new AssetUrl('/extensions/common/assets/css/common.css'),
'common',
new AssetUrl('/extensions/common/assets/css/common.css', '/extensions/common/assets/css/common.min.css'),
AssetTypeEnum::CSS(),
[],
'1.0.0',

0 comments on commit 65d49c1

Please sign in to comment.