mirror of
https://github.com/Icinga/icinga-php-library.git
synced 2025-07-21 20:54:37 +02:00
AssetLoader: Load fontawesome files
This commit is contained in:
parent
98f54c7607
commit
8b4549275b
@ -2,6 +2,11 @@
|
||||
|
||||
class AssetLoader
|
||||
{
|
||||
public static $awesomeVendorFiles = [
|
||||
'asset/static/font/awesome' => 'vendor/fortawesome/font-awesome/webfonts',
|
||||
'asset/css' => 'vendor/fortawesome/font-awesome/css/fontawesome.css'
|
||||
];
|
||||
|
||||
public static function update()
|
||||
{
|
||||
if (is_dir('asset')) {
|
||||
@ -48,5 +53,35 @@ class AssetLoader
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Register font-awesome files as assets
|
||||
foreach (static::$awesomeVendorFiles as $targetPath => $sourcePath) {
|
||||
$sourcePath = realpath($sourcePath);
|
||||
if (! $sourcePath) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_dir($sourcePath)) {
|
||||
if (! is_dir($targetPath)) {
|
||||
mkdir($targetPath, 0755, true);
|
||||
}
|
||||
|
||||
$awesomeFiles = new FilesystemIterator($sourcePath);
|
||||
} else { // is_file($sourcePath)
|
||||
$awesomeFiles = [new SplFileInfo($sourcePath)];
|
||||
$sourcePath = $awesomeFiles[0]->getPath();
|
||||
}
|
||||
|
||||
foreach ($awesomeFiles as $awesomeFile) {
|
||||
/** @var SplFileInfo $awesomeFile */
|
||||
$relativePath = join(DIRECTORY_SEPARATOR, [$targetPath, ltrim(
|
||||
substr($awesomeFile->getPathname(), strlen($sourcePath)),
|
||||
'/\\'
|
||||
)]);
|
||||
if (! file_exists($relativePath) && $awesomeFile->isFile()) {
|
||||
symlink($awesomeFile->getPathname(), $relativePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user