Skip to content

Commit

Permalink
Merge pull request #44 from craftcms/bugfix/fix-rebrand
Browse files Browse the repository at this point in the history
Fix rebrand assets
  • Loading branch information
timkelty authored May 31, 2024
2 parents 8d1a90d + 1f19d0c commit 7b0af77
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/web/AssetManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use craft\cloud\Helper;
use craft\cloud\Module;
use craft\helpers\FileHelper;
use craft\helpers\StringHelper;
use League\Uri\Components\HierarchicalPath;
use League\Uri\Modifier;

class AssetManager extends \craft\web\AssetManager
Expand Down Expand Up @@ -41,6 +43,16 @@ protected function preparePaths(): void
protected function hash($path): string
{
$dir = is_file($path) ? dirname($path) : $path;
$rebrandPath = Craft::$app->getPath()->getRebrandPath();

// Account for rebrand, as it lives in @storage by default,
// which will be different in Cloud runtime vs. Cloud build.
if (str_starts_with($dir, $rebrandPath)) {
return HierarchicalPath::new(StringHelper::removeLeft($dir, $rebrandPath))
->prepend('rebrand')
->withoutTrailingSlash()
->toString();
}

// @phpstan-ignore-next-line
$alias = Craft::alias($dir);
Expand Down
14 changes: 14 additions & 0 deletions src/web/assets/rebrand/RebrandAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace craft\cloud\web\assets\rebrand;

use Craft;

class RebrandAsset extends \craft\web\AssetBundle
{
public function init()
{
$this->sourcePath = Craft::$app->getPath()->getRebrandPath();
parent::init();
}
}

0 comments on commit 7b0af77

Please sign in to comment.