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