This repository has been archived by the owner on Sep 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
helpers.php
88 lines (78 loc) · 1.72 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
84
85
86
87
88
<?php
if ( ! function_exists('locate'))
{
/**
* Return theme path location of a requested view, this would allow
* `Orchestra\Theme` to check for existent of theme file associated to
* the given path before fallback to default view.
*
* @see Orchestra\Theme::path()
* @param string $view
* @return string
*/
function locate($view)
{
return Orchestra\Theme::resolve()->path($view);
}
}
if ( ! function_exists('memorize'))
{
/**
* Return memory configuration associated to the request
*
* @see Orchestra\Core::memory()
* @param string $key
* @param string $default
* @return mixed
*/
function memorize($key, $default = null)
{
return Orchestra\Core::memory()->get($key, $default);
}
}
if ( ! function_exists('handles'))
{
/**
* Return handles configuration for a bundle
*
* @param string $bundle Bundle name
* @return string URL path
*/
function handles($name)
{
$handles = '';
$query = '';
// split URI and query string.
if (strpos($name, '?') !== false)
{
list($name, $query) = explode('?', $name, 2);
}
if (strpos($name, '::') !== false)
{
list($bundle, $path) = Bundle::parse($name);
}
else
{
$bundle = $name;
$path = '';
}
// In situation where bundle is not registered, it best to assume
// that we are handle "application" routing
if ( ! Bundle::exists($bundle))
{
$path = $bundle;
$bundle = DEFAULT_BUNDLE;
// DEFAULT_BUNDLE should handle root path
$handles = '';
}
else
{
$handles = Bundle::option($bundle, 'handles');
$handles = rtrim($handles, '/');
}
$path = ltrim($path, '/');
// reappend query string.
empty($query) or $path .= '?'.$query;
return url($handles.'/'.$path);
}
}