Skip to content

Commit edcbf89

Browse files
committed
feat: fire ApplicationBooted after all callbacks have completed
1 parent 50d3eaa commit edcbf89

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

framework/core/src/Foundation/Application.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

1010
namespace Flarum\Foundation;
1111

12+
use Flarum\Foundation\Event\ApplicationBooted;
1213
use Illuminate\Contracts\Container\Container;
14+
use Illuminate\Contracts\Events\Dispatcher;
1315
use Illuminate\Events\EventServiceProvider;
1416
use Illuminate\Support\Arr;
1517
use Illuminate\Support\ServiceProvider;
@@ -276,6 +278,11 @@ public function boot()
276278
$this->booted = true;
277279

278280
$this->fireAppCallbacks($this->bootedCallbacks);
281+
282+
// Finally, we will fire an event to indicate that the application has booted.
283+
// We explicitly do this after firing the "booted" callbacks so that any listener that
284+
// needs to do work after booting can use this event to know when it is truly done.
285+
$this->container->make(Dispatcher::class)->dispatch(new ApplicationBooted());
279286
}
280287

281288
/**
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
/*
4+
* This file is part of Flarum.
5+
*
6+
* For detailed copyright and license information, please view the
7+
* LICENSE file that was distributed with this source code.
8+
*/
9+
10+
namespace Flarum\Foundation\Event;
11+
12+
/**
13+
* The "application booted" event is fired after the application has finished booting and all extension boot callbacks have been run, but before any requests have been handled.
14+
*/
15+
class ApplicationBooted
16+
{
17+
18+
}

0 commit comments

Comments
 (0)