mirror of
https://github.com/laravel/valet.git
synced 2026-02-08 01:10:08 +01:00
Update drivers location and loading
- Extract much of server.php into a `Server` class - Move all but the Laravel and Basic drivers into a subfolder - Load all but the Laravel and Basic drivers via glob - Add `beforeLoading` hook to simplify the `frontControllerPath` method for some drivers
This commit is contained in:
61
cli/Valet/Drivers/Specific/SculpinValetDriver.php
Normal file
61
cli/Valet/Drivers/Specific/SculpinValetDriver.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Valet\Drivers\Specific;
|
||||
|
||||
use Valet\Drivers\BasicValetDriver;
|
||||
|
||||
class SculpinValetDriver extends BasicValetDriver
|
||||
{
|
||||
/**
|
||||
* Determine if the driver serves the request.
|
||||
*
|
||||
* @param string $sitePath
|
||||
* @param string $siteName
|
||||
* @param string $uri
|
||||
* @return bool
|
||||
*/
|
||||
public function serves(string $sitePath, string $siteName, string $uri): bool
|
||||
{
|
||||
return $this->isModernSculpinProject($sitePath) ||
|
||||
$this->isLegacySculpinProject($sitePath);
|
||||
}
|
||||
|
||||
private function isModernSculpinProject($sitePath)
|
||||
{
|
||||
return is_dir($sitePath.'/source') &&
|
||||
is_dir($sitePath.'/output_dev') &&
|
||||
$this->composerRequiresSculpin($sitePath);
|
||||
}
|
||||
|
||||
private function isLegacySculpinProject($sitePath)
|
||||
{
|
||||
return is_dir($sitePath.'/.sculpin');
|
||||
}
|
||||
|
||||
private function composerRequiresSculpin($sitePath)
|
||||
{
|
||||
if (! file_exists($sitePath.'/composer.json')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$composer_json_source = file_get_contents($sitePath.'/composer.json');
|
||||
$composer_json = json_decode($composer_json_source, true);
|
||||
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return isset($composer_json['require']['sculpin/sculpin']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutate the incoming URI.
|
||||
*
|
||||
* @param string $uri
|
||||
* @return string
|
||||
*/
|
||||
public function mutateUri(string $uri): string
|
||||
{
|
||||
return rtrim('/output_dev'.$uri, '/');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user