|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace AbterPhp\Website\Bootstrappers\Orm; |
|
6
|
|
|
|
|
7
|
|
|
use AbterPhp\Admin\Bootstrappers\Orm\OrmBootstrapper as AbterAdminOrmBootstrapper; |
|
8
|
|
|
use AbterPhp\Website\Domain\Entities\Block; |
|
9
|
|
|
use AbterPhp\Website\Domain\Entities\BlockLayout; |
|
10
|
|
|
use AbterPhp\Website\Domain\Entities\ContentList; |
|
11
|
|
|
use AbterPhp\Website\Domain\Entities\ContentListItem; |
|
12
|
|
|
use AbterPhp\Website\Domain\Entities\Page; |
|
13
|
|
|
use AbterPhp\Website\Domain\Entities\PageCategory; |
|
14
|
|
|
use AbterPhp\Website\Domain\Entities\PageLayout; |
|
15
|
|
|
use AbterPhp\Website\Orm\BlockLayoutRepo; |
|
16
|
|
|
use AbterPhp\Website\Orm\BlockRepo; |
|
17
|
|
|
use AbterPhp\Website\Orm\ContentListItemRepo; |
|
18
|
|
|
use AbterPhp\Website\Orm\ContentListRepo; |
|
19
|
|
|
use AbterPhp\Website\Orm\DataMappers\BlockLayoutSqlDataMapper; |
|
20
|
|
|
use AbterPhp\Website\Orm\DataMappers\BlockSqlDataMapper; |
|
21
|
|
|
use AbterPhp\Website\Orm\DataMappers\ContentListItemSqlDataMapper; |
|
22
|
|
|
use AbterPhp\Website\Orm\DataMappers\ContentListSqlDataMapper; |
|
23
|
|
|
use AbterPhp\Website\Orm\DataMappers\PageCategorySqlDataMapper; |
|
24
|
|
|
use AbterPhp\Website\Orm\DataMappers\PageLayoutSqlDataMapper; |
|
25
|
|
|
use AbterPhp\Website\Orm\DataMappers\PageSqlDataMapper; |
|
26
|
|
|
use AbterPhp\Website\Orm\PageCategoryRepo; |
|
27
|
|
|
use AbterPhp\Website\Orm\PageLayoutRepo; |
|
28
|
|
|
use AbterPhp\Website\Orm\PageRepo; |
|
29
|
|
|
use Opulence\Ioc\IContainer; |
|
30
|
|
|
use Opulence\Ioc\IocException; |
|
31
|
|
|
use Opulence\Orm\IUnitOfWork; |
|
32
|
|
|
use RuntimeException; |
|
33
|
|
|
|
|
34
|
|
|
class OrmBootstrapper extends AbterAdminOrmBootstrapper |
|
35
|
|
|
{ |
|
36
|
|
|
/** @var array */ |
|
37
|
|
|
protected $repoMappers = [ |
|
38
|
|
|
BlockLayoutRepo::class => [BlockLayoutSqlDataMapper::class, BlockLayout::class], |
|
39
|
|
|
BlockRepo::class => [BlockSqlDataMapper::class, Block::class], |
|
40
|
|
|
ContentListRepo::class => [ContentListSqlDataMapper::class, ContentList::class], |
|
41
|
|
|
ContentListItemRepo::class => [ContentListItemSqlDataMapper::class, ContentListItem::class], |
|
42
|
|
|
PageLayoutRepo::class => [PageLayoutSqlDataMapper::class, PageLayout::class], |
|
43
|
|
|
PageCategoryRepo::class => [PageCategorySqlDataMapper::class, PageCategory::class], |
|
44
|
|
|
PageRepo::class => [PageSqlDataMapper::class, Page::class], |
|
45
|
|
|
]; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @inheritdoc |
|
49
|
|
|
*/ |
|
50
|
|
|
public function getBindings(): array |
|
51
|
|
|
{ |
|
52
|
|
|
return array_keys($this->repoMappers); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @inheritdoc |
|
57
|
|
|
*/ |
|
58
|
|
|
public function registerBindings(IContainer $container) |
|
59
|
|
|
{ |
|
60
|
|
|
try { |
|
61
|
|
|
$unitOfWork = $container->resolve(IUnitOfWork::class); |
|
62
|
|
|
$this->bindRepositories($container, $unitOfWork); |
|
63
|
|
|
} catch (IocException $ex) { |
|
64
|
|
|
$namespace = explode('\\', __NAMESPACE__)[0]; |
|
65
|
|
|
throw new RuntimeException("Failed to register $namespace bindings", 0, $ex); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|