mallardduck /
dynamic-echo-events
| 1 | <?php |
||
| 2 | |||
| 3 | namespace MallardDuck\DynamicEcho\Composer; |
||
| 4 | |||
| 5 | use Composer\Script\Event; |
||
| 6 | use Illuminate\Foundation\Application; |
||
| 7 | |||
| 8 | class ScriptsHelper |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Handle the post-install Composer event. |
||
| 12 | * |
||
| 13 | * @param Event $event |
||
| 14 | * @return void |
||
| 15 | */ |
||
| 16 | public static function postInstall(Event $event) |
||
| 17 | { |
||
| 18 | require_once $event->getComposer()->getConfig()->get('vendor-dir') . '/autoload.php'; |
||
| 19 | static::clearCompiled(); |
||
| 20 | } |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Handle the post-update Composer event. |
||
| 24 | * |
||
| 25 | * @param Event $event |
||
| 26 | * @return void |
||
| 27 | */ |
||
| 28 | public static function postUpdate(Event $event) |
||
| 29 | { |
||
| 30 | require_once $event->getComposer()->getConfig()->get('vendor-dir') . '/autoload.php'; |
||
| 31 | static::clearCompiled(); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Handle the post-autoload-dump Composer event. |
||
| 36 | * |
||
| 37 | * @param Event $event |
||
| 38 | * @return void |
||
| 39 | */ |
||
| 40 | public static function postAutoloadDump(Event $event) |
||
| 41 | { |
||
| 42 | require_once $event->getComposer()->getConfig()->get('vendor-dir') . '/autoload.php'; |
||
| 43 | static::clearCompiled(); |
||
| 44 | } |
||
| 45 | |||
| 46 | protected static function clearCompiled() |
||
| 47 | { |
||
| 48 | $laravel = new Application(getcwd()); |
||
| 49 | // For now just clear the main cache |
||
| 50 | if (is_file($servicesPath = $laravel->bootstrapPath('cache/dynamic-echo-discovery.php'))) { |
||
| 51 | @unlink($servicesPath); |
||
|
0 ignored issues
–
show
|
|||
| 52 | } |
||
| 53 | // TODO: clear route cache for the broadcast channels. |
||
| 54 | } |
||
| 55 | } |
||
| 56 |
If you suppress an error, we recommend checking for the error condition explicitly: