1
|
|
|
<?php |
2
|
|
|
namespace TheCodingMachine\CMS\StaticRegistry\DI; |
3
|
|
|
|
4
|
|
|
use Psr\Container\ContainerInterface; |
5
|
|
|
use Psr\SimpleCache\CacheInterface; |
6
|
|
|
use TheCodingMachine\CMS\StaticRegistry\Registry\BlockRegistry; |
7
|
|
|
use TheCodingMachine\CMS\StaticRegistry\Registry\PageRegistry; |
8
|
|
|
use TheCodingMachine\CMS\StaticRegistry\Registry\StaticRegistry; |
9
|
|
|
use TheCodingMachine\CMS\StaticRegistry\Registry\ThemeRegistry; |
10
|
|
|
use TheCodingMachine\Funky\Annotations\Factory; |
11
|
|
|
use TheCodingMachine\Funky\ServiceProvider; |
12
|
|
|
|
13
|
|
|
class StaticRegistryServiceProvider extends ServiceProvider |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @Factory() |
17
|
|
|
*/ |
18
|
|
|
public static function getStaticRegistry(PageRegistry $pageRegistry, ThemeRegistry $themeRegistry): StaticRegistry |
19
|
|
|
{ |
20
|
|
|
return new StaticRegistry($pageRegistry, $themeRegistry); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @Factory() |
25
|
|
|
*/ |
26
|
|
|
public static function getPageRegistry(string $PAGES_DIRECTORY, CacheInterface $cache): PageRegistry |
27
|
|
|
{ |
28
|
|
|
return new PageRegistry($PAGES_DIRECTORY, $cache); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @Factory() |
33
|
|
|
*/ |
34
|
|
|
public static function getThemeRegistry(string $THEMES_DIRECTORY, string $SUBTHEMES_DIRECTORY, ContainerInterface $container, CacheInterface $cache, BlockRegistry $blockRegistry): ThemeRegistry |
35
|
|
|
{ |
36
|
|
|
return new ThemeRegistry($THEMES_DIRECTORY, $SUBTHEMES_DIRECTORY, $container, $cache, $blockRegistry); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @Factory() |
41
|
|
|
*/ |
42
|
|
|
public static function getBlockRegistry(string $BLOCKS_DIRECTORY, ContainerInterface $container, CacheInterface $cache): BlockRegistry |
43
|
|
|
{ |
44
|
|
|
return new BlockRegistry($BLOCKS_DIRECTORY, $container, $cache); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @Factory(name="PAGES_DIRECTORY") |
49
|
|
|
*/ |
50
|
|
|
public static function getPagesDirectory(string $CMS_ROOT): string |
51
|
|
|
{ |
52
|
|
|
return $CMS_ROOT.'/pages'; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @Factory(name="THEMES_DIRECTORY") |
57
|
|
|
*/ |
58
|
|
|
public static function getThemesDirectory(string $CMS_ROOT): string |
59
|
|
|
{ |
60
|
|
|
return $CMS_ROOT.'/themes'; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @Factory(name="SUBTHEMES_DIRECTORY") |
65
|
|
|
*/ |
66
|
|
|
public static function getSubthemesDirectory(string $CMS_ROOT): string |
67
|
|
|
{ |
68
|
|
|
return $CMS_ROOT.'/sub_themes'; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @Factory(name="BLOCKS_DIRECTORY") |
73
|
|
|
*/ |
74
|
|
|
public static function getBlocksDirectory(string $CMS_ROOT): string |
75
|
|
|
{ |
76
|
|
|
return $CMS_ROOT.'/blocks'; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|