Skip to content

Commit

Permalink
feat: add echo() method for cli usage
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed May 4, 2023
1 parent 5d56b2b commit f09dd3c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions RockMigrations.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ class RockMigrations extends WireData implements Module, ConfigurableModule
/** @var WireData */
public $fieldSuccessMessages;

/**
* Flag that is set true when migrations are running
* @var bool
*/
public $ismigrating = false;

/**
* Timestamp of last run migration
* @var int
Expand Down Expand Up @@ -1488,6 +1494,24 @@ public function downloadModule($url)
return false;
}

/**
* Echo data (for CLI usage)
*/
public function echo($data)
{
if (is_array($data)) echo $log = print_r($data, true);
elseif (is_string($data)) echo $log = "$data\n";
else {
ob_start();
var_dump($data);
echo $log = ob_get_clean();
}
$this->wire->log->save("LineUpr", $log, [
'showUser' => false,
'showUrl' => false,
]);
}

/**
* Enable all languages for given page
*
Expand Down

0 comments on commit f09dd3c

Please sign in to comment.