1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Spiral Framework. |
4
|
|
|
* |
5
|
|
|
* @license MIT |
6
|
|
|
* @author Anton Titov (Wolfy-J) |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Spiral\Framework\Bootloaders; |
10
|
|
|
|
11
|
|
|
use Spiral\Config\ConfigFactory; |
12
|
|
|
use Spiral\Config\Loaders\DirectoryLoader; |
13
|
|
|
use Spiral\Core\Bootloaders\Bootloader; |
14
|
|
|
use Spiral\Core\ConfiguratorInterface; |
15
|
|
|
use Spiral\Core\FactoryInterface; |
16
|
|
|
use Spiral\Core\MemoryInterface; |
17
|
|
|
use Spiral\Files\Files; |
18
|
|
|
use Spiral\Files\FilesInterface; |
19
|
|
|
use Spiral\Framework\DirectoriesInterface; |
20
|
|
|
use Spiral\Framework\Memory; |
21
|
|
|
|
22
|
|
|
final class CoreBootloader extends Bootloader |
23
|
|
|
{ |
24
|
|
|
const SINGLETONS = [ |
25
|
|
|
FilesInterface::class => Files::class, |
26
|
|
|
MemoryInterface::class => [self::class, 'memory'], |
27
|
|
|
ConfiguratorInterface::class => [self::class, 'configFactory'], |
28
|
|
|
]; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @param DirectoriesInterface $directories |
32
|
|
|
* @param FactoryInterface $factory |
33
|
|
|
* @return ConfiguratorInterface |
34
|
|
|
*/ |
35
|
|
|
protected function configFactory( |
36
|
|
|
DirectoriesInterface $directories, |
37
|
|
|
FactoryInterface $factory |
38
|
|
|
): ConfiguratorInterface { |
39
|
|
|
return new ConfigFactory(new DirectoryLoader($directories->get('config'), $factory), true); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param DirectoriesInterface $directories |
44
|
|
|
* @param FilesInterface $files |
45
|
|
|
* @return MemoryInterface |
46
|
|
|
*/ |
47
|
|
|
protected function memory( |
48
|
|
|
DirectoriesInterface $directories, |
49
|
|
|
FilesInterface $files |
50
|
|
|
): MemoryInterface { |
51
|
|
|
return new Memory($directories->get('cache'), $files); |
52
|
|
|
} |
53
|
|
|
} |