MigrationLib has a better output for HTTP or CLI

This commit is contained in:
paolo
2016-07-05 17:54:26 +02:00
parent c85a406ec6
commit eac6aae4f1
2 changed files with 34 additions and 3 deletions
+29 -3
View File
@@ -9,19 +9,45 @@ class MigrationLib extends CI_Migration
private $ERROR_PREFIX = "[E]";
private $SEPARATOR = "------------------------------";
private $cli;
public function __construct()
{
if ($this->input->is_cli_request())
{
$this->cli = true;
}
else
{
$this->cli = false;
}
}
private function getEOL()
{
if ($this->cli === true)
{
return PHP_EOL;
}
else
{
return "<br>";
}
}
private function printMessage($message)
{
printf("%s %s" . PHP_EOL, $this->MSG_PREFIX, $message);
printf("%s %s" . $this->getEOL(), $this->MSG_PREFIX, $message);
}
private function printInfo($info)
{
printf("%s %s" . PHP_EOL, $this->INFO_PREFIX, $info);
printf("%s %s" . $this->getEOL(), $this->INFO_PREFIX, $info);
}
private function printError($error)
{
printf("%s %s" . PHP_EOL, $this->ERROR_PREFIX, $error);
printf("%s %s" . $this->getEOL(), $this->ERROR_PREFIX, $error);
}
protected function startUP()
@@ -6,6 +6,11 @@ require_once APPPATH . '/libraries/MigrationLib.php';
class Migration_Reihungstest extends MigrationLib
{
public function __construct()
{
parent::__construct();
}
public function up()
{
$this->startUP();