Loading src/UnicaenDbImport/Config/ConfigException.php +20 −1 Original line number Diff line number Diff line Loading @@ -6,9 +6,28 @@ use UnicaenApp\Exception\RuntimeException; class ConfigException extends RuntimeException { public static function missingKeyInImport($key, $name = null) { return $name ? new static("Le tableau de config de l'import '$name' doit contenir une clé '$key'") : new static("Le tableau de config d'un import ne contient pas la clé '$key' attendue"); } public static function missingKeyInSynchro($key, $name = null) { return $name ? new static("Le tableau de config de la synchro '$name' doit contenir une clé '$key'") : new static("Le tableau de config d'une synchro ne contient pas la clé '$key' attendue"); } public static function missingRootKey($key) { return new static("La config de l'appli doit contenir la clé '$key' contenant la config du module"); } public static function missingKey($key) { return new static("Clé de config '$key' introuvable"); return new static("Le tableau de config du module doit contenir la clé '$key'"); } public static function missingKeyInConnections($key) Loading src/UnicaenDbImport/Config/ConfigFactory.php +17 −7 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ use Zend\ServiceManager\ServiceLocatorInterface; class ConfigFactory { const CONFIG_KEY = 'import'; const CONFIG_ROOT_KEY = 'import'; /** * @var ServiceLocatorInterface Loading Loading @@ -74,8 +74,8 @@ class ConfigFactory { $appConfig = $this->container->get('Config'); if (!array_key_exists($key = self::CONFIG_KEY, $appConfig)) { throw ConfigException::missingKey($key); if (!array_key_exists($key = self::CONFIG_ROOT_KEY, $appConfig)) { throw ConfigException::missingRootKey($key); } return $appConfig[$key]; Loading Loading @@ -185,11 +185,16 @@ class ConfigFactory */ private function createImport(array $importConfig) { if (!array_key_exists($key = 'name', $importConfig)) { throw ConfigException::missingKeyInImport($key); } $name = $importConfig['name']; if (!array_key_exists($key = 'source', $importConfig)) { throw ConfigException::missingKey($key); throw ConfigException::missingKeyInImport($key, $name); } if (!array_key_exists($key = 'destination', $importConfig)) { throw ConfigException::missingKey($key); throw ConfigException::missingKeyInImport($key, $name); } $source = $this->createSource($importConfig['source']); Loading Loading @@ -222,11 +227,16 @@ class ConfigFactory */ private function createSynchro(array $synchroConfig) { if (!array_key_exists($key = 'name', $synchroConfig)) { throw ConfigException::missingKeyInImport($key); } $name = $synchroConfig['name']; if (!array_key_exists($key = 'source', $synchroConfig)) { throw ConfigException::missingKey($key); throw ConfigException::missingKeyInSynchro($key, $name); } if (!array_key_exists($key = 'destination', $synchroConfig)) { throw ConfigException::missingKey($key); throw ConfigException::missingKeyInSynchro($key, $name); } $source = $this->createSource($synchroConfig['source']); Loading Loading
src/UnicaenDbImport/Config/ConfigException.php +20 −1 Original line number Diff line number Diff line Loading @@ -6,9 +6,28 @@ use UnicaenApp\Exception\RuntimeException; class ConfigException extends RuntimeException { public static function missingKeyInImport($key, $name = null) { return $name ? new static("Le tableau de config de l'import '$name' doit contenir une clé '$key'") : new static("Le tableau de config d'un import ne contient pas la clé '$key' attendue"); } public static function missingKeyInSynchro($key, $name = null) { return $name ? new static("Le tableau de config de la synchro '$name' doit contenir une clé '$key'") : new static("Le tableau de config d'une synchro ne contient pas la clé '$key' attendue"); } public static function missingRootKey($key) { return new static("La config de l'appli doit contenir la clé '$key' contenant la config du module"); } public static function missingKey($key) { return new static("Clé de config '$key' introuvable"); return new static("Le tableau de config du module doit contenir la clé '$key'"); } public static function missingKeyInConnections($key) Loading
src/UnicaenDbImport/Config/ConfigFactory.php +17 −7 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ use Zend\ServiceManager\ServiceLocatorInterface; class ConfigFactory { const CONFIG_KEY = 'import'; const CONFIG_ROOT_KEY = 'import'; /** * @var ServiceLocatorInterface Loading Loading @@ -74,8 +74,8 @@ class ConfigFactory { $appConfig = $this->container->get('Config'); if (!array_key_exists($key = self::CONFIG_KEY, $appConfig)) { throw ConfigException::missingKey($key); if (!array_key_exists($key = self::CONFIG_ROOT_KEY, $appConfig)) { throw ConfigException::missingRootKey($key); } return $appConfig[$key]; Loading Loading @@ -185,11 +185,16 @@ class ConfigFactory */ private function createImport(array $importConfig) { if (!array_key_exists($key = 'name', $importConfig)) { throw ConfigException::missingKeyInImport($key); } $name = $importConfig['name']; if (!array_key_exists($key = 'source', $importConfig)) { throw ConfigException::missingKey($key); throw ConfigException::missingKeyInImport($key, $name); } if (!array_key_exists($key = 'destination', $importConfig)) { throw ConfigException::missingKey($key); throw ConfigException::missingKeyInImport($key, $name); } $source = $this->createSource($importConfig['source']); Loading Loading @@ -222,11 +227,16 @@ class ConfigFactory */ private function createSynchro(array $synchroConfig) { if (!array_key_exists($key = 'name', $synchroConfig)) { throw ConfigException::missingKeyInImport($key); } $name = $synchroConfig['name']; if (!array_key_exists($key = 'source', $synchroConfig)) { throw ConfigException::missingKey($key); throw ConfigException::missingKeyInSynchro($key, $name); } if (!array_key_exists($key = 'destination', $synchroConfig)) { throw ConfigException::missingKey($key); throw ConfigException::missingKeyInSynchro($key, $name); } $source = $this->createSource($synchroConfig['source']); Loading