-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpers.php
More file actions
77 lines (64 loc) · 1.95 KB
/
helpers.php
File metadata and controls
77 lines (64 loc) · 1.95 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
<?php
if (! function_exists('config')) {
function config($key = null, $default = null)
{
$path = explode('.', $key);
$configDirectory = __DIR__ . '/config/';
if (!file_exists($configDirectory)) {
return $default;
}
$configFilenames = scandir($configDirectory);
foreach ($configFilenames as $filename) {
if ($filename === $path[0].'.php' && file_exists($configPath = $configDirectory . $filename)) {
$config = include $configPath;
array_shift($path);
$result = &$config;
foreach ($path as $k) {
$result = isset($result[$k]) ? $result[$k] : $default;
}
return $result;
}
}
return $default;
}
}
if (! function_exists('elixir')) {
/**
* Get the path to a versioned Elixir file.
*
* @param string $file
* @return string
*
* @throws \InvalidArgumentException
*/
function elixir($file)
{
static $manifest = null;
static $manifestPath = __DIR__ . '/public/build/rev-manifest.json';
if (is_null($manifest) && file_exists($manifestPath)) {
$manifest = json_decode(file_get_contents($manifestPath), true);
}
if (isset($manifest[$file])) {
return '/build/'.$manifest[$file];
}
$unversioned = __DIR__ . '/public/';
if (file_exists($unversioned)) {
return '/'.trim($file, '/');
}
throw new InvalidArgumentException("File {$file} not defined in asset manifest.");
}
}
if (! function_exists('env')) {
function env($key, $default = null)
{
if (!file_exists(__DIR__ . '/env.php')) {
return $default;
}
$env = include 'env.php';
if (isset($env[$key])) {
return $env[$key];
} else {
return $default;
}
}
}