1 | <?php |
||
8 | class Apps |
||
9 | { |
||
10 | /** |
||
11 | * The container instance. |
||
12 | * |
||
13 | * @var \Illuminate\Contracts\Container\Container |
||
14 | */ |
||
15 | protected $container; |
||
16 | |||
17 | /** |
||
18 | * The current application identifier. |
||
19 | * |
||
20 | * @var string|false |
||
21 | */ |
||
22 | protected $id = false; |
||
23 | |||
24 | /** |
||
25 | * Create a new Apps instance. |
||
26 | * |
||
27 | * @param \Illuminate\Contracts\Container\Container $container |
||
28 | */ |
||
29 | 10 | public function __construct(Container $container) |
|
30 | { |
||
31 | 10 | $this->container = $container; |
|
32 | |||
33 | $this->container->rebinding('request', function () { |
||
34 | 1 | $this->refreshId(); |
|
35 | 10 | }); |
|
36 | 10 | } |
|
37 | |||
38 | /** |
||
39 | * Get or check the current application identifier. |
||
40 | * |
||
41 | * @return string|bool |
||
42 | */ |
||
43 | 3 | public function id() |
|
55 | |||
56 | /** |
||
57 | * Refresh the current application identifier. |
||
58 | * |
||
59 | * @return $this |
||
60 | */ |
||
61 | 2 | public function refreshId() |
|
67 | |||
68 | /** |
||
69 | * Get application identifier for the given URL. |
||
70 | * |
||
71 | * @param string $url |
||
72 | * @return string |
||
73 | */ |
||
74 | 4 | public function idForUrl($url) |
|
86 | |||
87 | /** |
||
88 | * Determine if an URL has the given root URL. |
||
89 | * |
||
90 | * @param string $url |
||
91 | * @param string $root |
||
92 | * @param bool $strict |
||
93 | * @return bool |
||
94 | */ |
||
95 | 4 | protected function urlHasRoot($url, $root, $strict = false) |
|
104 | |||
105 | /** |
||
106 | * Remove scheme for an URL. |
||
107 | * |
||
108 | * @param string $url |
||
109 | * @return string |
||
110 | */ |
||
111 | 4 | protected function removeScheme($url) |
|
115 | |||
116 | /** |
||
117 | * Get the root URL for the given application identifier. |
||
118 | * |
||
119 | * @param string $appId |
||
120 | * @return string |
||
121 | */ |
||
122 | 4 | public function root($appId = '') |
|
127 | |||
128 | /** |
||
129 | * Get the domain for the given application identifier. |
||
130 | * |
||
131 | * @param string $appId |
||
132 | * @return string |
||
133 | */ |
||
134 | 1 | public function domain($appId = '') |
|
138 | |||
139 | /** |
||
140 | * Get the URL prefix for the given application identifier. |
||
141 | * |
||
142 | * @param string $appId |
||
143 | * @return string |
||
144 | */ |
||
145 | 1 | public function prefix($appId = '') |
|
149 | |||
150 | /** |
||
151 | * Generate an absolute URL to a path for the given application identifier. |
||
152 | * |
||
153 | * @param string $appId |
||
154 | * @param string $path |
||
155 | * @param mixed $extra |
||
156 | * @return string |
||
157 | */ |
||
158 | 1 | public function url($appId = '', $path = '', $extra = []) |
|
165 | |||
166 | /** |
||
167 | * Return the remainder of a string after a given value. |
||
168 | * |
||
169 | * @param string $subject |
||
170 | * @param string $search |
||
171 | * @return string |
||
172 | */ |
||
173 | 1 | protected function stringAfter($subject, $search) |
|
177 | } |
||
178 |