Update Cli setup
This commit is contained in:
parent
7d8a207eee
commit
85583503f6
5 changed files with 144 additions and 12 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue