Create instance of ConfigManager and RouteCollection in Application.
This commit is contained in:
parent
8c4c1a81d9
commit
2ccddd390d
1 changed files with 19 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
namespace Misuzu;
|
namespace Misuzu;
|
||||||
|
|
||||||
|
use Aitemu\RouteCollection;
|
||||||
use Misuzu\Config\ConfigManager;
|
use Misuzu\Config\ConfigManager;
|
||||||
|
|
||||||
class Application
|
class Application
|
||||||
|
@ -26,14 +27,17 @@ class Application
|
||||||
return static::getInstance();
|
return static::getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private $router = null;
|
||||||
private $templating = null;
|
private $templating = null;
|
||||||
private $configuration = null;
|
private $configuration = null;
|
||||||
|
|
||||||
protected function __construct()
|
protected function __construct($config = null)
|
||||||
{
|
{
|
||||||
ExceptionHandler::register();
|
ExceptionHandler::register();
|
||||||
|
|
||||||
|
$this->router = new RouteCollection;
|
||||||
$this->templating = new TemplateEngine;
|
$this->templating = new TemplateEngine;
|
||||||
|
$this->configuration = new ConfigManager($config);
|
||||||
|
|
||||||
echo 'hello!';
|
echo 'hello!';
|
||||||
}
|
}
|
||||||
|
@ -52,6 +56,20 @@ class Application
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasRouter(): bool
|
||||||
|
{
|
||||||
|
return !is_null($this->router) && $this->router instanceof RouteCollection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRouter(): RouteCollection
|
||||||
|
{
|
||||||
|
if (!$this->hasRouter()) {
|
||||||
|
throw new \Exception('No RouteCollection instance is available.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->router;
|
||||||
|
}
|
||||||
|
|
||||||
public function hasTemplating(): bool
|
public function hasTemplating(): bool
|
||||||
{
|
{
|
||||||
return !is_null($this->templating) && $this->templating instanceof TemplateEngine;
|
return !is_null($this->templating) && $this->templating instanceof TemplateEngine;
|
||||||
|
|
Loading…
Add table
Reference in a new issue