1
0
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:
Kennedy Tedesco
2016-05-10 14:43:38 -03:00
parent 97f7ae2342
commit 29dafe848c
10 changed files with 22 additions and 23 deletions

View File

@@ -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.
*

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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);
}
}