| @@ 277-332 (lines=56) @@ | ||
| 274 | /** |
|
| 275 | * {@inheritdoc} |
|
| 276 | */ |
|
| 277 | public function getMigrationPaths($environment = null, $dbReference = null) |
|
| 278 | { |
|
| 279 | $paths = []; |
|
| 280 | ||
| 281 | if (!isset($this->values['paths']['migrations'])) { |
|
| 282 | throw new \UnexpectedValueException('Default migrations path missing from config file'); |
|
| 283 | } |
|
| 284 | ||
| 285 | if (is_string($this->values['paths']['migrations'])) { |
|
| 286 | $this->values['paths']['migrations'] = [$this->values['paths']['migrations']]; |
|
| 287 | } |
|
| 288 | ||
| 289 | if ($environment !== null && $dbReference !== null) { |
|
| 290 | ||
| 291 | $environment = $this->getEnvironment($environment); |
|
| 292 | if (isset($environment[$dbReference]['paths']['migrations'])) { |
|
| 293 | if (!is_array($environment[$dbReference]['paths']['migrations'])) { |
|
| 294 | return [$environment[$dbReference]['paths']['migrations']]; |
|
| 295 | } else { |
|
| 296 | foreach ($environment[$dbReference]['paths']['migrations'] as $namespace => $migrationPath) { |
|
| 297 | $paths[$namespace]= $migrationPath; |
|
| 298 | } |
|
| 299 | if (count($paths) > 0) { |
|
| 300 | $this->values['paths']['migrations']= $paths; |
|
| 301 | } |
|
| 302 | } |
|
| 303 | } |
|
| 304 | } elseif (is_null($environment) && is_null($dbReference)) { |
|
| 305 | if (is_array($this->values['environments'])) { |
|
| 306 | $environments = array_keys($this->values['environments']); |
|
| 307 | ||
| 308 | foreach ($environments as $env) { |
|
| 309 | if (is_array($this->values['environments'][$env])) { |
|
| 310 | foreach ($this->values['environments'][$env] as $dbReference => $properties) { |
|
| 311 | if (!is_array($properties)) { |
|
| 312 | continue; |
|
| 313 | } |
|
| 314 | ||
| 315 | if (!is_array($this->values['environments'][$env][$dbReference]['paths']['migrations'])) { |
|
| 316 | $paths []= $this->values['environments'][$env][$dbReference]['paths']['migrations']; |
|
| 317 | } else { |
|
| 318 | foreach ($this->values['environments'][$env][$dbReference]['paths']['migrations'] as $namespace => $migrationPath) { |
|
| 319 | $paths[$namespace]= $migrationPath; |
|
| 320 | } |
|
| 321 | } |
|
| 322 | } |
|
| 323 | } |
|
| 324 | } |
|
| 325 | if (count($paths) > 0) { |
|
| 326 | $this->values['paths']['migrations']= $paths; |
|
| 327 | } |
|
| 328 | } |
|
| 329 | } |
|
| 330 | ||
| 331 | return $this->values['paths']['migrations']; |
|
| 332 | } |
|
| 333 | ||
| 334 | /** |
|
| 335 | * Gets the base class name for migrations. |
|
| @@ 350-405 (lines=56) @@ | ||
| 347 | /** |
|
| 348 | * {@inheritdoc} |
|
| 349 | */ |
|
| 350 | public function getSeedPaths($environment = null, $dbReference = null) |
|
| 351 | { |
|
| 352 | ||
| 353 | $paths = []; |
|
| 354 | ||
| 355 | if (!isset($this->values['paths']['seeds'])) { |
|
| 356 | throw new \UnexpectedValueException('Seeds path missing from config file'); |
|
| 357 | } |
|
| 358 | ||
| 359 | if (is_string($this->values['paths']['seeds'])) { |
|
| 360 | $this->values['paths']['seeds'] = [$this->values['paths']['seeds']]; |
|
| 361 | } |
|
| 362 | ||
| 363 | if ($environment !== null && $dbReference !== null) { |
|
| 364 | $environment = $this->getEnvironment($environment); |
|
| 365 | if (isset($environment[$dbReference]['paths']['seeds'])) { |
|
| 366 | ||
| 367 | if (!is_array($environment[$dbReference]['paths']['seeds'])) { |
|
| 368 | return [$environment[$dbReference]['paths']['seeds']]; |
|
| 369 | } else { |
|
| 370 | foreach ($environment[$dbReference]['paths']['seeds'] as $namespace => $seedPath) { |
|
| 371 | $paths[$namespace]= $seedPath; |
|
| 372 | } |
|
| 373 | if (count($paths) > 0) { |
|
| 374 | $this->values['paths']['seeds']= $paths; |
|
| 375 | } |
|
| 376 | } |
|
| 377 | } |
|
| 378 | } elseif (is_null($environment) && is_null($dbReference)) { |
|
| 379 | if (is_array($this->values['environments'])) { |
|
| 380 | $environments = array_keys($this->values['environments']); |
|
| 381 | foreach ($environments as $env) { |
|
| 382 | if (is_array($this->values['environments'][$env])) { |
|
| 383 | foreach ($this->values['environments'][$env] as $dbReference => $properties) { |
|
| 384 | if (!is_array($properties)) { |
|
| 385 | continue; |
|
| 386 | } |
|
| 387 | ||
| 388 | if (!is_array($this->values['environments'][$env][$dbReference]['paths']['seeds'])) { |
|
| 389 | $paths []= $this->values['environments'][$env][$dbReference]['paths']['seeds']; |
|
| 390 | } else { |
|
| 391 | foreach ($this->values['environments'][$env][$dbReference]['paths']['seeds'] as $namespace => $migrationPath) { |
|
| 392 | $paths[$namespace]= $migrationPath; |
|
| 393 | } |
|
| 394 | } |
|
| 395 | } |
|
| 396 | } |
|
| 397 | } |
|
| 398 | } |
|
| 399 | if (count($paths) > 0) { |
|
| 400 | $this->values['paths']['seeds']= $paths; |
|
| 401 | } |
|
| 402 | } |
|
| 403 | ||
| 404 | return $this->values['paths']['seeds']; |
|
| 405 | } |
|
| 406 | ||
| 407 | /** |
|
| 408 | * Get the template file name. |
|