forked from tonik/theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.php
83 lines (72 loc) · 1.39 KB
/
helpers.php
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
78
79
80
81
82
83
<?php
namespace App\Theme;
use Tonik\Gin\Asset\Asset;
use Tonik\Gin\Foundation\Theme;
use Tonik\Gin\Template\Template;
/**
* Gets theme instance.
*
* @param string|null $key
* @param array $parameters
*
* @return \Tonik\Gin\Foundation\Theme
*/
function theme($key = null, $parameters = [])
{
if (null !== $key) {
return Theme::getInstance()->get($key, $parameters);
}
return Theme::getInstance();
}
/**
* Gets theme config instance.
*
* @param string|null $key
*
* @return array
*/
function config($key = null)
{
if (null !== $key) {
return theme('config')->get($key);
}
return theme('config');
}
/**
* Renders template file with data.
*
* @param string $file Relative path to the template file.
* @param array $data Dataset for the template.
*
* @return void
*/
function template($file, $data = [])
{
$template = new Template(config());
return $template
->setFile($file)
->render($data);
}
/**
* Gets asset instance.
*
* @param string $file Relative file path to the asset file.
*
* @return \Tonik\Gin\Asset\Asset
*/
function asset($file)
{
$asset = new Asset(config());
return $asset->setFile($file);
}
/**
* Gets asset file from public directory.
*
* @param string $file Relative file path to the asset file.
*
* @return string
*/
function asset_path($file)
{
return asset($file)->getUri();
}