Skip to content

Commit

Permalink
refactor middleware registration and increase $instance visibility to…
Browse files Browse the repository at this point in the history
… protected
  • Loading branch information
Prasetyo committed Aug 13, 2015
1 parent 2c651eb commit bc1b9ab
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Application implements ContainerInterface
/**
* @var Application;
*/
private static $instance;
protected static $instance;

/**
* @param ConfigurationInterface $config
Expand Down Expand Up @@ -148,16 +148,7 @@ public function register(ServiceProviderInterface $service, array $config = [])
*/
public function middleware($middleware)
{
if ($middleware instanceof \Closure) {
$this->middlewares[] = $middleware;
return $this;
}

if (is_callable($middleware)) {
if (! $middleware instanceof MiddlewareInterface) {
throw new \RuntimeException(sprintf('middleware should implement %s', MiddlewareInterface::class));
}
$this->container->singleton($middleware);
if ($middleware instanceof \Closure || $middleware instanceof MiddlewareInterface) {
$this->middlewares[] = $middleware;
return $this;
}
Expand Down

0 comments on commit bc1b9ab

Please sign in to comment.