alpha
Login
or
Join now
danielroe.dev
/
trellis-valet-driver
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
[READ-ONLY] Mirror of https://github.com/danielroe/trellis-valet-driver. A driver for Laravel Valet that supports the default Trellis install.
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
Up to date with Bedrock driver
author
Daniel Roe
date
8 years ago
(Mar 17, 2018, 8:33 PM UTC)
commit
6c4d380e
6c4d380e1653ed9f506f22e07856e0a867d82e97
parent
3271d45e
3271d45e56176105ed5d4a28d99d1447838d89f9
+27
-10
1 changed file
Expand all
Collapse all
Unified
Split
TrellisValetDriver.php
+27
-10
TrellisValetDriver.php
View file
Reviewed
···
8
8
* @param string $sitePath
9
9
* @param string $siteName
10
10
* @param string $uri
11
11
-
* @return void
11
11
+
* @return bool
12
12
*/
13
13
public function serves($sitePath, $siteName, $uri)
14
14
{
15
15
-
return (
16
16
-
file_exists("$sitePath/site/config/application.php")
17
17
-
&& file_exists("$sitePath/site/web/wp-config.php")
18
18
-
&& is_dir("$sitePath/site/web/app/")
19
19
-
);
15
15
+
return file_exists($sitePath . '/site/web/app/mu-plugins/bedrock-autoloader.php') ||
16
16
+
(is_dir($sitePath . '/site/web/app/') &&
17
17
+
file_exists($sitePath . '/site/web/wp-config.php') &&
18
18
+
file_exists($sitePath . '/site/config/application.php'));
20
19
}
21
20
22
21
/**
···
29
28
*/
30
29
public function isStaticFile($sitePath, $siteName, $uri)
31
30
{
32
32
-
$staticFilePath = $sitePath . '/site/web/' . $uri;
33
33
-
if (file_exists($staticFilePath) && !is_dir($staticFilePath)) {
31
31
+
$staticFilePath = $sitePath . '/site/web' . $uri;
32
32
+
if ($this->isActualFile($staticFilePath)) {
34
33
return $staticFilePath;
35
34
}
36
35
return false;
···
46
45
*/
47
46
public function frontControllerPath($sitePath, $siteName, $uri)
48
47
{
49
49
-
if (0 === strpos($uri, '/wp/')) {
50
50
-
return $sitePath . '/site/web' . $uri;
48
48
+
$_SERVER['PHP_SELF'] = $uri;
49
49
+
if (strpos($uri, '/wp/') === 0) {
50
50
+
return is_dir($sitePath . '/site/web' . $uri)
51
51
+
? $sitePath . '/site/web' . $this->forceTrailingSlash($uri) . '/index.php'
52
52
+
: $sitePath . '/site/web' . $uri;
51
53
}
52
54
return $sitePath . '/site/web/index.php';
55
55
+
}
56
56
+
57
57
+
/**
58
58
+
* Redirect to uri with trailing slash.
59
59
+
*
60
60
+
* @param string $uri
61
61
+
* @return string
62
62
+
*/
63
63
+
private function forceTrailingSlash($uri)
64
64
+
{
65
65
+
if (substr($uri, -1 * strlen('/wp/wp-admin')) == '/wp/wp-admin') {
66
66
+
header('Location: ' . $uri . '/');
67
67
+
die;
68
68
+
}
69
69
+
return $uri;
53
70
}
54
71
}