engelsystem/src/Application.php

60 lines
1.2 KiB
PHP
Raw Normal View History

2017-09-19 14:50:20 +02:00
<?php
namespace Engelsystem;
use Engelsystem\Container\Container;
use Psr\Container\ContainerInterface;
class Application extends Container
{
2017-09-21 20:52:19 +02:00
/** @var string|null */
protected $appPath = null;
/**
* Application constructor.
*
* @param string $appPath
*/
public function __construct($appPath = null)
2017-09-19 14:50:20 +02:00
{
2017-09-21 20:52:19 +02:00
if (!is_null($appPath)) {
$this->setAppPath($appPath);
}
2017-09-19 14:50:20 +02:00
$this->registerBaseBindings();
}
protected function registerBaseBindings()
{
static::setInstance($this);
2017-09-19 14:50:20 +02:00
Container::setInstance($this);
$this->instance('app', $this);
$this->instance('container', $this);
$this->instance(Container::class, $this);
$this->instance(Application::class, $this);
$this->bind(ContainerInterface::class, Application::class);
2017-09-19 14:50:20 +02:00
}
2017-09-21 20:52:19 +02:00
/**
* @param string $appPath
* @return static
*/
public function setAppPath($appPath)
{
$appPath = rtrim($appPath, DIRECTORY_SEPARATOR);
$this->appPath = $appPath;
$this->instance('path', $appPath);
return $this;
}
/**
* @return string|null
*/
public function path()
{
return $this->appPath;
}
2017-09-19 14:50:20 +02:00
}