protected function loadFromConfig() { if (!is_file('profiles.yml')) { if (is_file('profiles.yml.encrypted')) { if (class_exists('\\Vault\\Vault')) { try { $configYaml = \Vault\Vault::open('profiles.yml.encrypted'); } catch (\Exception $e) { throw new \Exception('Error decrypting profiles.yml.encrypted', 0, $e); } } else { throw new \Exception('Please install aoepeople/vault'); } } else { throw new \Exception('Could not find profiles.yml or profiles.yml.encrypted'); } } else { $configYaml = file_get_contents('profiles.yml'); } $config = \Symfony\Component\Yaml\Yaml::parse($configYaml); if (!isset($config['profiles'])) { throw new \Exception('Could not find "profiles" key'); } if (!is_array($config['profiles']) || count($config['profiles']) == 0) { throw new \Exception('Could not find any profiles "profiles"'); } return $config['profiles']; }
protected function getDecryptedFilecontent($encryptedFilename) { if (!is_file($encryptedFilename)) { throw new \Symfony\Component\Filesystem\Exception\FileNotFoundException("Could not find encrypted file {$encryptedFilename}"); } if (!class_exists('\\Vault\\Vault')) { throw new \Exception('Please install aoepeople/vault'); } try { return \Vault\Vault::open($encryptedFilename); } catch (\Exception $e) { throw new \Exception('Error decrypting ' . $encryptedFilename, 0, $e); } }