summaryrefslogtreecommitdiff
path: root/src/helpers.php
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2017-08-31 17:30:54 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2017-08-31 17:30:54 +0200
commit8c81adc8e83969e90b4c54daf4a396b1094134ff (patch)
treeae5b7e5bd826a9287d8fa34627d5b67c58e6fb22 /src/helpers.php
parent0a20883aa862779b48fd2a297456c2db04cffb95 (diff)
Implemented container
Diffstat (limited to 'src/helpers.php')
-rw-r--r--src/helpers.php29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/helpers.php b/src/helpers.php
index 24f93f2c..733b902d 100644
--- a/src/helpers.php
+++ b/src/helpers.php
@@ -2,12 +2,28 @@
// Some useful functions
use Engelsystem\Config\Config;
+use Engelsystem\Container\Container;
use Engelsystem\Http\Request;
use Engelsystem\Renderer\Renderer;
use Engelsystem\Routing\UrlGenerator;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
/**
+ * Get the global container instance
+ *
+ * @param string $id
+ * @return mixed
+ */
+function app($id = null)
+{
+ if (is_null($id)) {
+ return Container::getInstance();
+ }
+
+ return Container::getInstance()->get($id);
+}
+
+/**
* Get or set config values
*
* @param string|array $key
@@ -16,15 +32,18 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface;
*/
function config($key = null, $default = null)
{
+ $config = app('config');
+
if (empty($key)) {
- return Config::getInstance();
+ return $config;
}
if (is_array($key)) {
- Config::getInstance()->set($key);
+ $config->set($key);
+ return true;
}
- return Config::getInstance()->get($key, $default);
+ return $config->get($key, $default);
}
/**
@@ -34,7 +53,7 @@ function config($key = null, $default = null)
*/
function request($key = null, $default = null)
{
- $request = Request::getInstance();
+ $request = app('request');
if (is_null($key)) {
return $request;
@@ -66,7 +85,7 @@ function session($key = null, $default = null)
*/
function view($template = null, $data = null)
{
- $renderer = Renderer::getInstance();
+ $renderer = app('renderer');
if (is_null($template)) {
return $renderer;