mirror of
https://github.com/laravel/valet.git
synced 2026-02-05 00:20:08 +01:00
Flatten structure
This commit is contained in:
43
server.php
43
server.php
@@ -128,33 +128,40 @@ function valet_default_site_path($config)
|
|||||||
function get_valet_site_path($valetConfig, $siteName, $domain)
|
function get_valet_site_path($valetConfig, $siteName, $domain)
|
||||||
{
|
{
|
||||||
$valetSitePath = null;
|
$valetSitePath = null;
|
||||||
|
|
||||||
foreach ($valetConfig['paths'] as $path) {
|
foreach ($valetConfig['paths'] as $path) {
|
||||||
if ($handle = opendir($path)) {
|
$handle = opendir($path);
|
||||||
$dirs = [];
|
|
||||||
while (false !== ($file = readdir($handle))) {
|
if ($handle === false) {
|
||||||
if (! is_dir($path.'/'.$file)) continue;
|
continue;
|
||||||
if (in_array($file, ['.', '..', '.DS_Store'])) continue;
|
}
|
||||||
|
|
||||||
|
$dirs = [];
|
||||||
|
|
||||||
|
while (false !== ($file = readdir($handle))) {
|
||||||
|
if (is_dir($path.'/'.$file) && ! in_array($file, ['.', '..', '.DS_Store'])) {
|
||||||
$dirs[] = $file;
|
$dirs[] = $file;
|
||||||
}
|
}
|
||||||
closedir($handle);
|
}
|
||||||
|
|
||||||
// Note: strtolower used below because Nginx only tells us lowercase names
|
closedir($handle);
|
||||||
foreach ($dirs as $dir) {
|
|
||||||
if (strtolower($dir) === $siteName) {
|
|
||||||
// early return when exact match for linked subdomain
|
|
||||||
return $path.'/'.$dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strtolower($dir) === $domain) {
|
// Note: strtolower used below because Nginx only tells us lowercase names
|
||||||
// no early return here because the foreach may still have some subdomains to process with higher priority
|
foreach ($dirs as $dir) {
|
||||||
$valetSitePath = $path.'/'.$dir;
|
if (strtolower($dir) === $siteName) {
|
||||||
}
|
// early return when exact match for linked subdomain
|
||||||
|
return $path.'/'.$dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valetSitePath) {
|
if (strtolower($dir) === $domain) {
|
||||||
return $valetSitePath;
|
// no early return here because the foreach may still have some subdomains to process with higher priority
|
||||||
|
$valetSitePath = $path.'/'.$dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($valetSitePath) {
|
||||||
|
return $valetSitePath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user