$this->generate('AccountingEntries');
}
+ /**
+ * Write a log message.
+ *
+ * @param string $message
+ */
+ public function write($message) {
+ echo $message;
+ }
+
/**
* Public wrapper for calling private "add" functions
* Provides user feedback
* @param $itemName
*/
public function generate($itemName) {
- echo "Generating $itemName\n";
+ $this->write("Generating $itemName\n");
$fn = "add$itemName";
$this->$fn();
}
$items = $this->sampleData[$key];
}
if (!$items) {
- echo "Error: no items found for '$key'\n";
+ $this->write("Error: no items found for '$key'\n");
return FALSE;
}
return $items[$this->randomInt(0, count($items) - 1)];
*/
private function _insert(&$dao) {
if (self::ADD_TO_DB) {
- if (!$dao->insert()) {
- echo "ERROR INSERT: " . mysqli_error($dao->getConnection()->connection) . "\n";
- print_r($dao);
- exit(1);
- }
+ $dao->insert();
}
}
*/
private function _update(&$dao) {
if (self::ADD_TO_DB) {
- if (!$dao->update()) {
- echo "ERROR UPDATE: " . mysqli_error($dao->getConnection()->connection) . "\n";
- print_r($dao);
- exit(1);
- }
+ $dao->update();
}
}
require_once '../civicrm.config.php';
-
-// autoload
-require_once 'CRM/Core/ClassLoader.php';
-CRM_Core_ClassLoader::singleton()->register();
+CRM_Core_Config::singleton();
echo ("Starting data generation on " . date("F dS h:i:s A") . "\n");
-$gcd = new CRM_Core_CodeGen_GenerateData();
-$gcd->generateAll();
+try {
+ $scope = CRM_Core_TemporaryErrorScope::useException();
+ $gcd = new CRM_Core_CodeGen_GenerateData();
+ $gcd->generateAll();
+}
+catch (Exception $e) {
+ echo CRM_Core_Error::formatTextException($e);
+}
echo ("Ending data generation on " . date("F dS h:i:s A") . "\n");