Refactor CDN assets URL to separate service

[MAILPOET-3076]
This commit is contained in:
Rostislav Wolny
2020-09-02 16:50:28 +02:00
committed by Veljko V
parent e7206193e8
commit 6fb755eda7
5 changed files with 47 additions and 9 deletions

18
lib/Util/CdnAssetUrl.php Normal file
View File

@@ -0,0 +1,18 @@
<?php
namespace MailPoet\Util;
class CdnAssetUrl {
const CDN_URL = 'https://ps.w.org/mailpoet/';
/** @var string */
private $baseUrl;
public function __construct(string $baseUrl) {
$this->baseUrl = $baseUrl;
}
public function generateCdnUrl($path) {
$useCdn = defined('MAILPOET_USE_CDN') ? MAILPOET_USE_CDN : true;
return ($useCdn ? self::CDN_URL : $this->baseUrl . '/plugin_repository/') . "assets/$path";
}
}