44
55namespace Light \App ;
66
7+ use Doctrine \ORM \EntityManager ;
8+ use Doctrine \ORM \EntityManagerInterface ;
9+ use Doctrine \Persistence \Mapping \Driver \MappingDriverChain ;
10+ use Dot \Cache \Adapter \ArrayAdapter ;
11+ use Dot \Cache \Adapter \FilesystemAdapter ;
712use Light \App \Factory \GetIndexViewHandlerFactory ;
813use Light \App \Handler \GetIndexViewHandler ;
914use Mezzio \Application ;
15+ use Ramsey \Uuid \Doctrine \UuidBinaryOrderedTimeType ;
16+ use Ramsey \Uuid \Doctrine \UuidBinaryType ;
17+ use Ramsey \Uuid \Doctrine \UuidType ;
18+ use Roave \PsrContainerDoctrine \EntityManagerFactory ;
19+
20+ use function getcwd ;
1021
1122class ConfigProvider
1223{
@@ -20,6 +31,7 @@ public function __invoke(): array
2031 {
2132 return [
2233 'dependencies ' => $ this ->getDependencies (),
34+ 'doctrine ' => $ this ->getDoctrineConfig (),
2335 'templates ' => $ this ->getTemplates (),
2436 ];
2537 }
@@ -39,7 +51,12 @@ public function getDependencies(): array
3951 ],
4052 ],
4153 'factories ' => [
42- GetIndexViewHandler::class => GetIndexViewHandlerFactory::class,
54+ 'doctrine.entity_manager.orm_default ' => EntityManagerFactory::class,
55+ GetIndexViewHandler::class => GetIndexViewHandlerFactory::class,
56+ ],
57+ 'aliases ' => [
58+ EntityManager::class => 'doctrine.entity_manager.orm_default ' ,
59+ EntityManagerInterface::class => 'doctrine.entity_manager.orm_default ' ,
4360 ],
4461 ];
4562 }
@@ -65,4 +82,64 @@ public function getTemplates(): array
6582 ],
6683 ];
6784 }
85+
86+ private function getDoctrineConfig (): array
87+ {
88+ return [
89+ 'cache ' => [
90+ 'array ' => [
91+ 'class ' => ArrayAdapter::class,
92+ ],
93+ 'filesystem ' => [
94+ 'class ' => FilesystemAdapter::class,
95+ 'directory ' => getcwd () . '/data/cache ' ,
96+ 'namespace ' => 'doctrine ' ,
97+ ],
98+ ],
99+ 'configuration ' => [
100+ 'orm_default ' => [
101+ 'result_cache ' => 'filesystem ' ,
102+ 'metadata_cache ' => 'filesystem ' ,
103+ 'query_cache ' => 'filesystem ' ,
104+ 'hydration_cache ' => 'array ' ,
105+ 'typed_field_mapper ' => null ,
106+ 'second_level_cache ' => [
107+ 'enabled ' => true ,
108+ 'default_lifetime ' => 3600 ,
109+ 'default_lock_lifetime ' => 60 ,
110+ 'file_lock_region_directory ' => '' ,
111+ 'regions ' => [],
112+ ],
113+ ],
114+ ],
115+ 'connection ' => [
116+ 'orm_default ' => [
117+ 'doctrine_mapping_types ' => [
118+ UuidBinaryType::NAME => 'binary ' ,
119+ UuidBinaryOrderedTimeType::NAME => 'binary ' ,
120+ ],
121+ ],
122+ ],
123+ 'driver ' => [
124+ // The default metadata driver aggregates all other drivers into a single one.
125+ // Override `orm_default` only if you know what you're doing.
126+ 'orm_default ' => [
127+ 'class ' => MappingDriverChain::class,
128+ ],
129+ ],
130+ 'migrations ' => [
131+ // Modify this line based on where you would like to have you migrations
132+ 'migrations_paths ' => [
133+ 'Migrations ' => 'src/Migrations ' ,
134+ ],
135+ 'all_or_nothing ' => true ,
136+ 'check_database_platform ' => true ,
137+ ],
138+ 'types ' => [
139+ UuidType::NAME => UuidType::class,
140+ UuidBinaryType::NAME => UuidBinaryType::class,
141+ UuidBinaryOrderedTimeType::NAME => UuidBinaryOrderedTimeType::class,
142+ ],
143+ ];
144+ }
68145}
0 commit comments