forked from weprovide/valet-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Concrete5ValetDriver.php
48 lines (39 loc) · 1.21 KB
/
Concrete5ValetDriver.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
<?php
class Concrete5ValetDriver extends BasicValetDriver
{
/**
* If a concrete directory exists, it's probably c5
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return bool
*/
public function serves($sitePath, $siteName, $uri)
{
return file_exists($sitePath . "/concrete/config/install/base");
}
/**
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return string
*/
public function frontControllerPath($sitePath, $siteName, $uri)
{
if (!getenv('CONCRETE5_ENV')) {
putenv('CONCRETE5_ENV=valet');
}
$matches = [];
if (preg_match('/^\/(.*?)\.php/', $uri, $matches)) {
$filename = $matches[0];
if (file_exists($sitePath.$filename) && ! is_dir($sitePath.$filename)) {
$_SERVER['SCRIPT_FILENAME'] = $sitePath.$filename;
$_SERVER['SCRIPT_NAME'] = $filename;
return $sitePath . $filename;
}
}
$_SERVER['SCRIPT_FILENAME'] = $sitePath . '/index.php';
$_SERVER['SCRIPT_NAME'] = '/index.php';
return $sitePath . '/index.php';
}
}