mirror of
https://github.com/laravel/valet.git
synced 2026-02-05 16:40:05 +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.
|
* 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)
|
public function isStaticFile($sitePath, $siteName, $uri)
|
||||||
{
|
{
|
||||||
if (file_exists($staticFilePath = $sitePath.'/webroot/'.$uri)) {
|
if ($this->isActualFile($staticFilePath = $sitePath.'/webroot/'.$uri)) {
|
||||||
return $staticFilePath;
|
return $staticFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class ContaoValetDriver extends ValetDriver
|
|||||||
* @param string $sitePath
|
* @param string $sitePath
|
||||||
* @param string $siteName
|
* @param string $siteName
|
||||||
* @param string $uri
|
* @param string $uri
|
||||||
* @return void
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function serves($sitePath, $siteName, $uri)
|
public function serves($sitePath, $siteName, $uri)
|
||||||
{
|
{
|
||||||
@@ -25,7 +25,7 @@ public function serves($sitePath, $siteName, $uri)
|
|||||||
*/
|
*/
|
||||||
public function isStaticFile($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;
|
return $staticFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public function serves($sitePath, $siteName, $uri)
|
|||||||
*/
|
*/
|
||||||
public function isStaticFile($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;
|
return $staticFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ public function serves($sitePath, $siteName, $uri)
|
|||||||
*/
|
*/
|
||||||
public function isStaticFile($sitePath, $siteName, $uri)
|
public function isStaticFile($sitePath, $siteName, $uri)
|
||||||
{
|
{
|
||||||
if (file_exists($sitePath.$uri) && ! is_dir($sitePath.$uri)) {
|
if ($this->isActualFile($staticFilePath = $sitePath.$uri)) {
|
||||||
return $sitePath.$uri;
|
return $staticFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -36,8 +36,7 @@ public function isStaticFile($sitePath, $siteName, $uri)
|
|||||||
$storageUri = substr($uri, 8);
|
$storageUri = substr($uri, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists($storagePath = $sitePath.'/storage/app/public'.$storageUri) &&
|
if ($this->isActualFile($storagePath = $sitePath.'/storage/app/public'.$storageUri)) {
|
||||||
! is_dir($storagePath)) {
|
|
||||||
return $storagePath;
|
return $storagePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public function isStaticFile($sitePath, $siteName, $uri)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists($staticFilePath = $sitePath.$uri)) {
|
if ($this->isActualFile($staticFilePath = $sitePath.$uri)) {
|
||||||
return $staticFilePath;
|
return $staticFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ public function isStaticFile($sitePath, $siteName, $uri)
|
|||||||
return false;
|
return false;
|
||||||
} elseif (strpos($uri, '/local') === 0 || strpos($uri, '/statamic') === 0) {
|
} elseif (strpos($uri, '/local') === 0 || strpos($uri, '/statamic') === 0) {
|
||||||
return false;
|
return false;
|
||||||
} elseif (file_exists($staticFilePath = $sitePath.$uri)) {
|
} elseif ($this->isActualFile($staticFilePath = $sitePath.$uri)) {
|
||||||
return $staticFilePath;
|
return $staticFilePath;
|
||||||
} elseif (file_exists($staticFilePath = $sitePath.'/public'.$uri)) {
|
} elseif ($this->isActualFile($staticFilePath = $sitePath.'/public'.$uri)) {
|
||||||
return $staticFilePath;
|
return $staticFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public function serves($sitePath, $siteName, $uri)
|
|||||||
*/
|
*/
|
||||||
public function isStaticFile($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;
|
return $staticFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -126,4 +126,15 @@ public function serveStaticFile($staticFilePath, $sitePath, $siteName, $uri)
|
|||||||
|
|
||||||
readfile($staticFilePath);
|
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