1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AlxRoot; |
4
|
|
|
|
5
|
|
|
abstract class Installer |
6
|
|
|
{ |
7
|
|
|
public static function copyAssets() |
8
|
|
|
{ |
9
|
|
|
echo "Starting copyAssets...\n"; |
10
|
|
|
|
11
|
|
|
if (getenv('SKIP_COPY_ASSETS')) { |
12
|
|
|
echo "Prevented copyAssets in scrutinizer environment.\n"; |
13
|
|
|
return; |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
$source = realpath(__DIR__ . '/../assets'); |
17
|
|
|
if ($source === false) { |
18
|
|
|
echo "Source directory does not exist.\n"; |
19
|
|
|
return; |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
$target = realpath(__DIR__ . '/../../../../public/alxarafe'); |
23
|
|
|
if ($target === false) { |
24
|
|
|
$target = __DIR__ . '/../../../../public/alxarafe'; |
25
|
|
|
if (!mkdir($target, 0777, true) && !is_dir($target)) { |
26
|
|
|
echo "Failed to create target directory: $target\n"; |
27
|
|
|
return; |
28
|
|
|
} |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
echo "Copying assets from $source to $target...\n"; |
32
|
|
|
static::copyAssetsFolder($source, $target, 'css'); |
33
|
|
|
static::copyAssetsFolder($source, $target, 'js'); |
34
|
|
|
static::copyAssetsFolder($source, $target, 'img'); |
35
|
|
|
echo "Assets copied successfully.\n"; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
private static function copyAssetsFolder($baseDir, $publicDir, $extension) |
39
|
|
|
{ |
40
|
|
|
$dir = $baseDir . '/assets/' . $extension; |
41
|
|
|
if (!is_dir($dir)) { |
42
|
|
|
echo "Directory $dir does not exist.\n"; |
43
|
|
|
return; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
$targetDir = $publicDir . '/' . $extension; |
47
|
|
|
if (!is_dir($targetDir)) { |
48
|
|
|
if (!mkdir($targetDir, 0777, true) && !is_dir($targetDir)) { |
49
|
|
|
echo "Failed to create directory: $targetDir\n"; |
50
|
|
|
return; |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
foreach (glob($dir . '/*.' . $extension) as $file) { |
55
|
|
|
if (!copy($file, $publicDir . '/' . $extension . '/' . basename($file))) { |
56
|
|
|
echo "Failed to copy $file to $targetDir.\n"; |
57
|
|
|
return; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
echo "Directory $dir copied successfully.\n"; |
62
|
|
|
} |
63
|
|
|
} |