1
0
Fork 0

Accept different types/formats from clients

Currently only the default Options type and the vscode format are accepted.
pull/668/head
Jürgen Steitz 2017-03-04 12:32:10 +01:00
parent ca225ff6a6
commit c4568bfc34
1 changed files with 24 additions and 2 deletions

View File

@ -216,16 +216,38 @@ class Workspace
} }
/** /**
* @param Options|null $settings * Fires when client changes settings in the client
*
* The default paramter type is Options but it also accepts different types
* which will be transformed on demand.
*
* Currently only the vscode format is supported
*
* @param mixed|null $settings
* @return void
*/ */
public function didChangeConfiguration(Options $settings = null) public function didChangeConfiguration($settings = null)
{ {
if ($settings === null) { if ($settings === null) {
return; return;
} }
// VSC sends the settings with the config section as main key
if ($settings instanceof \stdClass && $settings->phpIntelliSense) {
$mapper = new \JsonMapper();
$settings = $mapper->map($settings->phpIntelliSense, new Options);
}
if (!($settings instanceof Options)) {
return;
}
$changedOptions = $this->getChangedOptions($settings); $changedOptions = $this->getChangedOptions($settings);
if (empty($changedOptions)) {
return;
}
foreach (get_object_vars($settings) as $prop => $val) { foreach (get_object_vars($settings) as $prop => $val) {
$this->options->$prop = $val; $this->options->$prop = $val;
} }