mirror of
https://github.com/laravel/valet.git
synced 2026-02-05 08:30:07 +01:00
tweaks to drivers. add jigsaw
This commit is contained in:
28
drivers/JigsawValetDriver.php
Normal file
28
drivers/JigsawValetDriver.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
class JigsawValetDriver extends StaticValetDriver
|
||||
{
|
||||
/**
|
||||
* Mutate the incoming URI.
|
||||
*
|
||||
* @param string $uri
|
||||
* @return string
|
||||
*/
|
||||
public function mutateUri($uri)
|
||||
{
|
||||
return rtrim('/build_local'.$uri, '/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the driver serves the request.
|
||||
*
|
||||
* @param string $sitePath
|
||||
* @param string $siteName
|
||||
* @param string $uri
|
||||
* @return void
|
||||
*/
|
||||
public function serves($sitePath, $siteName, $uri)
|
||||
{
|
||||
return is_dir($sitePath.'/build_local');
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ class StaticValetDriver extends ValetDriver
|
||||
*/
|
||||
public function serves($sitePath, $siteName, $uri)
|
||||
{
|
||||
return file_exists($sitePath.'/index.html');
|
||||
return $this->isStaticFile($sitePath, $siteName, $uri) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,14 +44,15 @@ public static function assign($sitePath, $siteName, $uri)
|
||||
{
|
||||
$drivers = static::driversIn(VALET_HOME_PATH.'/Drivers');
|
||||
|
||||
$drivers[] = 'StatamicValetDriver';
|
||||
$drivers[] = 'LaravelValetDriver';
|
||||
$drivers[] = 'StatamicValetDriver';
|
||||
$drivers[] = 'JigsawValetDriver';
|
||||
$drivers[] = 'StaticValetDriver';
|
||||
|
||||
foreach ($drivers as $driver) {
|
||||
$driver = new $driver;
|
||||
|
||||
if ($driver->serves($sitePath, $siteName, $uri)) {
|
||||
if ($driver->serves($sitePath, $siteName, $driver->mutateUri($uri))) {
|
||||
return $driver;
|
||||
}
|
||||
}
|
||||
@@ -82,6 +83,17 @@ public static function driversIn($path)
|
||||
return $drivers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutate the incoming URI.
|
||||
*
|
||||
* @param string $uri
|
||||
* @return string
|
||||
*/
|
||||
public function mutateUri($uri)
|
||||
{
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serve the static file at the given path.
|
||||
*
|
||||
|
||||
@@ -65,6 +65,7 @@ function show_valet_404()
|
||||
require_once __DIR__.'/drivers/StatamicValetDriver.php';
|
||||
require_once __DIR__.'/drivers/LaravelValetDriver.php';
|
||||
require_once __DIR__.'/drivers/StaticValetDriver.php';
|
||||
require_once __DIR__.'/drivers/JigsawValetDriver.php';
|
||||
|
||||
$valetDriver = ValetDriver::assign($valetSitePath, $siteName, $uri);
|
||||
|
||||
@@ -75,6 +76,8 @@ function show_valet_404()
|
||||
/**
|
||||
* Dispatch the request.
|
||||
*/
|
||||
$uri = $valetDriver->mutateUri($uri);
|
||||
|
||||
if ($uri !== '/' && $staticFilePath = $valetDriver->isStaticFile($valetSitePath, $siteName, $uri)) {
|
||||
return $valetDriver->serveStaticFile($staticFilePath, $valetSitePath, $siteName, $uri);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user