You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.2 KiB
PHTML

<?php
// Some useful functions
use Engelsystem\Config\Config;
use Engelsystem\Http\Request;
use Engelsystem\Renderer\Renderer;
use Engelsystem\Routing\UrlGenerator;
/**
* Get or set config values
*
* @param string|array $key
* @param mixed $default
* @return mixed|Config
*/
function config($key = null, $default = null)
{
if (empty($key)) {
return Config::getInstance();
}
if (is_array($key)) {
Config::getInstance()->set($key);
}
return Config::getInstance()->get($key, $default);
}
/**
* @param string $key
* @param mixed $default
* @return Request|mixed
*/
function request($key = null, $default = null)
{
$request = Request::getInstance();
if (is_null($key)) {
return $request;
}
return $request->input($key, $default);
}
/**
* @param string $template
* @param mixed[] $data
* @return Renderer|string
*/
function view($template = null, $data = null)
{
$renderer = Renderer::getInstance();
if (is_null($template)) {
return $renderer;
}
return $renderer->render($template, $data);
}
/**
* @param string $path
* @param array $parameters
* @return string
*/
function url($path, $parameters = [])
{
return UrlGenerator::to($path, $parameters);
}