Update Cli setup

This commit is contained in:
Maarten 2019-12-24 01:54:04 +01:00
parent 7d8a207eee
commit 85583503f6
5 changed files with 144 additions and 12 deletions

View file

@ -2,19 +2,17 @@
namespace Runtime\Factory;
use Cli\Factory;
use Cli\Factory as CliFactory;
use Runtime\Exceptions\Exceptions\ClassNotFoundException;
use Runtime\Http\View\ViewEngine;
use Runtime\Router\Route;
use Runtime\Exceptions\ExceptionHandler;
use Runtime\Router\Router;
use Twig\Environment;
use Twig\Loader\FilesystemLoader;
class BootstrapFactory {
/**
*
* Handle Http core
*/
public function handle()
{
@ -33,27 +31,38 @@ class BootstrapFactory {
}
}
/**
* Handle kernel core
*/
public function kernel()
{
app(Factory::class)->handle();
app(CliFactory::class)->handle();
}
/**
* @param $abstract
* @param array $arguments
* @return mixed
*/
public function make($abstract)
public function make($abstract, $arguments = [])
{
return $this->resolve($abstract);
return $this->resolve($abstract, $arguments);
}
/**
* @param $abstract
* @param $arguments
* @return mixed|null
*/
private function resolve($abstract) {
private function resolve($abstract, array $arguments) {
if(class_exists($abstract)) {
return new $abstract;
try {
$reflection = new \ReflectionClass($abstract);
return $reflection->newInstanceArgs($arguments);
}
catch (\ReflectionException $e) {
ExceptionHandler::make($e);
}
}
ExceptionHandler::make(ClassNotFoundException::class);