-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDiscuzQValetDriver.php
54 lines (42 loc) · 1.35 KB
/
DiscuzQValetDriver.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
<?php
class DiscuzQValetDriver extends LaravelValetDriver
{
private function startsWith($haystack, $needle)
{
$length = strlen($needle);
return (substr($haystack, 0, $length) === $needle);
}
public function serves($sitePath, $siteName, $uri)
{
return file_exists($sitePath . '/public/index.php') && file_exists($sitePath . '/disco');
}
public function isStaticFile($sitePath, $siteName, $uri)
{
if (file_exists($staticFilePath = $sitePath . '/public/' . $uri)) {
return $staticFilePath;
}
if ($this->startsWith($uri, "/api")) {
return false;
}
if ($this->startsWith($uri, "/install")) {
return false;
}
if ($this->startsWith($uri, "/admin")) {
return $sitePath . '/public/admin.html';
}
return $sitePath . '/public/index.html';
}
public function frontControllerPath($sitePath, $siteName, $uri)
{
if ($this->startsWith($uri, "/api")) {
return $sitePath . '/public/index.php';
}
if ($this->startsWith($uri, "/install")) {
return $sitePath . '/public/index.php';
}
if ($this->startsWith($uri, "/admin")) {
return $sitePath . '/public/admin.html';
}
return $sitePath . '/public/index.html';
}
}