-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve compatibility issues with latest Valet (#44)
* fix sanitization of site_name * add ValetConfig * add Config facade * bind config to ValetConfig implementations * replace Valet::domain with Config * remove unused domain methods
- Loading branch information
1 parent
ab3dedb
commit 783a3a7
Showing
7 changed files
with
60 additions
and
30 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace WP_CLI_Valet; | ||
|
||
/** | ||
* @method static get(string $key) | ||
*/ | ||
class Config extends Facade | ||
{ | ||
public static function getContainerKey() | ||
{ | ||
return 'config'; | ||
} | ||
} |
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace WP_CLI_Valet; | ||
|
||
class ValetConfig | ||
{ | ||
protected $data; | ||
|
||
/** | ||
* ValetConfig constructor. | ||
* | ||
* @param $data | ||
*/ | ||
public function __construct($data) | ||
{ | ||
$this->data = $data; | ||
} | ||
|
||
/** | ||
* @throws \Exception | ||
*/ | ||
public static function loadSystem() | ||
{ | ||
$config_path = file_exists("{$_SERVER['HOME']}/.config/valet/config.json") | ||
? "{$_SERVER['HOME']}/.config/valet/config.json" | ||
: "{$_SERVER['HOME']}/.valet/config.json"; | ||
|
||
if (! file_exists($config_path)) { | ||
throw new \Exception('Valet configuration file not found.'); | ||
} | ||
|
||
return new static(json_decode(file_get_contents($config_path), true)); | ||
} | ||
|
||
public function get($key) | ||
{ | ||
return isset($this->data[$key]) ? $this->data[$key] : null; | ||
} | ||
} |