mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
8b6b196c99
* feat: migrate encoding scripts from github to platform * style: fix StyleCI finding * fix: don't concatenate updated videos when attempting to attach entry on video upload * fix(api): fix field dependencies & feat(admin): upload script from video detail screen
54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Repositories\Storage\Wiki\Video;
|
|
|
|
use App\Constants\Config\VideoConstants;
|
|
use App\Models\Wiki\Video\VideoScript;
|
|
use App\Repositories\Storage\StorageRepository;
|
|
use Closure;
|
|
use Illuminate\Support\Facades\Config;
|
|
use Illuminate\Support\Facades\File;
|
|
use League\Flysystem\StorageAttributes;
|
|
|
|
/**
|
|
* Class ScriptRepository.
|
|
*
|
|
* @extends StorageRepository<VideoScript>
|
|
*/
|
|
class ScriptRepository extends StorageRepository
|
|
{
|
|
/**
|
|
* The name of the disk.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function disk(): string
|
|
{
|
|
return Config::get(VideoConstants::SCRIPT_DISK_QUALIFIED);
|
|
}
|
|
|
|
/**
|
|
* Return the callback to filter filesystem contents.
|
|
*
|
|
* @return Closure(StorageAttributes): bool
|
|
*/
|
|
protected function filterCallback(): Closure
|
|
{
|
|
return fn (StorageAttributes $file) => $file->isFile() && File::extension($file->path()) === 'txt';
|
|
}
|
|
|
|
/**
|
|
* Map filesystem files to model.
|
|
*
|
|
* @return Closure(StorageAttributes): VideoScript
|
|
*/
|
|
protected function mapCallback(): Closure
|
|
{
|
|
return fn (StorageAttributes $file) => new VideoScript([
|
|
VideoScript::ATTRIBUTE_PATH => $file->path(),
|
|
]);
|
|
}
|
|
}
|