Created
August 12, 2016 09:23
-
-
Save LasseRafn/c753050c4a81f543b47da8145b59c91e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
?php | |
class Prestashop1ValetDriver extends ValetDriver | |
{ | |
/** | |
* Determine if the driver serves the request. | |
* | |
* @param string $sitePath | |
* @param string $siteName | |
* @param string $uri | |
* @return boolean | |
*/ | |
public function serves($sitePath, $siteName, $uri) | |
{ | |
return file_exists($sitePath . '/classes/PrestaShopAutoload.php') | |
&& file_exists($sitePath . '/config/config.inc.php'); | |
} | |
/** | |
* Determine if the incoming request is for a static file. | |
* | |
* @param string $sitePath | |
* @param string $siteName | |
* @param string $uri | |
* @return string|false | |
*/ | |
public function isStaticFile($sitePath, $siteName, $uri) | |
{ | |
if (( | |
(file_exists($staticFilePath = $sitePath . $uri)) | |
|| (file_exists($staticFilePath = $sitePath . '/install/' . $uri)) | |
|| (file_exists($staticFilePath = $sitePath . '/admin/' . $uri)) | |
|| (file_exists($staticFilePath = $sitePath . '/themes/' . $uri)) | |
) && !is_dir($staticFilePath)) | |
{ | |
return $staticFilePath; | |
} | |
return false; | |
} | |
/** | |
* Get the fully resolved path to the application's front controller. | |
* | |
* @param string $sitePath | |
* @param string $siteName | |
* @param string $uri | |
* @return string | |
*/ | |
public function frontControllerPath($sitePath, $siteName, $uri) | |
{ | |
if(strpos($uri, '/api') !== false) | |
{ | |
return $sitePath . '/webservice/dispatcher.php'; | |
} | |
if(strpos($uri, '/install') !== false) | |
{ | |
return $sitePath . '/install/index.php'; | |
} | |
if(strpos($uri, '/install') !== false) | |
{ | |
return $sitePath . '/install/index.php'; | |
} | |
if(strpos($uri, '/admin') !== false) | |
{ | |
$path = $sitePath; | |
$results = scandir($path); | |
foreach($results as $result) | |
{ | |
if( $result === '.' || $result === '..' || strpos($result, 'admin') === false || !is_dir($path . '/' . $result)) continue; | |
return $path . '/' . $result . '/index.php'; | |
} | |
return $sitePath . '/admin/index.php'; | |
} | |
return $sitePath . '/index.php'; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment