Skip to content

Commit

Permalink
r support for latest laravel
Browse files Browse the repository at this point in the history
  • Loading branch information
dusterio committed Jul 16, 2019
1 parent 4a2b2ff commit aa62470
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 2 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ $app->routeMiddleware([
'auth' => App\Http\Middleware\Authenticate::class,
]);

// Finally register two service providers - original one and Lumen adapter
$app->register(Laravel\Passport\PassportServiceProvider::class);
// Finally register a service provider of the Lumen adapter
$app->register(Dusterio\LumenPassport\PassportServiceProvider::class);
```

Expand Down
7 changes: 7 additions & 0 deletions src/PassportServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Dusterio\LumenPassport\Console\Commands\Purge;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Connection;
use Symfony\Component\Debug\Exception\FatalThrowableError;

/**
* Class CustomQueueServiceProvider
Expand All @@ -19,6 +20,9 @@ class PassportServiceProvider extends ServiceProvider
*/
public function boot()
{
$laravel = new \Laravel\Passport\PassportServiceProvider($this->app);
$laravel->boot();

$this->app->singleton(Connection::class, function() {
return $this->app['db.connection'];
});
Expand All @@ -40,5 +44,8 @@ public function boot()
*/
public function register()
{
$app = new ProxyApplication($this->app);
$laravel = new \Laravel\Passport\PassportServiceProvider($app);
$laravel->register();
}
}
106 changes: 106 additions & 0 deletions src/ProxyApplication.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php

namespace Dusterio\LumenPassport;

class ProxyApplication implements \ArrayAccess {
protected $app;

public function __construct($app)
{
$this->app = $app;
}

/**
* @return bool
*/
public function configurationIsCached()
{
return false;
}

/**
* @return bool
*/
public function runningInConsole()
{
return $this->app->runningInConsole();
}

/**
* @param string $symbol
* @param callable|mixed $callback
* @return mixed
*/
public function singleton($symbol, $callback)
{
return $this->app->singleton($symbol, $callback);
}

/**
* Determine if a given offset exists.
*
* @param string $key
* @return bool
*/
public function offsetExists($key)
{
return $this->app->offsetExists($key);
}

/**
* Get the value at a given offset.
*
* @param string $key
* @return mixed
*/
public function offsetGet($key)
{
return $this->app->offsetGet($key);
}

/**
* Set the value at a given offset.
*
* @param string $key
* @param mixed $value
* @return void
*/
public function offsetSet($key, $value)
{
$this->app->offsetSet($key, $value);
}

/**
* Unset the value at a given offset.
*
* @param string $key
* @return void
*/
public function offsetUnset($key)
{
$this->app->offsetUnset($key);
}

/**
* Dynamically access container services.
*
* @param string $key
* @return mixed
*/
public function __get($key)
{
return $this->app[$key];
}

/**
* Dynamically set container services.
*
* @param string $key
* @param mixed $value
* @return void
*/
public function __set($key, $value)
{
$this->app[$key] = $value;
}
}

0 comments on commit aa62470

Please sign in to comment.