-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigProvider.php
More file actions
124 lines (117 loc) · 4.33 KB
/
Copy pathConfigProvider.php
File metadata and controls
124 lines (117 loc) · 4.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
declare(strict_types=1);
namespace Light\Blog;
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
use Light\Blog\DBAL\Types\PostStatusEnumType;
use Light\Blog\Factory\Author\AuthorCollectionHandlerFactory;
use Light\Blog\Factory\Author\AuthorResourceHandlerFactory;
use Light\Blog\Factory\Author\AuthorResourceRepositoryFactory;
use Light\Blog\Factory\Category\CategoryCollectionHandlerFactory;
use Light\Blog\Factory\Category\CategoryCollectionRepositoryFactory;
use Light\Blog\Factory\Category\CategoryResourceHandlerFactory;
use Light\Blog\Factory\Post\PostCollectionHandlerFactory;
use Light\Blog\Factory\Post\PostCollectionRepositoryFactory;
use Light\Blog\Factory\Post\PostResourceHandlerFactory;
use Light\Blog\Factory\Tag\TagResourceHandlerFactory;
use Light\Blog\Factory\Tag\TagResourceRepositoryFactory;
use Light\Blog\Handler\GetAuthorCollectionHandler;
use Light\Blog\Handler\GetAuthorResourceHandler;
use Light\Blog\Handler\GetCategoryCollectionHandler;
use Light\Blog\Handler\GetCategoryResourceHandler;
use Light\Blog\Handler\GetPostCollectionHandler;
use Light\Blog\Handler\GetPostResourceHandler;
use Light\Blog\Handler\GetTagResourceHandler;
use Light\Blog\Repository\AuthorRepository;
use Light\Blog\Repository\CategoryRepository;
use Light\Blog\Repository\PostRepository;
use Light\Blog\Repository\TagRepository;
use Mezzio\Application;
class ConfigProvider
{
/**
@return array{
* dependencies: array<mixed>,
* templates: array<mixed>,
* }
*/
public function __invoke(): array
{
return [
'dependencies' => $this->getDependencies(),
'doctrine' => $this->getDoctrineConfig(),
'templates' => $this->getTemplates(),
];
}
/**
* @return array{
* delegators: array<class-string, array<class-string>>,
* factories: array<class-string, class-string>,
* }
*/
private function getDependencies(): array
{
return [
'delegators' => [
Application::class => [
RoutesDelegator::class,
],
],
'factories' => [
GetCategoryCollectionHandler::class => CategoryCollectionHandlerFactory::class,
CategoryRepository::class => CategoryCollectionRepositoryFactory::class,
GetPostCollectionHandler::class => PostCollectionHandlerFactory::class,
PostRepository::class => PostCollectionRepositoryFactory::class,
GetPostResourceHandler::class => PostResourceHandlerFactory::class,
GetCategoryResourceHandler::class => CategoryResourceHandlerFactory::class,
AuthorRepository::class => AuthorResourceRepositoryFactory::class,
GetAuthorResourceHandler::class => AuthorResourceHandlerFactory::class,
GetAuthorCollectionHandler::class => AuthorCollectionHandlerFactory::class,
TagRepository::class => TagResourceRepositoryFactory::class,
GetTagResourceHandler::class => TagResourceHandlerFactory::class,
],
];
}
/**
@return array{
* driver: array<mixed>,
* types: array<mixed>,
* }
*/
private function getDoctrineConfig(): array
{
return [
'driver' => [
'orm_default' => [
'drivers' => [
'Light\Blog\Entity' => 'BlogEntities',
],
],
'BlogEntities' => [
'class' => AttributeDriver::class,
'cache' => 'array',
'paths' => [__DIR__ . '/Entity'],
],
],
'types' => [
PostStatusEnumType::NAME => PostStatusEnumType::class,
],
];
}
/**
* @return array{
* paths: array{
* page: array{literal-string&non-falsy-string},
* jsonld: array{literal-string&non-falsy-string},
* }
* }
*/
private function getTemplates(): array
{
return [
'paths' => [
'page' => [__DIR__ . '/../templates/page'],
'jsonld' => [__DIR__ . '/../templates/page/JSON-LD'],
],
];
}
}