Some checks are pending
Telegram Mini App Shop Builder / Compute version metadata (push) Waiting to run
Telegram Mini App Shop Builder / Run Frontend tests (push) Waiting to run
Telegram Mini App Shop Builder / Run Backend tests (push) Waiting to run
Telegram Mini App Shop Builder / Run PHP_CodeSniffer (push) Waiting to run
Telegram Mini App Shop Builder / Build module. (push) Blocked by required conditions
Telegram Mini App Shop Builder / release (push) Blocked by required conditions
41 lines
1.0 KiB
PHP
41 lines
1.0 KiB
PHP
<?php
|
|
|
|
$module = 'acmeshop';
|
|
|
|
$basePath = dirname(__DIR__) . '/';
|
|
|
|
if ($basePath === '//') {
|
|
$basePath = '/';
|
|
}
|
|
|
|
$modulesPath = $basePath . 'module/';
|
|
$modulePath = $modulesPath . $module . '/upload/';
|
|
|
|
$files = [];
|
|
|
|
$iterator = new RecursiveDirectoryIterator($modulePath);
|
|
$recursiveIterator = new RecursiveIteratorIterator($iterator);
|
|
|
|
/** @var SplFileInfo $file */
|
|
foreach ($recursiveIterator as $file) {
|
|
if ($file->isFile() && fnmatch($pattern = '*', $file->getFilename())) {
|
|
$files[] = $file->getRealPath();
|
|
}
|
|
}
|
|
|
|
foreach ($files as $file) {
|
|
$link = $basePath . 'web/upload/' . str_replace($modulePath, '', $file);
|
|
|
|
if (! is_dir(dirname($link))) {
|
|
if (!mkdir($concurrentDirectory = dirname($link), 0775, true) && !is_dir($concurrentDirectory)) {
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory));
|
|
}
|
|
}
|
|
|
|
echo sprintf('%s => %s', $file, $link) . PHP_EOL;
|
|
|
|
@unlink($link);
|
|
symlink($file, $link);
|
|
chmod($link, 0777);
|
|
}
|