1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-08 09:10:10 +01:00

add statamic driver

This commit is contained in:
Jason Varga
2023-08-28 14:38:42 -04:00
parent 9a4a7a1693
commit 12c10e0b03

View File

@@ -0,0 +1,40 @@
<?php
namespace Valet\Drivers\Specific;
use Valet\Drivers\LaravelValetDriver;
class StatamicV3ValetDriver extends LaravelValetDriver
{
/**
* Determine if the driver serves the request.
*/
public function serves(string $sitePath, string $siteName, string $uri): bool
{
return file_exists($sitePath.'/please')
&& parent::serves($sitePath, $siteName, $uri);
}
/**
* Get the fully resolved path to the application's front controller.
*/
public function frontControllerPath(string $sitePath, string $siteName, string $uri): string
{
if ($this->isActualFile($staticPath = $this->getStaticPath($sitePath))) {
return $staticPath;
}
return parent::frontControllerPath($sitePath, $siteName, $uri);
}
/**
* Get the path to the static file.
*/
protected function getStaticPath(string $sitePath): string
{
$parts = parse_url($_SERVER['REQUEST_URI']);
$query = $parts['query'] ?? '';
return $sitePath.'/public/static'.$parts['path'].'_'.$query.'.html';
}
}