@@ -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 string|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)) { |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @return string |
| 62 | 62 | */ |
| 63 | - public function prettyVarExport($data, $tabs=1) |
|
| 63 | + public function prettyVarExport($data, $tabs = 1) |
|
| 64 | 64 | { |
| 65 | - $spacing = str_repeat(' ', 4*$tabs); |
|
| 65 | + $spacing = str_repeat(' ', 4 * $tabs); |
|
| 66 | 66 | |
| 67 | 67 | $string = ''; |
| 68 | 68 | $parts = preg_split('/\R/', var_export($data, true)); |
@@ -81,7 +81,7 @@ |
||
| 81 | 81 | } elseif ($object == 'r' || $object == 'resource') { |
| 82 | 82 | $this->seedResources($type, $name, $id, $date); |
| 83 | 83 | |
| 84 | - } elseif ($object == 's' || $object == 'snippet') { |
|
| 84 | + } elseif ($object == 's' || $object == 'snippet') { |
|
| 85 | 85 | $this->seedSnippets($type, $name, $id); |
| 86 | 86 | |
| 87 | 87 | } elseif ($object == 'x' || $object == 'systemSettings') { |