mirror of
https://github.com/humhub/humhub.git
synced 2025-01-19 07:08:06 +01:00
Module Asset Management use asset path instead of file path to determine published url
This commit is contained in:
parent
314b5f616e
commit
1ffa682c2d
@ -120,16 +120,31 @@ class Module extends \yii\base\Module
|
|||||||
*/
|
*/
|
||||||
public function getPublishedUrl($relativePath)
|
public function getPublishedUrl($relativePath)
|
||||||
{
|
{
|
||||||
$path = $this->getAssetPath().$relativePath;
|
$path = $this->getAssetPath();
|
||||||
|
|
||||||
$publishedPath = Yii::$app->assetManager->getPublishedPath($path);
|
// If the file has not been published yet we publish the module assets
|
||||||
|
if(!$this->isPublished($relativePath)) {
|
||||||
if($publishedPath === false || !is_file($publishedPath)) {
|
|
||||||
$this->publishAssets();
|
$this->publishAssets();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Yii::$app->assetManager->getPublishedUrl($path);
|
// If its still not published the file does not exist
|
||||||
|
if($this->isPublished($relativePath)) {
|
||||||
|
return Yii::$app->assetManager->getPublishedUrl($path).$relativePath;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a specific asset file has already been published
|
||||||
|
* @param type $relativePath
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
|
private function isPublished($relativePath)
|
||||||
|
{
|
||||||
|
$path = $this->getAssetPath();
|
||||||
|
$publishedPath = Yii::$app->assetManager->getPublishedPath($path);
|
||||||
|
return $publishedPath !== false && is_file($publishedPath.$relativePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Assets Url
|
* Get Assets Url
|
||||||
|
Loading…
x
Reference in New Issue
Block a user