Skip to content
This repository was archived by the owner on Dec 9, 2019. It is now read-only.

Commit 49b6737

Browse files
nnnmscpriego
authored andcommitted
Add CakePHP 2 driver (cpriego#126)
Brought to you by @nnnms
1 parent ebd4d1f commit 49b6737

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

cli/drivers/Cake2ValetDriver.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
class Cake2ValetDriver extends ValetDriver
4+
{
5+
6+
/**
7+
* Determine if the driver serves the request.
8+
*
9+
* @param string $sitePath
10+
* @param string $siteName
11+
* @param string $uri
12+
* @return bool
13+
*/
14+
public function serves($sitePath, $siteName, $uri)
15+
{
16+
return file_exists($sitePath . '/Console/cake');
17+
}
18+
19+
/**
20+
* Determine if the incoming request is for a static file.
21+
*
22+
* @param string $sitePath
23+
* @param string $siteName
24+
* @param string $uri
25+
* @return string|false
26+
*/
27+
public function isStaticFile($sitePath, $siteName, $uri)
28+
{
29+
if ($this->isActualFile($staticFilePath = $sitePath . '/webroot/' . $uri)) {
30+
return $staticFilePath;
31+
}
32+
33+
return false;
34+
}
35+
36+
/**
37+
* Get the fully resolved path to the application's front controller.
38+
*
39+
* @param string $sitePath
40+
* @param string $siteName
41+
* @param string $uri
42+
* @return string
43+
*/
44+
public function frontControllerPath($sitePath, $siteName, $uri)
45+
{
46+
$_SERVER['DOCUMENT_ROOT'] = $sitePath . '/webroot';
47+
$_SERVER['SCRIPT_FILENAME'] = $sitePath . '/webroot/index.php';
48+
$_SERVER['SCRIPT_NAME'] = '/index.php';
49+
$_SERVER['PHP_SELF'] = '/index.php';
50+
51+
return $sitePath . '/webroot/index.php';
52+
}
53+
}

cli/drivers/ValetDriver.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public static function assign($sitePath, $siteName, $uri)
6060
$drivers[] = 'StatamicValetDriver';
6161
$drivers[] = 'StatamicV1ValetDriver';
6262
$drivers[] = 'CakeValetDriver';
63+
$drivers[] = 'Cake2ValetDriver';
6364
$drivers[] = 'SculpinValetDriver';
6465
$drivers[] = 'JigsawValetDriver';
6566
$drivers[] = 'KirbyValetDriver';

cli/drivers/require.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
require_once __DIR__.'/ContaoValetDriver.php';
2323
require_once __DIR__.'/KatanaValetDriver.php';
2424
require_once __DIR__.'/CakeValetDriver.php';
25+
require_once __DIR__.'/Cake2ValetDriver.php';
2526
require_once __DIR__.'/JoomlaValetDriver.php';
2627
require_once __DIR__.'/DrupalValetDriver.php';
2728
require_once __DIR__.'/Concrete5ValetDriver.php';

0 commit comments

Comments
 (0)