예제 #1
0
 public function __construct($data = null)
 {
     $this->log = \Malmanger\Mpmq\Util\Log::getInstance();
     if (!empty($data)) {
         $this->data = $data;
     }
 }
예제 #2
0
파일: Db.php 프로젝트: bjomal/mpmq
 public function __construct($data)
 {
     $this->log = \Malmanger\Mpmq\Util\Log::getInstance();
     $this->type = 'generic';
     $this->connected = false;
     $this->data = $data;
     if (array_key_exists('prefix', $this->data)) {
         $this->tablePrefix = $this->data['prefix'];
     }
     if (!$this->connect()) {
         throw new \Exception('Unable to connect to database');
     }
 }
예제 #3
0
파일: DbQueue.php 프로젝트: bjomal/mpmq
 public function __construct($id, $name, $description = '', $timeout = self::DEFAULT_TIMEOUT)
 {
     if (empty($timeout)) {
         $timeout = self::DEFAULT_TIMEOUT;
     }
     $this->log = \Malmanger\Mpmq\Util\Log::getInstance();
     $this->id = $id;
     if ($this->load()) {
         $this->log->debug("id={$id} alredy existed. Cannot create!!!");
         $this->existed = true;
     } else {
         $this->name = $name;
         $this->description = $description;
         $this->timeout = $timeout;
         $this->changed();
     }
 }
예제 #4
0
파일: DbMessage.php 프로젝트: bjomal/mpmq
 public function __construct($queueId, $messageId = null, $title = '', $payload = '', $timeout = self::DEFAULT_TIMEOUT)
 {
     if (empty($timeout)) {
         $timeout = self::DEFAULT_TIMEOUT;
     }
     $this->log = \Malmanger\Mpmq\Util\Log::getInstance();
     $this->queueId = $queueId;
     $this->messageId = $messageId;
     if ($this->messageId !== null && $this->load()) {
         $this->log->debug("id={$id} alredy existed. Cannot create!!!");
         $this->existed = true;
     } else {
         $this->title = $title;
         $this->payload = $payload;
         $this->timeout = $timeout;
         $this->inFlight = false;
         $this->changed();
     }
 }
예제 #5
0
 public function __construct()
 {
     $this->log = \Malmanger\Mpmq\Util\Log::getInstance();
     $this->errorMessages = array();
 }
예제 #6
0
파일: Misc.php 프로젝트: bjomal/mpmq
 public function __construct()
 {
     $this->log = \Malmanger\Mpmq\Util\Log::getInstance();
 }
예제 #7
0
파일: index.php 프로젝트: bjomal/mpmq
<?php

// All file paths relative to root
chdir(dirname(__FILE__));
define('MPMQ_ROOT', dirname(__FILE__) . '/');
require 'vendor/autoload.php';
require 'app/src/autoload.php';
session_start();
if (file_exists('app/settings.php')) {
    $settings = (require 'app/settings.php');
} else {
    $settings = (require 'app/settings.php.dist');
}
// Create a log object
$log = \Malmanger\Mpmq\Util\Log::getInstance(\Malmanger\Mpmq\Util\Log::DEBUG);
$log->debug("Logging started");
// initialize database
$data = $settings["settings"]["db"];
$misc = $settings["settings"]["misc"];
$app = new \Slim\App($settings);
// disable error handler
unset($app->getContainer()['errorHandler']);
// Create or connect to DB
try {
    // TODO: do test on settings to confirm correct database type
    $database = new \Malmanger\Mpmq\Db\SQLite($data);
} catch (\Exception $e) {
    $err = new \Malmanger\Mpmq\Util\ErrorHandler();
    $resp = new Slim\Http\Response();
    $log->debug("Error connecting to database:" . $e->getMessage());
    $log->error("Unable to create or connect to database!, exiting");