mirror of
https://github.com/laravel/valet.git
synced 2026-02-04 08:10:07 +01:00
Move isActualFile() to ValetDriver
This commit is contained in:
@@ -73,17 +73,6 @@ public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the path is a file and not a directory.
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
protected function isActualFile($path)
|
||||
{
|
||||
return file_exists($path) && ! is_dir($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Concatenate the site path and URI as a single file name.
|
||||
*
|
||||
|
||||
@@ -25,7 +25,7 @@ public function serves($sitePath, $siteName, $uri)
|
||||
*/
|
||||
public function isStaticFile($sitePath, $siteName, $uri)
|
||||
{
|
||||
if (file_exists($staticFilePath = $sitePath.'/webroot/'.$uri)) {
|
||||
if ($this->isActualFile($staticFilePath = $sitePath.'/webroot/'.$uri)) {
|
||||
return $staticFilePath;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ class ContaoValetDriver extends ValetDriver
|
||||
* @param string $sitePath
|
||||
* @param string $siteName
|
||||
* @param string $uri
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function serves($sitePath, $siteName, $uri)
|
||||
{
|
||||
@@ -25,7 +25,7 @@ public function serves($sitePath, $siteName, $uri)
|
||||
*/
|
||||
public function isStaticFile($sitePath, $siteName, $uri)
|
||||
{
|
||||
if (file_exists($staticFilePath = $sitePath.'/web'.$uri)) {
|
||||
if ($this->isActualFile($staticFilePath = $sitePath.'/web'.$uri)) {
|
||||
return $staticFilePath;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public function serves($sitePath, $siteName, $uri)
|
||||
*/
|
||||
public function isStaticFile($sitePath, $siteName, $uri)
|
||||
{
|
||||
if (file_exists($staticFilePath = $sitePath.'/public'.$uri)) {
|
||||
if ($this->isActualFile($staticFilePath = $sitePath.'/public'.$uri)) {
|
||||
return $staticFilePath;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ public function serves($sitePath, $siteName, $uri)
|
||||
*/
|
||||
public function isStaticFile($sitePath, $siteName, $uri)
|
||||
{
|
||||
if (file_exists($sitePath.$uri) && ! is_dir($sitePath.$uri)) {
|
||||
return $sitePath.$uri;
|
||||
if ($this->isActualFile($staticFilePath = $sitePath.$uri)) {
|
||||
return $staticFilePath;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -36,8 +36,7 @@ public function isStaticFile($sitePath, $siteName, $uri)
|
||||
$storageUri = substr($uri, 8);
|
||||
}
|
||||
|
||||
if (file_exists($storagePath = $sitePath.'/storage/app/public'.$storageUri) &&
|
||||
! is_dir($storagePath)) {
|
||||
if ($this->isActualFile($storagePath = $sitePath.'/storage/app/public'.$storageUri)) {
|
||||
return $storagePath;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public function isStaticFile($sitePath, $siteName, $uri)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (file_exists($staticFilePath = $sitePath.$uri)) {
|
||||
if ($this->isActualFile($staticFilePath = $sitePath.$uri)) {
|
||||
return $staticFilePath;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,9 +29,9 @@ public function isStaticFile($sitePath, $siteName, $uri)
|
||||
return false;
|
||||
} elseif (strpos($uri, '/local') === 0 || strpos($uri, '/statamic') === 0) {
|
||||
return false;
|
||||
} elseif (file_exists($staticFilePath = $sitePath.$uri)) {
|
||||
} elseif ($this->isActualFile($staticFilePath = $sitePath.$uri)) {
|
||||
return $staticFilePath;
|
||||
} elseif (file_exists($staticFilePath = $sitePath.'/public'.$uri)) {
|
||||
} elseif ($this->isActualFile($staticFilePath = $sitePath.'/public'.$uri)) {
|
||||
return $staticFilePath;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public function serves($sitePath, $siteName, $uri)
|
||||
*/
|
||||
public function isStaticFile($sitePath, $siteName, $uri)
|
||||
{
|
||||
if (file_exists($staticFilePath = $sitePath.'/web/'.$uri)) {
|
||||
if ($this->isActualFile($staticFilePath = $sitePath.'/web/'.$uri)) {
|
||||
return $staticFilePath;
|
||||
}
|
||||
|
||||
|
||||
@@ -126,4 +126,15 @@ public function serveStaticFile($staticFilePath, $sitePath, $siteName, $uri)
|
||||
|
||||
readfile($staticFilePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the path is a file and not a directory.
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
protected function isActualFile($path)
|
||||
{
|
||||
return ! is_dir($path) && file_exists($path);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user