@@ -49,7 +49,7 @@ |
||
| 49 | 49 | * |
| 50 | 50 | * @return $this |
| 51 | 51 | */ |
| 52 | - public function mergePropertiesFromArray(array $data=[]) |
|
| 52 | + public function mergePropertiesFromArray(array $data = []) |
|
| 53 | 53 | { |
| 54 | 54 | if ($this->verifyArray($data)) { |
| 55 | 55 | $this->data = array_merge($data, $this->data); |
@@ -81,11 +81,11 @@ discard block |
||
| 81 | 81 | * @param Blender $blender |
| 82 | 82 | * @param string|array $unique_value |
| 83 | 83 | */ |
| 84 | - public function __construct(\modx $modx, Blender $blender, $unique_value='') |
|
| 84 | + public function __construct(\modx $modx, Blender $blender, $unique_value = '') |
|
| 85 | 85 | { |
| 86 | 86 | $this->modx = $modx; |
| 87 | 87 | $this->blender = $blender; |
| 88 | - if (method_exists($this, 'loadProperties') ) { |
|
| 88 | + if (method_exists($this, 'loadProperties')) { |
|
| 89 | 89 | $this->loadProperties(); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -134,9 +134,9 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | public function setSeedsDir($dir) |
| 136 | 136 | { |
| 137 | - $this->seeds_dir = (string) $dir; |
|
| 137 | + $this->seeds_dir = (string)$dir; |
|
| 138 | 138 | if (!empty($this->seeds_dir)) { |
| 139 | - $this->cacheOptions[\xPDO::OPT_CACHE_PATH] = $this->blender->getSeedsPath() . $dir . '/'; |
|
| 139 | + $this->cacheOptions[\xPDO::OPT_CACHE_PATH] = $this->blender->getSeedsPath().$dir.'/'; |
|
| 140 | 140 | } |
| 141 | 141 | return $this; |
| 142 | 142 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * @param string $type ~ seed or revert |
| 170 | 170 | * @return string |
| 171 | 171 | */ |
| 172 | - public function getSeedKey($type='seed') |
|
| 172 | + public function getSeedKey($type = 'seed') |
|
| 173 | 173 | { |
| 174 | 174 | $name = $this->blendable_xpdo_simple_object_data[$this->unique_key_column]; |
| 175 | 175 | if (method_exists($this, 'getFieldName')) { |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | switch ($type) { |
| 181 | 181 | case 'revert': |
| 182 | - $seed_key = 'revert-' . $key; |
|
| 182 | + $seed_key = 'revert-'.$key; |
|
| 183 | 183 | break; |
| 184 | 184 | |
| 185 | 185 | case 'seed': |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | * @param bool $overwrite |
| 205 | 205 | * @return bool |
| 206 | 206 | */ |
| 207 | - public function blendFromArray($data, $overwrite=false) |
|
| 207 | + public function blendFromArray($data, $overwrite = false) |
|
| 208 | 208 | { |
| 209 | 209 | if (isset($data['columns'])) { |
| 210 | 210 | $this->blendable_xpdo_simple_object_data = $data['columns']; |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * |
| 230 | 230 | * @return bool |
| 231 | 231 | */ |
| 232 | - public function blendFromSeed($seed_key, $overwrite=false) |
|
| 232 | + public function blendFromSeed($seed_key, $overwrite = false) |
|
| 233 | 233 | { |
| 234 | 234 | $this->loadObjectDataFromSeed($seed_key); |
| 235 | 235 | return $this->blend($overwrite); |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | * |
| 241 | 241 | * @return bool |
| 242 | 242 | */ |
| 243 | - public function blend($overwrite=false) |
|
| 243 | + public function blend($overwrite = false) |
|
| 244 | 244 | { |
| 245 | 245 | if ($this->type == 'blend') { |
| 246 | 246 | /** @var \LCI\Blend\Blendable\Blendable $currentVersion */ |
@@ -285,26 +285,26 @@ discard block |
||
| 285 | 285 | * @param bool $make_revert_seed |
| 286 | 286 | * @return bool |
| 287 | 287 | */ |
| 288 | - public function delete($make_revert_seed=true) |
|
| 288 | + public function delete($make_revert_seed = true) |
|
| 289 | 289 | { |
| 290 | 290 | if ($make_revert_seed) { |
| 291 | 291 | $this->seed('revert'); |
| 292 | 292 | } |
| 293 | 293 | $removed = false; |
| 294 | 294 | if (!is_object($this->xPDOSimpleObject)) { |
| 295 | - $this->blender->out($this->blendable_xpdo_simple_object_data[$this->unique_key_column] . ' of xPDO class '. |
|
| 295 | + $this->blender->out($this->blendable_xpdo_simple_object_data[$this->unique_key_column].' of xPDO class '. |
|
| 296 | 296 | $this->xpdo_simple_object_class.' was not found, could not be removed/deleted', true); |
| 297 | 297 | |
| 298 | 298 | } elseif ($this->xPDOSimpleObject->remove()) { |
| 299 | 299 | $this->onDeleteRevertRelatedPieces(); |
| 300 | 300 | if ($this->isDebug()) { |
| 301 | - $this->blender->out($this->blendable_xpdo_simple_object_data[$this->unique_key_column] . ' has been removed/deleted'); |
|
| 301 | + $this->blender->out($this->blendable_xpdo_simple_object_data[$this->unique_key_column].' has been removed/deleted'); |
|
| 302 | 302 | } |
| 303 | 303 | $removed = true; |
| 304 | 304 | |
| 305 | 305 | } else { |
| 306 | 306 | if ($this->isDebug()) { |
| 307 | - $this->blender->out($this->blendable_xpdo_simple_object_data[$this->unique_key_column] . ' did not remove/delete', true); |
|
| 307 | + $this->blender->out($this->blendable_xpdo_simple_object_data[$this->unique_key_column].' did not remove/delete', true); |
|
| 308 | 308 | } |
| 309 | 309 | } |
| 310 | 310 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | * @param string $type ~ seed or revert |
| 330 | 330 | * @return string ~ the related seed key |
| 331 | 331 | */ |
| 332 | - public function seed($type='seed') |
|
| 332 | + public function seed($type = 'seed') |
|
| 333 | 333 | { |
| 334 | 334 | $data = false; |
| 335 | 335 | // No IDs! must get the alias and get a seed key, |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | * @param string $seed_key |
| 354 | 354 | * @return array |
| 355 | 355 | */ |
| 356 | - public function seedToArray($type='seed', $seed_key='') |
|
| 356 | + public function seedToArray($type = 'seed', $seed_key = '') |
|
| 357 | 357 | { |
| 358 | 358 | if (is_object($this->xPDOSimpleObject)) { |
| 359 | 359 | $this->current_xpdo_simple_object_data = $this->xPDOSimpleObject->toArray(); |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | } |
| 365 | 365 | // Any child class can create a seed method, an example for modResource: |
| 366 | 366 | // seedTemplate(1) and would return the string name |
| 367 | - $method = 'seed' . $this->makeStudyCase($column); |
|
| 367 | + $method = 'seed'.$this->makeStudyCase($column); |
|
| 368 | 368 | if (method_exists($this, $method)) { |
| 369 | 369 | $value = $this->$method($value); |
| 370 | 370 | } |
@@ -420,15 +420,15 @@ discard block |
||
| 420 | 420 | * |
| 421 | 421 | * @return bool |
| 422 | 422 | */ |
| 423 | - protected function save($overwrite=false) |
|
| 423 | + protected function save($overwrite = false) |
|
| 424 | 424 | { |
| 425 | 425 | $saved = false; |
| 426 | 426 | |
| 427 | 427 | if (is_object($this->xPDOSimpleObject)) { |
| 428 | 428 | if (!$overwrite) { |
| 429 | 429 | $this->error = true; |
| 430 | - $this->error_messages['exits'] = $this->xpdo_simple_object_class.': ' . |
|
| 431 | - $this->blendable_xpdo_simple_object_data[$this->unique_key_column] . ' already exists '; |
|
| 430 | + $this->error_messages['exits'] = $this->xpdo_simple_object_class.': '. |
|
| 431 | + $this->blendable_xpdo_simple_object_data[$this->unique_key_column].' already exists '; |
|
| 432 | 432 | return $saved; |
| 433 | 433 | } |
| 434 | 434 | } else { |
@@ -456,13 +456,13 @@ discard block |
||
| 456 | 456 | if ($this->xPDOSimpleObject->save()) { |
| 457 | 457 | $this->attachRelatedPiecesAfterSave(); |
| 458 | 458 | if ($this->isDebug()) { |
| 459 | - $this->blender->out($this->blendable_xpdo_simple_object_data[$this->unique_key_column] . ' has been installed/saved'); |
|
| 459 | + $this->blender->out($this->blendable_xpdo_simple_object_data[$this->unique_key_column].' has been installed/saved'); |
|
| 460 | 460 | } |
| 461 | 461 | $saved = true; |
| 462 | 462 | |
| 463 | 463 | } else { |
| 464 | 464 | if ($this->isDebug()) { |
| 465 | - $this->blender->out($this->blendable_xpdo_simple_object_data[$this->unique_key_column] . ' did not install/update', true); |
|
| 465 | + $this->blender->out($this->blendable_xpdo_simple_object_data[$this->unique_key_column].' did not install/update', true); |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | } |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | * |
| 510 | 510 | * @return $this |
| 511 | 511 | */ |
| 512 | - protected function loadFromArray($data=[]) |
|
| 512 | + protected function loadFromArray($data = []) |
|
| 513 | 513 | { |
| 514 | 514 | foreach ($data as $column => $value) { |
| 515 | 515 | $method_name = 'seed'.$this->makeStudyCase($column); |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | } |
| 538 | 538 | $this->$method_name($value); |
| 539 | 539 | |
| 540 | - } elseif($this->isDebug()) { |
|
| 540 | + } elseif ($this->isDebug()) { |
|
| 541 | 541 | $this->blender->out(__METHOD__.' missing: '.$method_name.' V: '.$value, true); |
| 542 | 542 | } |
| 543 | 543 | } |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | /** |
| 627 | 627 | * @var string $type blend or revert |
| 628 | 628 | */ |
| 629 | - protected function seedRelated($type='blend') |
|
| 629 | + protected function seedRelated($type = 'blend') |
|
| 630 | 630 | { |
| 631 | 631 | // load related data: |
| 632 | 632 | $this->loadRelatedData(); |
@@ -101,7 +101,7 @@ |
||
| 101 | 101 | foreach ($commands as $command) { |
| 102 | 102 | $class = new $command(); |
| 103 | 103 | |
| 104 | - if (is_object($class) ) { |
|
| 104 | + if (is_object($class)) { |
|
| 105 | 105 | if (method_exists($class, 'setConsole')) { |
| 106 | 106 | $class->setConsole($this->console); |
| 107 | 107 | } |
@@ -31,9 +31,9 @@ |
||
| 31 | 31 | return new InputDefinition(array( |
| 32 | 32 | new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'), |
| 33 | 33 | |
| 34 | - new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message.'), |
|
| 34 | + new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message.'), |
|
| 35 | 35 | //new InputOption('--verbose', '-v|vv|vvv', InputOption::VALUE_NONE, 'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug.'), |
| 36 | - new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display the Blend version.'), |
|
| 36 | + new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display the Blend version.'), |
|
| 37 | 37 | )); |
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | \ No newline at end of file |
@@ -410,7 +410,7 @@ |
||
| 410 | 410 | else { |
| 411 | 411 | try { |
| 412 | 412 | $write = file_put_contents($this->migrations_path . $class_name . '.php', $file_contents); |
| 413 | - $this->log_data = [ |
|
| 413 | + $this->log_data = [ |
|
| 414 | 414 | 'name' => $class_name, |
| 415 | 415 | 'type' => $this->getServerType(), |
| 416 | 416 | 'description' => $this->getDescription(), |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @param UserInteractionHandler $userInteractionHandler |
| 54 | 54 | * @param array $class_data |
| 55 | 55 | */ |
| 56 | - public function __construct(UserInteractionHandler $userInteractionHandler, $class_data=[]) |
|
| 56 | + public function __construct(UserInteractionHandler $userInteractionHandler, $class_data = []) |
|
| 57 | 57 | { |
| 58 | 58 | $this->class_data = $class_data; |
| 59 | 59 | |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | $this->path_time_stamp = date('Y_m_d_His'); |
| 63 | 63 | $this->format = new Format($this->path_time_stamp); |
| 64 | 64 | |
| 65 | - $this->migration_templates_path = __DIR__. '/templates/'; |
|
| 66 | - $this->setBaseMigrationsPath(dirname(__DIR__) . DIRECTORY_SEPARATOR); |
|
| 65 | + $this->migration_templates_path = __DIR__.'/templates/'; |
|
| 66 | + $this->setBaseMigrationsPath(dirname(__DIR__).DIRECTORY_SEPARATOR); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -71,20 +71,20 @@ discard block |
||
| 71 | 71 | * @param bool $append ~ if true will create database/migrations with in the path |
| 72 | 72 | * @return $this |
| 73 | 73 | */ |
| 74 | - public function setMigrationsPath($path, $append=false) |
|
| 74 | + public function setMigrationsPath($path, $append = false) |
|
| 75 | 75 | { |
| 76 | 76 | $this->migrations_path = $path; |
| 77 | 77 | |
| 78 | 78 | if (file_exists($path) && $append) { |
| 79 | - if (!file_exists($path . 'database')) { |
|
| 80 | - mkdir($path . 'database'); |
|
| 79 | + if (!file_exists($path.'database')) { |
|
| 80 | + mkdir($path.'database'); |
|
| 81 | 81 | } |
| 82 | - if (!file_exists($path . 'database/migrations')) { |
|
| 83 | - mkdir($path . 'database/migrations'); |
|
| 82 | + if (!file_exists($path.'database/migrations')) { |
|
| 83 | + mkdir($path.'database/migrations'); |
|
| 84 | 84 | } |
| 85 | - $this->migrations_path = $path . 'database/migrations/'; |
|
| 85 | + $this->migrations_path = $path.'database/migrations/'; |
|
| 86 | 86 | |
| 87 | - } elseif( !file_exists($path) && !$append) { |
|
| 87 | + } elseif (!file_exists($path) && !$append) { |
|
| 88 | 88 | // @TODO review: |
| 89 | 89 | mkdir($path, 0777, true); |
| 90 | 90 | } |
@@ -96,20 +96,20 @@ discard block |
||
| 96 | 96 | * @param bool $append ~ if true will create database/seeds with in the path |
| 97 | 97 | * @return $this |
| 98 | 98 | */ |
| 99 | - public function setSeedsPath($path, $append=false) |
|
| 99 | + public function setSeedsPath($path, $append = false) |
|
| 100 | 100 | { |
| 101 | 101 | $this->seeds_path = $path; |
| 102 | 102 | |
| 103 | 103 | if (file_exists($path) && $append) { |
| 104 | - if (!file_exists($path . 'database')) { |
|
| 105 | - mkdir($path . 'database'); |
|
| 104 | + if (!file_exists($path.'database')) { |
|
| 105 | + mkdir($path.'database'); |
|
| 106 | 106 | } |
| 107 | - if (!file_exists($path . 'database/seeds')) { |
|
| 108 | - mkdir($path . 'database/seeds'); |
|
| 107 | + if (!file_exists($path.'database/seeds')) { |
|
| 108 | + mkdir($path.'database/seeds'); |
|
| 109 | 109 | } |
| 110 | - $this->seeds_path = $path . 'database/seeds/'; |
|
| 110 | + $this->seeds_path = $path.'database/seeds/'; |
|
| 111 | 111 | |
| 112 | - } elseif( !file_exists($path) && !$append) { |
|
| 112 | + } elseif (!file_exists($path) && !$append) { |
|
| 113 | 113 | // @TODO review: |
| 114 | 114 | mkdir($path, 0777, true); |
| 115 | 115 | } |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | */ |
| 365 | 365 | protected function writeMigrationClassFile() |
| 366 | 366 | { |
| 367 | - $class_name = $this->format->getMigrationName(substr($this->migration_template, 0,-4), $this->name); |
|
| 367 | + $class_name = $this->format->getMigrationName(substr($this->migration_template, 0, -4), $this->name); |
|
| 368 | 368 | |
| 369 | 369 | $placeholders = array_merge( |
| 370 | 370 | [ |
@@ -383,22 +383,22 @@ discard block |
||
| 383 | 383 | |
| 384 | 384 | $file_contents = ''; |
| 385 | 385 | |
| 386 | - $migration_template = $this->migration_templates_path . $this->migration_template; |
|
| 386 | + $migration_template = $this->migration_templates_path.$this->migration_template; |
|
| 387 | 387 | if (file_exists($migration_template)) { |
| 388 | 388 | $file_contents = file_get_contents($migration_template); |
| 389 | 389 | } else { |
| 390 | - $this->out('Migration template file not found: ' . $migration_template, true); |
|
| 390 | + $this->out('Migration template file not found: '.$migration_template, true); |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | foreach ($placeholders as $name => $value) { |
| 394 | 394 | $file_contents = str_replace('[[+'.$name.']]', $value, $file_contents); |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - $this->out($this->migrations_path . $class_name.'.php'); |
|
| 397 | + $this->out($this->migrations_path.$class_name.'.php'); |
|
| 398 | 398 | |
| 399 | 399 | $write = false; |
| 400 | - if (file_exists($this->migrations_path . $class_name . '.php')) { |
|
| 401 | - $this->out($this->migrations_path . $class_name . '.php migration file already exists', true); |
|
| 400 | + if (file_exists($this->migrations_path.$class_name.'.php')) { |
|
| 401 | + $this->out($this->migrations_path.$class_name.'.php migration file already exists', true); |
|
| 402 | 402 | |
| 403 | 403 | } |
| 404 | 404 | /** |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | } */ |
| 410 | 410 | else { |
| 411 | 411 | try { |
| 412 | - $write = file_put_contents($this->migrations_path . $class_name . '.php', $file_contents); |
|
| 412 | + $write = file_put_contents($this->migrations_path.$class_name.'.php', $file_contents); |
|
| 413 | 413 | $this->log_data = [ |
| 414 | 414 | 'name' => $class_name, |
| 415 | 415 | 'type' => $this->getServerType(), |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | if (!$write) { |
| 426 | - $this->out($this->migrations_path . $class_name . '.php Did not write to file', true); |
|
| 426 | + $this->out($this->migrations_path.$class_name.'.php Did not write to file', true); |
|
| 427 | 427 | $this->out('Verify that the folders exists and are writable by PHP', true); |
| 428 | 428 | } |
| 429 | 429 | } |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | * @param string $message |
| 436 | 436 | * @param bool $error |
| 437 | 437 | */ |
| 438 | - public function out($message, $error=false) |
|
| 438 | + public function out($message, $error = false) |
|
| 439 | 439 | { |
| 440 | 440 | if ($error) { |
| 441 | 441 | $this->userInteractionHandler->tellUser($message, userInteractionHandler::MASSAGE_ERROR); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * Format constructor. |
| 18 | 18 | * @param null $path_time_stamp |
| 19 | 19 | */ |
| 20 | - public function __construct($path_time_stamp=null) |
|
| 20 | + public function __construct($path_time_stamp = null) |
|
| 21 | 21 | { |
| 22 | 22 | if (!empty($path_time_stamp)) { |
| 23 | 23 | $this->path_time_stamp = $path_time_stamp; |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @param null $name |
| 32 | 32 | * @return string |
| 33 | 33 | */ |
| 34 | - public function getMigrationName($type, $name=null) |
|
| 34 | + public function getMigrationName($type, $name = null) |
|
| 35 | 35 | { |
| 36 | 36 | $dir_name = 'm'.$this->path_time_stamp.'_'; |
| 37 | 37 | if (empty($name)) { |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return string |
| 54 | 54 | */ |
| 55 | - public function prettyVarExport($data, $tabs=1) |
|
| 55 | + public function prettyVarExport($data, $tabs = 1) |
|
| 56 | 56 | { |
| 57 | - $spacing = str_repeat(' ', 4*$tabs); |
|
| 57 | + $spacing = str_repeat(' ', 4 * $tabs); |
|
| 58 | 58 | |
| 59 | 59 | $string = ''; |
| 60 | 60 | $parts = preg_split('/\R/', var_export($data, true)); |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * @param UserInteractionHandler $userInteractionHandler |
| 82 | 82 | * @param array $config |
| 83 | 83 | */ |
| 84 | - public function __construct(modX $modx, UserInteractionHandler $userInteractionHandler, $config=[]) |
|
| 84 | + public function __construct(modX $modx, UserInteractionHandler $userInteractionHandler, $config = []) |
|
| 85 | 85 | { |
| 86 | 86 | $this->modx = $modx; |
| 87 | 87 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | $this->userInteractionHandler = $userInteractionHandler; |
| 91 | 91 | |
| 92 | - if (version_compare($this->modx_version_info['full_version'], '3.0') >= 0 ) { |
|
| 92 | + if (version_compare($this->modx_version_info['full_version'], '3.0') >= 0) { |
|
| 93 | 93 | $this->xpdo_version = 3; |
| 94 | 94 | $this->blend_class_object = 'LCI\\Blend\\Model\\xPDO\\BlendMigrations'; |
| 95 | 95 | $this->blend_package = 'LCI\\Blend\\Model\\xPDO'; |
@@ -104,10 +104,10 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | $this->config = [ |
| 107 | - 'migration_templates_path' => __DIR__. '/Migrations/templates/', |
|
| 107 | + 'migration_templates_path' => __DIR__.'/Migrations/templates/', |
|
| 108 | 108 | 'migrations_path' => $blend_modx_migration_dir.'database/migrations/', |
| 109 | 109 | 'seeds_path' => $blend_modx_migration_dir.'database/seeds/', |
| 110 | - 'model_dir' => __DIR__ . ($this->xpdo_version >= 3 ? '/' : '/xpdo2/'), |
|
| 110 | + 'model_dir' => __DIR__.($this->xpdo_version >= 3 ? '/' : '/xpdo2/'), |
|
| 111 | 111 | 'extras' => [ |
| 112 | 112 | 'tagger' => false |
| 113 | 113 | ] |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | $this->seeds_dir = date('Y_m_d_His'); |
| 118 | 118 | |
| 119 | - $tagger_path = $this->modx->getOption('tagger.core_path', null, $this->modx->getOption('core_path') . 'components/tagger/') . 'model/tagger/'; |
|
| 119 | + $tagger_path = $this->modx->getOption('tagger.core_path', null, $this->modx->getOption('core_path').'components/tagger/').'model/tagger/'; |
|
| 120 | 120 | if (is_dir($tagger_path)) { |
| 121 | 121 | $this->config['extras']['tagger'] = true; |
| 122 | 122 | /** @var \Tagger $tagger */ |
@@ -178,11 +178,11 @@ discard block |
||
| 178 | 178 | * @param null $directory_key |
| 179 | 179 | * @return string |
| 180 | 180 | */ |
| 181 | - public function getSeedsPath($directory_key=null) |
|
| 181 | + public function getSeedsPath($directory_key = null) |
|
| 182 | 182 | { |
| 183 | 183 | $seed_path = $this->config['seeds_path']; |
| 184 | 184 | if (!empty($directory_key)) { |
| 185 | - $seed_path .= trim($directory_key, '/') . DIRECTORY_SEPARATOR; |
|
| 185 | + $seed_path .= trim($directory_key, '/').DIRECTORY_SEPARATOR; |
|
| 186 | 186 | } |
| 187 | 187 | return $seed_path; |
| 188 | 188 | } |
@@ -204,21 +204,21 @@ discard block |
||
| 204 | 204 | * |
| 205 | 205 | * @return array ~ array of \BlendMigrations |
| 206 | 206 | */ |
| 207 | - public function getBlendMigrationCollection($reload=false, $dir='ASC', $count=0, $id=0, $name=null) |
|
| 207 | + public function getBlendMigrationCollection($reload = false, $dir = 'ASC', $count = 0, $id = 0, $name = null) |
|
| 208 | 208 | { |
| 209 | 209 | if (!$this->blendMigrations || $reload) { |
| 210 | 210 | $blendMigrations = []; |
| 211 | 211 | |
| 212 | 212 | /** @var \xPDOQuery $query */ |
| 213 | 213 | $query = $this->modx->newQuery($this->blend_class_object); |
| 214 | - if ($id > 0 ) { |
|
| 214 | + if ($id > 0) { |
|
| 215 | 215 | $query->where(['id' => $id]); |
| 216 | 216 | } elseif (!empty($name)) { |
| 217 | 217 | $query->where(['name' => $name]); |
| 218 | 218 | } |
| 219 | 219 | // @TODO need a ran sequence column to better order of down |
| 220 | 220 | $query->sortBy('name', $dir); |
| 221 | - if ($count > 0 ) { |
|
| 221 | + if ($count > 0) { |
|
| 222 | 222 | $query->limit($count); |
| 223 | 223 | } |
| 224 | 224 | $query->prepare(); |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | return $this->tagger; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - public function getCategoryMap($refresh=false) |
|
| 245 | + public function getCategoryMap($refresh = false) |
|
| 246 | 246 | { |
| 247 | 247 | if (count($this->category_map) == 0 || $refresh) { |
| 248 | 248 | $this->category_map = [ |
@@ -287,14 +287,14 @@ discard block |
||
| 287 | 287 | public function getBlendableChunk($name) |
| 288 | 288 | { |
| 289 | 289 | /** @var \LCI\Blend\Blendable\Chunk $chunk */ |
| 290 | - $chunk = new Chunk($this->modx, $this, $name); |
|
| 290 | + $chunk = new Chunk($this->modx, $this, $name); |
|
| 291 | 291 | return $chunk->setSeedsDir($this->getSeedsDir()); |
| 292 | 292 | } |
| 293 | 293 | /** |
| 294 | 294 | * @param array $chunks |
| 295 | 295 | * @param string $seeds_dir |
| 296 | 296 | */ |
| 297 | - public function blendManyChunks($chunks=[], $seeds_dir='') |
|
| 297 | + public function blendManyChunks($chunks = [], $seeds_dir = '') |
|
| 298 | 298 | { |
| 299 | 299 | // will update if element does exist or create new |
| 300 | 300 | foreach ($chunks as $seed_key) { |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | if ($blendChunk->blendFromSeed($seed_key)) { |
| 307 | 307 | $this->out($seed_key.' has been blended into ID: '); |
| 308 | 308 | |
| 309 | - } elseif($blendChunk->isExists()) { |
|
| 309 | + } elseif ($blendChunk->isExists()) { |
|
| 310 | 310 | // @TODO prompt Do you want to blend Y/N/Compare |
| 311 | 311 | $this->out($seed_key.' chunk already exists', true); |
| 312 | 312 | if ($this->prompt('Would you like to update?', 'Y') === 'Y') { |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | * @param array $chunks |
| 325 | 325 | * @param string $seeds_dir |
| 326 | 326 | */ |
| 327 | - public function revertBlendManyChunks($chunks=[], $seeds_dir='') |
|
| 327 | + public function revertBlendManyChunks($chunks = [], $seeds_dir = '') |
|
| 328 | 328 | { |
| 329 | 329 | // will update if system setting does exist or create new |
| 330 | 330 | foreach ($chunks as $seed_key) { |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | $blendChunk->setSeedsDir($seeds_dir); |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | - if ( $blendChunk->revertBlend() ) { |
|
| 337 | + if ($blendChunk->revertBlend()) { |
|
| 338 | 338 | $this->out($blendChunk->getFieldName().' chunk has been reverted to '.$seeds_dir); |
| 339 | 339 | |
| 340 | 340 | } else { |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | public function getBlendableContext($key) |
| 352 | 352 | { |
| 353 | 353 | /** @var \LCI\Blend\Blendable\Context $chunk */ |
| 354 | - $context = new Context($this->modx, $this, $key); |
|
| 354 | + $context = new Context($this->modx, $this, $key); |
|
| 355 | 355 | return $context->setSeedsDir($this->getSeedsDir()); |
| 356 | 356 | } |
| 357 | 357 | |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | * @param array $contexts |
| 360 | 360 | * @param string $seeds_dir |
| 361 | 361 | */ |
| 362 | - public function blendManyContexts($contexts=[], $seeds_dir='') |
|
| 362 | + public function blendManyContexts($contexts = [], $seeds_dir = '') |
|
| 363 | 363 | { |
| 364 | 364 | // will update if element does exist or create new |
| 365 | 365 | foreach ($contexts as $seed_key) { |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | if ($blendContext->blendFromSeed($seed_key)) { |
| 372 | 372 | $this->out($seed_key.' has been blended '); |
| 373 | 373 | |
| 374 | - } elseif($blendContext->isExists()) { |
|
| 374 | + } elseif ($blendContext->isExists()) { |
|
| 375 | 375 | // @TODO prompt Do you want to blend Y/N/Compare |
| 376 | 376 | $this->out($seed_key.' chunk already exists', true); |
| 377 | 377 | if ($this->prompt('Would you like to update?', 'Y') === 'Y') { |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | * @param array $contexts |
| 390 | 390 | * @param string $seeds_dir |
| 391 | 391 | */ |
| 392 | - public function revertBlendManyContexts($contexts=[], $seeds_dir='') |
|
| 392 | + public function revertBlendManyContexts($contexts = [], $seeds_dir = '') |
|
| 393 | 393 | { |
| 394 | 394 | // will update if system setting does exist or create new |
| 395 | 395 | foreach ($contexts as $seed_key) { |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | $blendContext->setSeedsDir($seeds_dir); |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | - if ( $blendContext->revertBlend() ) { |
|
| 402 | + if ($blendContext->revertBlend()) { |
|
| 403 | 403 | $this->out($blendContext->getFieldKey().' context has been reverted to '.$seeds_dir); |
| 404 | 404 | |
| 405 | 405 | } else { |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | public function getBlendableMediaSource($name) |
| 417 | 417 | { |
| 418 | 418 | /** @var \LCI\Blend\Blendable\MediaSource $mediaSource */ |
| 419 | - $mediaSource = new MediaSource($this->modx, $this, $name); |
|
| 419 | + $mediaSource = new MediaSource($this->modx, $this, $name); |
|
| 420 | 420 | return $mediaSource |
| 421 | 421 | ->setFieldName($name) |
| 422 | 422 | ->setSeedsDir($this->getSeedsDir()); |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | * @param array $media_sources |
| 427 | 427 | * @param string $seeds_dir |
| 428 | 428 | */ |
| 429 | - public function blendManyMediaSources($media_sources=[], $seeds_dir='') |
|
| 429 | + public function blendManyMediaSources($media_sources = [], $seeds_dir = '') |
|
| 430 | 430 | { |
| 431 | 431 | // will update if element does exist or create new |
| 432 | 432 | foreach ($media_sources as $seed_key) { |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | if ($blendMediaSource->blendFromSeed($seed_key)) { |
| 439 | 439 | $this->out($seed_key.' has been blended into ID: '); |
| 440 | 440 | |
| 441 | - } elseif($blendMediaSource->isExists()) { |
|
| 441 | + } elseif ($blendMediaSource->isExists()) { |
|
| 442 | 442 | // @TODO add Compare as option |
| 443 | 443 | $this->out($seed_key.' media source already exists', true); |
| 444 | 444 | if ($this->prompt('Would you like to update?', 'Y') === 'Y') { |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | * @param array $media_sources |
| 457 | 457 | * @param string $seeds_dir |
| 458 | 458 | */ |
| 459 | - public function revertBlendManyMediaSources($media_sources=[], $seeds_dir='') |
|
| 459 | + public function revertBlendManyMediaSources($media_sources = [], $seeds_dir = '') |
|
| 460 | 460 | { |
| 461 | 461 | // will update if system setting does exist or create new |
| 462 | 462 | foreach ($media_sources as $seed_key) { |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | $blendMediaSource->setSeedsDir($seeds_dir); |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | - if ( $blendMediaSource->revertBlend() ) { |
|
| 469 | + if ($blendMediaSource->revertBlend()) { |
|
| 470 | 470 | $this->out($blendMediaSource->getFieldName().' media source has been reverted to '.$seeds_dir); |
| 471 | 471 | |
| 472 | 472 | } else { |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | public function getBlendablePlugin($name) |
| 484 | 484 | { |
| 485 | 485 | /** @var \LCI\Blend\Blendable\Plugin $plugin */ |
| 486 | - $plugin = new Plugin($this->modx, $this, $name); |
|
| 486 | + $plugin = new Plugin($this->modx, $this, $name); |
|
| 487 | 487 | return $plugin->setSeedsDir($this->getSeedsDir()); |
| 488 | 488 | } |
| 489 | 489 | |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | * @param array $plugins |
| 492 | 492 | * @param string $seeds_dir |
| 493 | 493 | */ |
| 494 | - public function blendManyPlugins($plugins=[], $seeds_dir='') |
|
| 494 | + public function blendManyPlugins($plugins = [], $seeds_dir = '') |
|
| 495 | 495 | { |
| 496 | 496 | // will update if element does exist or create new |
| 497 | 497 | foreach ($plugins as $seed_key) { |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | if ($blendPlugin->blendFromSeed($seed_key)) { |
| 504 | 504 | $this->out($seed_key.' has been blended into ID: '); |
| 505 | 505 | |
| 506 | - } elseif($blendPlugin->isExists()) { |
|
| 506 | + } elseif ($blendPlugin->isExists()) { |
|
| 507 | 507 | // @TODO prompt Do you want to blend Y/N/Compare |
| 508 | 508 | $this->out($seed_key.' plugin already exists', true); |
| 509 | 509 | if ($this->prompt('Would you like to update?', 'Y') === 'Y') { |
@@ -521,7 +521,7 @@ discard block |
||
| 521 | 521 | * @param array $plugins |
| 522 | 522 | * @param string $seeds_dir |
| 523 | 523 | */ |
| 524 | - public function revertBlendManyPlugins($plugins=[], $seeds_dir='') |
|
| 524 | + public function revertBlendManyPlugins($plugins = [], $seeds_dir = '') |
|
| 525 | 525 | { |
| 526 | 526 | // will update if system setting does exist or create new |
| 527 | 527 | foreach ($plugins as $seed_key) { |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | $blendPlugin->setSeedsDir($seeds_dir); |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | - if ( $blendPlugin->revertBlend() ) { |
|
| 534 | + if ($blendPlugin->revertBlend()) { |
|
| 535 | 535 | $this->out($blendPlugin->getFieldName().' plugin has been reverted to '.$seeds_dir); |
| 536 | 536 | |
| 537 | 537 | } else { |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | public function getBlendableSnippet($name) |
| 549 | 549 | { |
| 550 | 550 | /** @var Snippet $snippet */ |
| 551 | - $snippet = new Snippet($this->modx, $this, $name); |
|
| 551 | + $snippet = new Snippet($this->modx, $this, $name); |
|
| 552 | 552 | return $snippet->setSeedsDir($this->getSeedsDir()); |
| 553 | 553 | } |
| 554 | 554 | |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | * @param array $snippets |
| 557 | 557 | * @param string $seeds_dir |
| 558 | 558 | */ |
| 559 | - public function blendManySnippets($snippets=[], $seeds_dir='') |
|
| 559 | + public function blendManySnippets($snippets = [], $seeds_dir = '') |
|
| 560 | 560 | { |
| 561 | 561 | // will update if element does exist or create new |
| 562 | 562 | foreach ($snippets as $seed_key) { |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | if ($blendSnippet->blendFromSeed($seed_key)) { |
| 569 | 569 | $this->out($seed_key.' has been blended'); |
| 570 | 570 | |
| 571 | - } elseif($blendSnippet->isExists()) { |
|
| 571 | + } elseif ($blendSnippet->isExists()) { |
|
| 572 | 572 | // @TODO prompt Do you want to blend Y/N/Compare |
| 573 | 573 | $this->out($seed_key.' snippet already exists', true); |
| 574 | 574 | if ($this->prompt('Would you like to update?', 'Y') === 'Y') { |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | * @param array $snippets |
| 586 | 586 | * @param string $seeds_dir |
| 587 | 587 | */ |
| 588 | - public function revertBlendManySnippets($snippets=[], $seeds_dir='') |
|
| 588 | + public function revertBlendManySnippets($snippets = [], $seeds_dir = '') |
|
| 589 | 589 | { |
| 590 | 590 | // will update if system setting does exist or create new |
| 591 | 591 | foreach ($snippets as $seed_key) { |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | $blendSnippet->setSeedsDir($seeds_dir); |
| 596 | 596 | } |
| 597 | 597 | |
| 598 | - if ( $blendSnippet->revertBlend() ) { |
|
| 598 | + if ($blendSnippet->revertBlend()) { |
|
| 599 | 599 | $this->out($blendSnippet->getFieldName().' snippet has been reverted to '.$seeds_dir); |
| 600 | 600 | |
| 601 | 601 | } else { |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | public function getBlendableTemplate($name) |
| 613 | 613 | { |
| 614 | 614 | /** @var \LCI\Blend\Blendable\Template $template */ |
| 615 | - $template = new Template($this->modx, $this, $name); |
|
| 615 | + $template = new Template($this->modx, $this, $name); |
|
| 616 | 616 | return $template->setSeedsDir($this->seeds_dir); |
| 617 | 617 | } |
| 618 | 618 | |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | * @param string $seeds_dir |
| 622 | 622 | * @param bool $overwrite |
| 623 | 623 | */ |
| 624 | - public function blendManyTemplates($templates=[], $seeds_dir='', $overwrite=false) |
|
| 624 | + public function blendManyTemplates($templates = [], $seeds_dir = '', $overwrite = false) |
|
| 625 | 625 | { |
| 626 | 626 | // will update if template does exist or create new |
| 627 | 627 | foreach ($templates as $seed_key) { |
@@ -634,7 +634,7 @@ discard block |
||
| 634 | 634 | if ($blendTemplate->blendFromSeed($seed_key, $overwrite)) { |
| 635 | 635 | $this->out($seed_key.' has been blended'); |
| 636 | 636 | |
| 637 | - } elseif($blendTemplate->isExists()) { |
|
| 637 | + } elseif ($blendTemplate->isExists()) { |
|
| 638 | 638 | $this->out($seed_key.' template already exists', true); |
| 639 | 639 | if ($this->prompt('Would you like to update?', 'Y') === 'Y') { |
| 640 | 640 | if ($blendTemplate->blendFromSeed($seed_key, true)) { |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | * @param array $templates |
| 652 | 652 | * @param string $seeds_dir |
| 653 | 653 | */ |
| 654 | - public function revertBlendManyTemplates($templates=[], $seeds_dir='') |
|
| 654 | + public function revertBlendManyTemplates($templates = [], $seeds_dir = '') |
|
| 655 | 655 | { |
| 656 | 656 | // will update if system setting does exist or create new |
| 657 | 657 | foreach ($templates as $seed_key) { |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | $blendTemplate->setSeedsDir($seeds_dir); |
| 662 | 662 | } |
| 663 | 663 | |
| 664 | - if ( $blendTemplate->revertBlend() ) { |
|
| 664 | + if ($blendTemplate->revertBlend()) { |
|
| 665 | 665 | $this->out($blendTemplate->getFieldName().' template has been reverted to '.$seeds_dir); |
| 666 | 666 | |
| 667 | 667 | } else { |
@@ -678,7 +678,7 @@ discard block |
||
| 678 | 678 | public function getBlendableTemplateVariable($name) |
| 679 | 679 | { |
| 680 | 680 | /** @var \LCI\Blend\Blendable\TemplateVariable $tv */ |
| 681 | - $tv = new TemplateVariable($this->modx, $this, $name); |
|
| 681 | + $tv = new TemplateVariable($this->modx, $this, $name); |
|
| 682 | 682 | return $tv->setSeedsDir($this->seeds_dir); |
| 683 | 683 | } |
| 684 | 684 | |
@@ -687,10 +687,10 @@ discard block |
||
| 687 | 687 | * @param string $context |
| 688 | 688 | * @return \LCI\Blend\Blendable\Resource |
| 689 | 689 | */ |
| 690 | - public function getBlendableResource($alias, $context='web') |
|
| 690 | + public function getBlendableResource($alias, $context = 'web') |
|
| 691 | 691 | { |
| 692 | 692 | /** @var \LCI\Blend\Blendable\Resource $resource */ |
| 693 | - $resource = new Resource($this->modx, $this, $alias, $context); |
|
| 693 | + $resource = new Resource($this->modx, $this, $alias, $context); |
|
| 694 | 694 | return $resource |
| 695 | 695 | ->setSeedsDir($this->getSeedsDir()); |
| 696 | 696 | } |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | * |
| 702 | 702 | * @return bool |
| 703 | 703 | */ |
| 704 | - public function blendManyResources($resources=[], $seeds_dir='', $overwrite=false) |
|
| 704 | + public function blendManyResources($resources = [], $seeds_dir = '', $overwrite = false) |
|
| 705 | 705 | { |
| 706 | 706 | $saved = true; |
| 707 | 707 | // will update if resource does exist or create new |
@@ -715,19 +715,19 @@ discard block |
||
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | if ($blendResource->blendFromSeed($seed_key, $overwrite)) { |
| 718 | - $this->out($seed_key . ' has been blended into ID: '); |
|
| 718 | + $this->out($seed_key.' has been blended into ID: '); |
|
| 719 | 719 | |
| 720 | 720 | } elseif ($blendResource->isExists()) { |
| 721 | 721 | // @TODO prompt Do you want to blend Y/N/Compare |
| 722 | - $this->out($seed_key . ' already exists', true); |
|
| 722 | + $this->out($seed_key.' already exists', true); |
|
| 723 | 723 | if ($this->prompt('Would you like to update?', 'Y') === 'Y') { |
| 724 | 724 | if ($blendResource->blendFromSeed($seed_key, true)) { |
| 725 | - $this->out($seed_key . ' has been blended into ID: '); |
|
| 725 | + $this->out($seed_key.' has been blended into ID: '); |
|
| 726 | 726 | } |
| 727 | 727 | } |
| 728 | 728 | } else { |
| 729 | - $this->out('There was an error saving ' . $seed_key, true); |
|
| 730 | - echo 'There was an error saving ' . $seed_key; exit(); |
|
| 729 | + $this->out('There was an error saving '.$seed_key, true); |
|
| 730 | + echo 'There was an error saving '.$seed_key; exit(); |
|
| 731 | 731 | $saved = false; |
| 732 | 732 | } |
| 733 | 733 | } |
@@ -743,7 +743,7 @@ discard block |
||
| 743 | 743 | * |
| 744 | 744 | * @return bool |
| 745 | 745 | */ |
| 746 | - public function revertBlendManyResources($resources=[], $seeds_dir='', $overwrite=false) |
|
| 746 | + public function revertBlendManyResources($resources = [], $seeds_dir = '', $overwrite = false) |
|
| 747 | 747 | { |
| 748 | 748 | $saved = true; |
| 749 | 749 | // will update if resource does exist or create new |
@@ -756,10 +756,10 @@ discard block |
||
| 756 | 756 | $blendResource->setSeedsDir($seeds_dir); |
| 757 | 757 | } |
| 758 | 758 | if ($blendResource->revertBlend()) { |
| 759 | - $this->out($seed_key . ' has been reverted '); |
|
| 759 | + $this->out($seed_key.' has been reverted '); |
|
| 760 | 760 | |
| 761 | 761 | } else { |
| 762 | - $this->out('There was an error reverting resource ' . $seed_key, true); |
|
| 762 | + $this->out('There was an error reverting resource '.$seed_key, true); |
|
| 763 | 763 | $saved = false; |
| 764 | 764 | } |
| 765 | 765 | } |
@@ -772,10 +772,10 @@ discard block |
||
| 772 | 772 | * @param string $key |
| 773 | 773 | * @return \LCI\Blend\Blendable\SystemSetting |
| 774 | 774 | */ |
| 775 | - public function getBlendableSystemSetting($key='') |
|
| 775 | + public function getBlendableSystemSetting($key = '') |
|
| 776 | 776 | { |
| 777 | 777 | /** @var \LCI\Blend\Blendable\SystemSetting $systemSetting */ |
| 778 | - $systemSetting = new SystemSetting($this->modx, $this, $key); |
|
| 778 | + $systemSetting = new SystemSetting($this->modx, $this, $key); |
|
| 779 | 779 | return $systemSetting->setSeedsDir($this->getSeedsDir()); |
| 780 | 780 | } |
| 781 | 781 | |
@@ -785,7 +785,7 @@ discard block |
||
| 785 | 785 | * |
| 786 | 786 | * @return bool |
| 787 | 787 | */ |
| 788 | - public function blendManySystemSettings($settings=[], $seeds_dir='') |
|
| 788 | + public function blendManySystemSettings($settings = [], $seeds_dir = '') |
|
| 789 | 789 | { |
| 790 | 790 | $success = true; |
| 791 | 791 | // will update if system setting does exist or create new |
@@ -830,7 +830,7 @@ discard block |
||
| 830 | 830 | * |
| 831 | 831 | * @return bool |
| 832 | 832 | */ |
| 833 | - public function revertBlendManySystemSettings($settings=[], $seeds_dir='') |
|
| 833 | + public function revertBlendManySystemSettings($settings = [], $seeds_dir = '') |
|
| 834 | 834 | { |
| 835 | 835 | $success = true; |
| 836 | 836 | // will update if system setting does exist or create new |
@@ -860,7 +860,7 @@ discard block |
||
| 860 | 860 | $systemSetting->setSeedsDir($seeds_dir); |
| 861 | 861 | } |
| 862 | 862 | |
| 863 | - if ( $systemSetting->revertBlend() ) { |
|
| 863 | + if ($systemSetting->revertBlend()) { |
|
| 864 | 864 | $this->out($systemSetting->getFieldName().' setting has been reverted to '.$seeds_dir); |
| 865 | 865 | |
| 866 | 866 | } else { |
@@ -878,7 +878,7 @@ discard block |
||
| 878 | 878 | * |
| 879 | 879 | * @return mixed |
| 880 | 880 | */ |
| 881 | - protected function prompt($question, $default='') |
|
| 881 | + protected function prompt($question, $default = '') |
|
| 882 | 882 | { |
| 883 | 883 | return $this->userInteractionHandler->promptInput($question, $default); |
| 884 | 884 | } |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | * @param bool $default |
| 889 | 889 | * @return bool |
| 890 | 890 | */ |
| 891 | - protected function promptConfirm($question, $default=true) |
|
| 891 | + protected function promptConfirm($question, $default = true) |
|
| 892 | 892 | { |
| 893 | 893 | return $this->userInteractionHandler->promptConfirm($question, $default); |
| 894 | 894 | } |
@@ -899,7 +899,7 @@ discard block |
||
| 899 | 899 | * @param array $options ~ ex: ['Option1' => 'value', 'Option2' => 'value2', ...] |
| 900 | 900 | * @return mixed ~ selected value |
| 901 | 901 | */ |
| 902 | - protected function promptSelectOneOption($question, $default, $options=[]) |
|
| 902 | + protected function promptSelectOneOption($question, $default, $options = []) |
|
| 903 | 903 | { |
| 904 | 904 | return $this->userInteractionHandler->promptSelectOneOption($question, $default, $options); |
| 905 | 905 | } |
@@ -910,7 +910,7 @@ discard block |
||
| 910 | 910 | * @param array $options ~ ex: ['Option1' => 'value', 'Option2' => 'value2', ...] |
| 911 | 911 | * @return array ~ array of selected values |
| 912 | 912 | */ |
| 913 | - protected function promptSelectMultipleOptions($question, $default, $options=[]) |
|
| 913 | + protected function promptSelectMultipleOptions($question, $default, $options = []) |
|
| 914 | 914 | { |
| 915 | 915 | return $this->userInteractionHandler->promptSelectMultipleOptions($question, $default, $options); |
| 916 | 916 | } |
@@ -919,7 +919,7 @@ discard block |
||
| 919 | 919 | * @param string $message |
| 920 | 920 | * @param bool $error |
| 921 | 921 | */ |
| 922 | - public function out($message, $error=false) |
|
| 922 | + public function out($message, $error = false) |
|
| 923 | 923 | { |
| 924 | 924 | if ($error) { |
| 925 | 925 | $this->userInteractionHandler->tellUser($message, userInteractionHandler::MASSAGE_ERROR); |
@@ -944,7 +944,7 @@ discard block |
||
| 944 | 944 | * |
| 945 | 945 | * @return bool |
| 946 | 946 | */ |
| 947 | - public function createBlankMigrationClassFile($name, $server_type='master', $migration_path=null) |
|
| 947 | + public function createBlankMigrationClassFile($name, $server_type = 'master', $migration_path = null) |
|
| 948 | 948 | { |
| 949 | 949 | $migrationCreator = new MigrationsCreator($this->userInteractionHandler); |
| 950 | 950 | |
@@ -972,7 +972,7 @@ discard block |
||
| 972 | 972 | * |
| 973 | 973 | * @return array |
| 974 | 974 | */ |
| 975 | - public function makeChunkSeeds($criteria, $server_type='master', $name=null, $create_migration_file=true) |
|
| 975 | + public function makeChunkSeeds($criteria, $server_type = 'master', $name = null, $create_migration_file = true) |
|
| 976 | 976 | { |
| 977 | 977 | $keys = []; |
| 978 | 978 | $collection = $this->modx->getCollection('modChunk', $criteria); |
@@ -1012,7 +1012,7 @@ discard block |
||
| 1012 | 1012 | * |
| 1013 | 1013 | * @return array |
| 1014 | 1014 | */ |
| 1015 | - public function makeContextSeeds($criteria, $server_type='master', $name=null, $create_migration_file=true) |
|
| 1015 | + public function makeContextSeeds($criteria, $server_type = 'master', $name = null, $create_migration_file = true) |
|
| 1016 | 1016 | { |
| 1017 | 1017 | $keys = []; |
| 1018 | 1018 | $collection = $this->modx->getCollection('modContext', $criteria); |
@@ -1052,7 +1052,7 @@ discard block |
||
| 1052 | 1052 | * |
| 1053 | 1053 | * @return array |
| 1054 | 1054 | */ |
| 1055 | - public function makeMediaSourceSeeds($criteria, $server_type='master', $name=null, $create_migration_file=true) |
|
| 1055 | + public function makeMediaSourceSeeds($criteria, $server_type = 'master', $name = null, $create_migration_file = true) |
|
| 1056 | 1056 | { |
| 1057 | 1057 | $keys = []; |
| 1058 | 1058 | $collection = $this->modx->getCollection('modMediaSource', $criteria); |
@@ -1092,7 +1092,7 @@ discard block |
||
| 1092 | 1092 | * |
| 1093 | 1093 | * @return array |
| 1094 | 1094 | */ |
| 1095 | - public function makePluginSeeds($criteria, $server_type='master', $name=null, $create_migration_file=true) |
|
| 1095 | + public function makePluginSeeds($criteria, $server_type = 'master', $name = null, $create_migration_file = true) |
|
| 1096 | 1096 | { |
| 1097 | 1097 | $keys = []; |
| 1098 | 1098 | $collection = $this->modx->getCollection('modPlugin', $criteria); |
@@ -1132,7 +1132,7 @@ discard block |
||
| 1132 | 1132 | * |
| 1133 | 1133 | * @return array |
| 1134 | 1134 | */ |
| 1135 | - public function makeResourceSeeds($criteria, $server_type='master', $name=null, $create_migration_file=true) |
|
| 1135 | + public function makeResourceSeeds($criteria, $server_type = 'master', $name = null, $create_migration_file = true) |
|
| 1136 | 1136 | { |
| 1137 | 1137 | $keys = [ |
| 1138 | 1138 | 'web' => [] |
@@ -1178,7 +1178,7 @@ discard block |
||
| 1178 | 1178 | * |
| 1179 | 1179 | * @return array |
| 1180 | 1180 | */ |
| 1181 | - public function makeSnippetSeeds($criteria, $server_type='master', $name=null, $create_migration_file=true) |
|
| 1181 | + public function makeSnippetSeeds($criteria, $server_type = 'master', $name = null, $create_migration_file = true) |
|
| 1182 | 1182 | { |
| 1183 | 1183 | $keys = []; |
| 1184 | 1184 | $collection = $this->modx->getCollection('modSnippet', $criteria); |
@@ -1218,7 +1218,7 @@ discard block |
||
| 1218 | 1218 | * |
| 1219 | 1219 | * @return array |
| 1220 | 1220 | */ |
| 1221 | - public function makeSystemSettingSeeds($criteria, $server_type='master', $name=null, $create_migration_file=true) |
|
| 1221 | + public function makeSystemSettingSeeds($criteria, $server_type = 'master', $name = null, $create_migration_file = true) |
|
| 1222 | 1222 | { |
| 1223 | 1223 | $collection = $this->modx->getCollection('modSystemSetting', $criteria); |
| 1224 | 1224 | |
@@ -1263,7 +1263,7 @@ discard block |
||
| 1263 | 1263 | * |
| 1264 | 1264 | * @return array |
| 1265 | 1265 | */ |
| 1266 | - public function makeTemplateSeeds($criteria, $server_type='master', $name=null, $create_migration_file=true) |
|
| 1266 | + public function makeTemplateSeeds($criteria, $server_type = 'master', $name = null, $create_migration_file = true) |
|
| 1267 | 1267 | { |
| 1268 | 1268 | $keys = []; |
| 1269 | 1269 | $collection = $this->modx->getCollection('modTemplate', $criteria); |
@@ -1300,7 +1300,7 @@ discard block |
||
| 1300 | 1300 | * @param string $server_type |
| 1301 | 1301 | * @param null|string $name |
| 1302 | 1302 | */ |
| 1303 | - public function makeSiteSeed($server_type='master', $name=null) |
|
| 1303 | + public function makeSiteSeed($server_type = 'master', $name = null) |
|
| 1304 | 1304 | { |
| 1305 | 1305 | $site_data = [ |
| 1306 | 1306 | 'mediaSources' => $this->makeMediaSourceSeeds(null, $server_type, $name, false), |
@@ -1331,7 +1331,7 @@ discard block |
||
| 1331 | 1331 | * @param string $method |
| 1332 | 1332 | * @param bool $prompt |
| 1333 | 1333 | */ |
| 1334 | - public function install($method='up', $prompt=false) |
|
| 1334 | + public function install($method = 'up', $prompt = false) |
|
| 1335 | 1335 | { |
| 1336 | 1336 | $migration_name = 'install_blender'; |
| 1337 | 1337 | $custom_migration_dir = __DIR__.'/Migrations/Blend/'; |
@@ -1346,7 +1346,7 @@ discard block |
||
| 1346 | 1346 | * @param string $method |
| 1347 | 1347 | * @param bool $prompt |
| 1348 | 1348 | */ |
| 1349 | - protected function runInstallMigration($migration_name, $custom_migration_path=null, $seed_root_path=null, $method='up', $prompt=false) |
|
| 1349 | + protected function runInstallMigration($migration_name, $custom_migration_path = null, $seed_root_path = null, $method = 'up', $prompt = false) |
|
| 1350 | 1350 | { |
| 1351 | 1351 | // new blender for each instance |
| 1352 | 1352 | $config = $this->config; |
@@ -1381,10 +1381,10 @@ discard block |
||
| 1381 | 1381 | $migration->set('status', 'up_complete'); |
| 1382 | 1382 | $migration->set('created_at', date('Y-m-d H:i:s')); |
| 1383 | 1383 | $migration->set('processed_at', date('Y-m-d H:i:s')); |
| 1384 | - if ($migration->save() ) { |
|
| 1384 | + if ($migration->save()) { |
|
| 1385 | 1385 | $this->outSuccess($migration_name.' ran and logged'); |
| 1386 | 1386 | } else { |
| 1387 | - $this->out($migration_name . ' did not log correctly', true); |
|
| 1387 | + $this->out($migration_name.' did not log correctly', true); |
|
| 1388 | 1388 | } |
| 1389 | 1389 | |
| 1390 | 1390 | // does the migration directory exist? |
@@ -1399,12 +1399,12 @@ discard block |
||
| 1399 | 1399 | } |
| 1400 | 1400 | if ($create) { |
| 1401 | 1401 | mkdir($this->getMigrationPath(), 0700, true); |
| 1402 | - $this->outSuccess('Created migration directory: '. $this->getMigrationPath()); |
|
| 1402 | + $this->outSuccess('Created migration directory: '.$this->getMigrationPath()); |
|
| 1403 | 1403 | } |
| 1404 | 1404 | } |
| 1405 | 1405 | |
| 1406 | 1406 | } else { |
| 1407 | - $this->out($migration_name . ' did not log correctly', true); |
|
| 1407 | + $this->out($migration_name.' did not log correctly', true); |
|
| 1408 | 1408 | } |
| 1409 | 1409 | |
| 1410 | 1410 | } elseif ($method == 'down') { |
@@ -1427,7 +1427,7 @@ discard block |
||
| 1427 | 1427 | /** |
| 1428 | 1428 | * @param string $method |
| 1429 | 1429 | */ |
| 1430 | - public function update($method='up') |
|
| 1430 | + public function update($method = 'up') |
|
| 1431 | 1431 | { |
| 1432 | 1432 | $current_vesion = $this->modx->getOption('blend.version'); |
| 1433 | 1433 | |
@@ -1438,7 +1438,7 @@ discard block |
||
| 1438 | 1438 | $blender = new Blender($this->modx, $this->getUserInteractionHandler(), $config); |
| 1439 | 1439 | |
| 1440 | 1440 | foreach ($this->update_migrations as $v => $migration_name) { |
| 1441 | - if (version_compare($v, $current_vesion) === 1 ) { |
|
| 1441 | + if (version_compare($v, $current_vesion) === 1) { |
|
| 1442 | 1442 | // can not use as xPDO get queries fill the SELECT with the DB fields and since we are adding one this is a SQL error |
| 1443 | 1443 | //$blender->runMigration($method, 'master', 0, 0, $migration_name); |
| 1444 | 1444 | |
@@ -1463,7 +1463,7 @@ discard block |
||
| 1463 | 1463 | $migration->set('status', 'up_complete'); |
| 1464 | 1464 | $migration->set('created_at', date('Y-m-d H:i:s')); |
| 1465 | 1465 | $migration->set('processed_at', date('Y-m-d H:i:s')); |
| 1466 | - if ($migration->save() ) { |
|
| 1466 | + if ($migration->save()) { |
|
| 1467 | 1467 | $this->outSuccess('Blend updated to '.$v); |
| 1468 | 1468 | } else { |
| 1469 | 1469 | $this->out('Blend did not update to '.$v, true); |
@@ -1503,7 +1503,7 @@ discard block |
||
| 1503 | 1503 | |
| 1504 | 1504 | $current_vesion = $this->modx->getOption('blend.version'); |
| 1505 | 1505 | // FILE version, DB Version |
| 1506 | - if ( $this->isBlendInstalledInModx() && ( !$current_vesion || version_compare($this->getVersion(), $current_vesion)) ) { |
|
| 1506 | + if ($this->isBlendInstalledInModx() && (!$current_vesion || version_compare($this->getVersion(), $current_vesion))) { |
|
| 1507 | 1507 | $upgrade = true; |
| 1508 | 1508 | } |
| 1509 | 1509 | |
@@ -1548,7 +1548,7 @@ discard block |
||
| 1548 | 1548 | * @param int $id |
| 1549 | 1549 | * @param string $name |
| 1550 | 1550 | */ |
| 1551 | - public function runMigration($method='up', $type='master', $count=0, $id=0, $name=null) |
|
| 1551 | + public function runMigration($method = 'up', $type = 'master', $count = 0, $id = 0, $name = null) |
|
| 1552 | 1552 | { |
| 1553 | 1553 | $dir = 'ASC'; |
| 1554 | 1554 | if ($method == 'down') { |
@@ -1582,7 +1582,7 @@ discard block |
||
| 1582 | 1582 | /** @var string $server_type */ |
| 1583 | 1583 | $server_type = $migration->get('type'); |
| 1584 | 1584 | |
| 1585 | - if ( ($server_type != $type) || ($method == 'up' && $status == 'up_complete') || ($method == 'down' && $status != 'up_complete') ) { |
|
| 1585 | + if (($server_type != $type) || ($method == 'up' && $status == 'up_complete') || ($method == 'down' && $status != 'up_complete')) { |
|
| 1586 | 1586 | continue; |
| 1587 | 1587 | } |
| 1588 | 1588 | |
@@ -1680,7 +1680,7 @@ discard block |
||
| 1680 | 1680 | if (file_exists($file)) { |
| 1681 | 1681 | require_once $file; |
| 1682 | 1682 | |
| 1683 | - if(class_exists($name)) { |
|
| 1683 | + if (class_exists($name)) { |
|
| 1684 | 1684 | /** @var Migrations $migrationProcessClass */ |
| 1685 | 1685 | $migrationProcessClass = new $name($this->modx, $blender); |
| 1686 | 1686 | } |
@@ -1694,7 +1694,7 @@ discard block |
||
| 1694 | 1694 | * @param null $name |
| 1695 | 1695 | * @return string |
| 1696 | 1696 | */ |
| 1697 | - public function getMigrationName($type, $name=null) |
|
| 1697 | + public function getMigrationName($type, $name = null) |
|
| 1698 | 1698 | { |
| 1699 | 1699 | $format = new Format($this->seeds_dir); |
| 1700 | 1700 | return $format->getMigrationName($type, $name); |
@@ -1712,21 +1712,21 @@ discard block |
||
| 1712 | 1712 | $class_name = $this->getMigrationName($type, $name); |
| 1713 | 1713 | |
| 1714 | 1714 | $removed = false; |
| 1715 | - $migration_file = $this->getMigrationPath() . $class_name . '.php'; |
|
| 1715 | + $migration_file = $this->getMigrationPath().$class_name.'.php'; |
|
| 1716 | 1716 | if (file_exists($migration_file)) { |
| 1717 | 1717 | if (unlink($migration_file)) { |
| 1718 | 1718 | $removed = true; |
| 1719 | 1719 | $migration = $this->modx->getObject($this->blend_class_object, ['name' => $class_name]); |
| 1720 | 1720 | if (is_object($migration) && $migration->remove()) { |
| 1721 | - $this->out($class_name . ' migration has been removed from the blend_migrations table'); |
|
| 1721 | + $this->out($class_name.' migration has been removed from the blend_migrations table'); |
|
| 1722 | 1722 | |
| 1723 | 1723 | } |
| 1724 | 1724 | } else { |
| 1725 | - $this->out($class_name . ' migration has not been removed from the blend_migrations table', true); |
|
| 1725 | + $this->out($class_name.' migration has not been removed from the blend_migrations table', true); |
|
| 1726 | 1726 | } |
| 1727 | 1727 | |
| 1728 | 1728 | } else { |
| 1729 | - $this->out($this->getMigrationPath() . $class_name . '.php migration could not be found to remove', true); |
|
| 1729 | + $this->out($this->getMigrationPath().$class_name.'.php migration could not be found to remove', true); |
|
| 1730 | 1730 | } |
| 1731 | 1731 | |
| 1732 | 1732 | return $removed; |
@@ -1764,7 +1764,7 @@ discard block |
||
| 1764 | 1764 | * |
| 1765 | 1765 | * @return bool|int |
| 1766 | 1766 | */ |
| 1767 | - public function getResourceIDFromSeedKey($seed_key, $context='web') |
|
| 1767 | + public function getResourceIDFromSeedKey($seed_key, $context = 'web') |
|
| 1768 | 1768 | { |
| 1769 | 1769 | if (!isset($this->resource_seek_key_map[$context])) { |
| 1770 | 1770 | $this->resource_seek_key_map[$context] = []; |