private function updateLocalConfiguration($remoteConfiguration) { $localWebHooksConfiguration = $this->configurationStorage->get()['web_hooks']; $remoteWebHooksConfiguration = $remoteConfiguration['web_hooks']; // remove old $localKeysToRemove = []; foreach ($localWebHooksConfiguration as $localKey => $localWebHook) { $found = false; foreach ($remoteWebHooksConfiguration as $remoteWebHook) { if ($localWebHook['endpoint'] == $remoteWebHook['endpoint']) { $found = true; break; } } if (!$found) { $localKeysToRemove[] = $localKey; } } $removedEndpoints = []; foreach ($localKeysToRemove as $localKeyToRemove) { $removedEndpoints[] = $localWebHooksConfiguration[$localKeyToRemove]['endpoint']; unset($localWebHooksConfiguration[$localKeyToRemove]); } if (count($removedEndpoints)) { $this->io->writeln('Endpoint(s) "' . implode(', ', $removedEndpoints) . '" removed from local configuration as it/they does not exists anymore on the server.'); } // add new $addedEndpoints = []; foreach ($remoteWebHooksConfiguration as $key => $remoteWebHook) { if (!$this->getLocalWebHookConfigurationBy('endpoint', $remoteWebHook['endpoint'])) { $localWebHooksConfiguration[] = $remoteWebHook; $addedEndpoints[] = $remoteWebHook['endpoint']; } } if (count($addedEndpoints)) { $this->io->writeln('Endpoint(s) ' . implode(', ', $addedEndpoints) . ' added to the local configuration as it/they has been configured on the server.'); } $remoteConfiguration['web_hooks'] = array_values($localWebHooksConfiguration); $this->configurationStorage->replaceConfiguration($remoteConfiguration)->save(); }
protected function execute(InputInterface $input, OutputInterface $output) { $this->configurationStorage = new ConfigurationStorage(false); $this->configurationStorage->deleteFile(); }