Created
March 6, 2018 14:30
-
-
Save NBZ4live/98663326065ba0860c679ac411d87f80 to your computer and use it in GitHub Desktop.
PHP-PM Lumen adapter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\PHPPM; | |
use Illuminate\Container\BoundMethod; | |
use Illuminate\Support\ServiceProvider; | |
use PHPPM\Bootstraps\Laravel; | |
class LumenAdapter extends Laravel | |
{ | |
/** | |
* @param \Illuminate\Contracts\Foundation\Application $app | |
*/ | |
public function postHandle($app) | |
{ | |
$this->resetProvider(\App\Providers\AuthServiceProvider::class); | |
$this->resetProvider(\Illuminate\Session\SessionServiceProvider::class); | |
} | |
/** | |
* @param \Illuminate\Support\ServiceProvider|string $provider | |
*/ | |
protected function resetProvider($provider) | |
{ | |
if (! $provider instanceof ServiceProvider) { | |
$provider = new $provider($this->app); | |
} | |
if (method_exists($provider, 'register')) { | |
$provider->register(); | |
} | |
if (method_exists($provider, 'boot')) { | |
BoundMethod::call($this->app, [$provider, 'boot']); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do you use this?