Removed references to $config in the AppManager class before it's instantiated

This commit is contained in:
Chris Kankiewicz
2020-02-06 08:54:54 -07:00
parent 0005b6091a
commit 8a860171a2
2 changed files with 14 additions and 19 deletions

View File

@@ -6,7 +6,6 @@ use App\Providers;
use DI\Bridge\Slim\Bridge;
use DI\Container;
use Invoker\CallableResolver;
use PHLAK\Config\Config;
use Slim\App;
use Tightenco\Collect\Support\Collection;
@@ -27,9 +26,6 @@ class AppManager
/** @var Container The applicaiton container */
protected $container;
/** @var Config The application config */
protected $config;
/** @var CallableResolver The callable resolver */
protected $callableResolver;
@@ -38,10 +34,9 @@ class AppManager
*
* @param \DI\Container $container
*/
public function __construct(Container $container, Config $config, CallableResolver $callableResolver)
public function __construct(Container $container, CallableResolver $callableResolver)
{
$this->container = $container;
$this->config = $config;
$this->callableResolver = $callableResolver;
}
@@ -66,13 +61,13 @@ class AppManager
*/
protected function registerProviders(): void
{
Collection::make(self::PROVIDERS)->merge(
$this->config->get('app.providers', [])
)->each(function (string $provider) {
$this->container->call(
$this->callableResolver->resolve($provider)
);
});
Collection::make(self::PROVIDERS)->each(
function (string $provider) {
$this->container->call(
$this->callableResolver->resolve($provider)
);
}
);
}
/**
@@ -84,10 +79,10 @@ class AppManager
*/
protected function registerMiddlewares(App $app): void
{
Collection::make(self::MIDDLEWARES)->merge(
$this->config->get('app.middlewares', [])
)->each(function (string $middleware) use ($app) {
$app->add($middleware);
});
Collection::make(self::MIDDLEWARES)->each(
function (string $middleware) use ($app) {
$app->add($middleware);
}
);
}
}

View File

@@ -12,7 +12,7 @@ class AppManangerTest extends TestCase
public function test_it_returns_an_app_instance(): void
{
$callableResolver = $this->container->get(CallableResolver::class);
$app = (new AppManager($this->container, $this->config, $callableResolver))();
$app = (new AppManager($this->container, $callableResolver))();
$this->assertInstanceOf(App::class, $app);
}