| @@ 186-215 (lines=30) @@ | ||
| 183 | * |
|
| 184 | * @return Builder |
|
| 185 | */ |
|
| 186 | public function getBuilder( |
|
| 187 | array $config = ['debug' => false], |
|
| 188 | array $options = ['verbosity' => Builder::VERBOSITY_NORMAL] |
|
| 189 | ) { |
|
| 190 | if (!file_exists($this->getPath().'/'.self::CONFIG_FILE)) { |
|
| 191 | throw new \Exception(sprintf('Config file not found in "%s"!', $this->getPath())); |
|
| 192 | } |
|
| 193 | // verbosity: verbose |
|
| 194 | if ($options['verbosity'] == Builder::VERBOSITY_VERBOSE) { |
|
| 195 | $this->verbose = true; |
|
| 196 | } |
|
| 197 | // verbosity: quiet |
|
| 198 | if ($options['verbosity'] == Builder::VERBOSITY_QUIET) { |
|
| 199 | $this->quiet = true; |
|
| 200 | } |
|
| 201 | ||
| 202 | try { |
|
| 203 | $configFile = Yaml::parse(file_get_contents($this->getPath().'/'.self::CONFIG_FILE)); |
|
| 204 | $config = array_replace_recursive($configFile, $config); |
|
| 205 | $this->builder = (new Builder($config, $this->messageCallback())) |
|
| 206 | ->setSourceDir($this->getPath()) |
|
| 207 | ->setDestinationDir($this->getPath()); |
|
| 208 | } catch (ParseException $e) { |
|
| 209 | throw new \Exception(sprintf('Config file parse error: %s', $e->getMessage())); |
|
| 210 | } catch (\Exception $e) { |
|
| 211 | throw new \Exception(sprintf($e->getMessage())); |
|
| 212 | } |
|
| 213 | ||
| 214 | return $this->builder; |
|
| 215 | } |
|
| 216 | ||
| 217 | /** |
|
| 218 | * Custom message callback function. |
|
| @@ 65-95 (lines=31) @@ | ||
| 62 | * |
|
| 63 | * @return Builder |
|
| 64 | */ |
|
| 65 | public function getBuilder( |
|
| 66 | OutputInterface $output, |
|
| 67 | array $config = ['debug' => false], |
|
| 68 | array $options = ['verbosity' => Builder::VERBOSITY_NORMAL] |
|
| 69 | ) { |
|
| 70 | if (!file_exists($this->getPath().'/'.self::CONFIG_FILE)) { |
|
| 71 | throw new \Exception(sprintf('Config file not found in "%s"!', $this->getPath())); |
|
| 72 | } |
|
| 73 | // verbosity: verbose |
|
| 74 | if ($options['verbosity'] == Builder::VERBOSITY_VERBOSE) { |
|
| 75 | $this->verbose = true; |
|
| 76 | } |
|
| 77 | // verbosity: quiet |
|
| 78 | if ($options['verbosity'] == Builder::VERBOSITY_QUIET) { |
|
| 79 | $this->quiet = true; |
|
| 80 | } |
|
| 81 | ||
| 82 | try { |
|
| 83 | $configFile = Yaml::parse(file_get_contents($this->getPath().'/'.self::CONFIG_FILE)); |
|
| 84 | $config = array_replace_recursive($configFile, $config); |
|
| 85 | $this->builder = (new Builder($config, $this->messageCallback($output))) |
|
| 86 | ->setSourceDir($this->getPath()) |
|
| 87 | ->setDestinationDir($this->getPath()); |
|
| 88 | } catch (ParseException $e) { |
|
| 89 | throw new \Exception(sprintf('Config file parse error: %s', $e->getMessage())); |
|
| 90 | } catch (\Exception $e) { |
|
| 91 | throw new \Exception(sprintf($e->getMessage())); |
|
| 92 | } |
|
| 93 | ||
| 94 | return $this->builder; |
|
| 95 | } |
|
| 96 | ||
| 97 | /** |
|
| 98 | * @param OutputInterface $output |
|