Accept different types/formats from clients
Currently only the default Options type and the vscode format are accepted.pull/668/head
parent
ca225ff6a6
commit
c4568bfc34
|
@ -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) {
|
||||
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);
|
||||
|
||||
if (empty($changedOptions)) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (get_object_vars($settings) as $prop => $val) {
|
||||
$this->options->$prop = $val;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue