summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2017-09-21 20:52:19 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2017-09-21 20:52:19 +0200
commit783c58611ada88460ba670d51ebf4013563e1197 (patch)
tree1e70863dc17c53d440e600b1cd8e5faa8b69be8d /src
parent212760d4c93ce14e9ae34ef207bbb8f48a7dd9a7 (diff)
Added app path to container
Diffstat (limited to 'src')
-rw-r--r--src/Application.php36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/Application.php b/src/Application.php
index fa895d77..80538396 100644
--- a/src/Application.php
+++ b/src/Application.php
@@ -7,8 +7,20 @@ use Psr\Container\ContainerInterface;
class Application extends Container
{
- public function __construct()
+ /** @var string|null */
+ protected $appPath = null;
+
+ /**
+ * Application constructor.
+ *
+ * @param string $appPath
+ */
+ public function __construct($appPath = null)
{
+ if (!is_null($appPath)) {
+ $this->setAppPath($appPath);
+ }
+
$this->registerBaseBindings();
}
@@ -22,4 +34,26 @@ class Application extends Container
$this->instance(Application::class, $this);
$this->bind(ContainerInterface::class, Application::class);
}
+
+ /**
+ * @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;
+ }
}