Skip to content

Commit 0c8220a

Browse files
Listen to booting event of extension manager
1 parent 93b7efb commit 0c8220a

File tree

1 file changed

+21
-26
lines changed

1 file changed

+21
-26
lines changed

src/GedmoExtensionsServiceProvider.php

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,32 @@
99
class GedmoExtensionsServiceProvider extends ServiceProvider
1010
{
1111
/**
12-
* Boot the service provider
12+
* Register the service provider.
13+
* @return void
1314
*/
14-
public function boot()
15+
public function register()
1516
{
16-
$registry = $this->app->make('registry');
17+
$this->app['events']->listen('doctrine.extensions.booting', function () {
18+
$registry = $this->app->make('registry');
1719

18-
foreach ($registry->getManagers() as $manager) {
19-
$chain = $manager->getConfiguration()->getMetadataDriverImpl();
20-
$reader = $chain->getReader();
20+
foreach ($registry->getManagers() as $manager) {
21+
$chain = $manager->getConfiguration()->getMetadataDriverImpl();
22+
$reader = $chain->getReader();
2123

22-
if ($reader instanceof Reader) {
23-
if ($this->app->make('config')->get('doctrine.gedmo.all_mappings', false)) {
24-
DoctrineExtensions::registerMappingIntoDriverChainORM(
25-
$chain,
26-
$reader
27-
);
28-
} else {
29-
DoctrineExtensions::registerAbstractMappingIntoDriverChainORM(
30-
$chain,
31-
$reader
32-
);
24+
if ($reader instanceof Reader) {
25+
if ($this->app->make('config')->get('doctrine.gedmo.all_mappings', false)) {
26+
DoctrineExtensions::registerMappingIntoDriverChainORM(
27+
$chain,
28+
$reader
29+
);
30+
} else {
31+
DoctrineExtensions::registerAbstractMappingIntoDriverChainORM(
32+
$chain,
33+
$reader
34+
);
35+
}
3336
}
3437
}
35-
}
36-
}
37-
38-
/**
39-
* Register the service provider.
40-
* @return void
41-
*/
42-
public function register()
43-
{
38+
});
4439
}
4540
}

0 commit comments

Comments
 (0)