30 lines
870 B
PHP
30 lines
870 B
PHP
|
|
<?php
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace Phred\Providers\Core;
|
||
|
|
|
||
|
|
use DI\Container;
|
||
|
|
use DI\ContainerBuilder;
|
||
|
|
use League\Flysystem\Filesystem;
|
||
|
|
use League\Flysystem\Local\LocalFilesystemAdapter;
|
||
|
|
use Phred\Support\Contracts\ConfigInterface;
|
||
|
|
use Phred\Support\Contracts\ServiceProviderInterface;
|
||
|
|
|
||
|
|
final class StorageServiceProvider implements ServiceProviderInterface
|
||
|
|
{
|
||
|
|
public function register(ContainerBuilder $builder, ConfigInterface $config): void
|
||
|
|
{
|
||
|
|
$builder->addDefinitions([
|
||
|
|
'storage.local.root' => getcwd() . '/storage',
|
||
|
|
|
||
|
|
Filesystem::class => function (Container $c) {
|
||
|
|
$root = $c->get('storage.local.root');
|
||
|
|
$adapter = new LocalFilesystemAdapter($root);
|
||
|
|
return new Filesystem($adapter);
|
||
|
|
},
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function boot(Container $container): void {}
|
||
|
|
}
|