forked from weprovide/valet-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MagentoValetDriver.php
44 lines (37 loc) · 1.3 KB
/
MagentoValetDriver.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
class MagentoValetDriver extends BasicValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return bool
*/
public function serves($sitePath, $siteName, $uri)
{
return is_dir($sitePath.'/app/code/core/Mage');
}
public function configure($devtools, $url) {
info('Configuring Magento...');
$sitePath = getcwd();
if(!file_exists($sitePath.'/app/etc/local.xml')) {
info('local.xml missing. Installing default local.xml...');
$devtools->files->putAsUser(
$sitePath.'/app/etc/local.xml',
str_replace(
'DBNAME',
$devtools->mysql->getDirName(),
$devtools->files->get(__DIR__.'/../stubs/magento/local.xml')
)
);
}
info('Setting base url...');
$devtools->cli->quietlyAsUser('n98-magerun config:set web/unsecure/base_url ' . $url . '/');
$devtools->cli->quietlyAsUser('n98-magerun config:set web/secure/base_url ' . $url . '/');
info('Flushing cache...');
$devtools->cli->quietlyAsUser('n98-magerun cache:flush');
info('Configured Magento');
}
}