-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelpers.php
More file actions
77 lines (56 loc) · 1.28 KB
/
Helpers.php
File metadata and controls
77 lines (56 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
use khokonc\mvc\Application;
if (!function_exists('str_contains')) {
function str_contains($haystack, $needle) {
return $needle !== '' && mb_strpos($haystack, $needle) !== false;
}
}
function view(string $view, array $params = [])
{
return Application::$app->view->renderView($view, $params);
}
function _token()
{
return Application::$app->session->getToken();
}
function csrf_token()
{
return sprintf("<input type='hidden' name='_token' value='%s'>", _token());
}
function asset(string $file)
{
return config('app.app_url') . '/' . trim($file, '/');
}
function route($name, $params = null)
{
return Application::$app->router->getRouteByName($name,$params);
}
function session_flash($key)
{
return Application::$app->session->getFlashMessage($key);
}
function redirect(string $to = null)
{
return new \khokonc\mvc\Http\HttpRedirectResponse($to);
}
function dd($object)
{
echo "<pre>";
var_dump($object);
die();
}
function app($classname)
{
return new $classname();
}
function config($path)
{
$paths = explode('.',$path);
$configs = include(__DIR__."/../../../config/".$paths[0].".php");
array_shift($paths);
$data = $configs;
foreach($paths as $key){
$data = $data[$key];
}
return $data;
}