/** * @param string|string[] $measurementName * @return Time */ public static function start($measurementName) { if (is_array($measurementName)) { $measurementName = implode('/', $measurementName); } return new Time($measurementName, Drivers::get()); }
public function testStartWithArray() { $driver = $this->buildMock(); $driver->expects($this->once())->method('measureTime')->with('foo/bar'); Drivers::set($driver); Time::start(["foo", "bar"]); }
/** * This method is a wrapper for an insert-into sql-command * * @param $s_table_name * * @return $this */ public function insert_into($s_table_name) { parent::insert_into($s_table_name); var_dump(__FUNCTION__); var_dump($this->o_database_connection); return $this; }
/** * The factory method will load the correct driver for the database-connection, * based on the DB_TYPE constant in the '.dbconfig.php' file. * It also will check, if driver-only-methods have the DB_TYPE prefix, because of * readability and usage. (driver-only-methods are methods of a driver, that not specified in the * abstract Database_Driver class) * * @return Drivers| \Database\Driver_MySQL return the specific driver-object * @throws \LOGD_Exception */ public static function factory() { //check if we have already an instance of a driver class if (null === self::$o_instance) { //try to load the specific driver class (check if the class exists), //based on the PREFIX with namespace and the database-type. //throw an Exception with the corresponding error, which driver class failed try { $s_class = self::DRIVER_PREFIX . DB_TYPE; if (!class_exists($s_class)) { $message = __('error_class_not_found', 'errors') . '<strong>' . $s_class . '</strong><br>'; $message .= __('error_wrong_driver', 'errors') . '<strong>' . DB_TYPE . '</strong>'; throw new \LOGD_Exception($message, 900); } //set the current instance-object to the specific driver class and check the methods self::$o_instance = new $s_class(); self::$o_instance->check_methods(); } catch (\LOGD_Exception $e) { $e->print_error(); } } return self::$o_instance; }
public function testSetAndGet() { $driver = $this->getMock("Wikia\\Measurements\\Driver"); Drivers::set($driver); $this->assertEquals($driver, Drivers::get()); }
<?php require_once '../classes/db/Drivers.php'; require_once '../classes/Helper.php'; $drivers = new Drivers(); if ($_GET) { if (isset($_GET["company_hash"]) && $_GET["company_hash"] == "qwerty") { Helper::checkGetParameter('id'); $driver = $drivers->getDriver($_GET['id']); if ($driver != null) { echo "OK"; } else { echo "WRONG USER"; } exit; } Helper::checkAuthorisation(); switch ($_GET['type']) { case 'id': Helper::checkGetParameter('id'); $driver = $drivers->getDriver($_GET['id']); echo json_encode($driver); break; case 'location': $response = ['time' => time(), 'list' => $drivers->getDriversLocation()]; echo json_encode($response); break; case 'list': $response = ['list' => $drivers->getUserGroupDrivers()]; echo json_encode($response); break;
* @param Driver $currentDriver */ public static function set(Driver $currentDriver) { self::$currentDriver = $currentDriver; } /** * @return Driver */ public static function get() { return self::$currentDriver; } /** * Resets default driver to default value. */ public static function resetDefault() { $candidates = [new NewrelicDriver(), new DummyDriver()]; foreach ($candidates as $candidate) { /** @var Driver $candidate */ if ($candidate->canUse()) { self::set($candidate); break; } } } } // static constructor replacement Drivers::resetDefault();
require_once '../classes/db/Drivers.php'; require_once '../classes/Helper.php'; Helper::checkAuthorisation(); if ($_GET) { require_once '../classes/SSP.php'; require_once '../classes/db/utils/SQLConfig.php'; $table = 'drivers'; $primaryKey = 'driver_id'; $columns = array(array('db' => 'driver_id', 'dt' => 0), array('db' => 'name', 'dt' => 1), array('db' => 'alias', 'dt' => 2), array('db' => 'phone_number', 'dt' => 3), array('db' => 'vehicle_num', 'dt' => 4), array('db' => 'vehicle_description', 'dt' => 5)); $sql_details = SQLConfig::getSqlDetails(); echo json_encode(SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns)); } else { if ($_POST) { Helper::checkPostParameter('action'); $driverManager = new Drivers(); switch ($_POST['action']) { case 'create': $result = $driverManager->createDriver(); if (isset($result) && $result) { echo $result; } else { echo 'UNKNOWN_ERROR'; } break; case 'modify': Helper::checkPostParameter('driver_id'); Helper::checkPostParameter('groups'); require_once '../classes/db/Groups.php'; $groupManager = new Groups(); $result = $driverManager->modifyDriver($_POST['driver_id'], $_POST);
/** convertToDriver() * @todo Email functionality to email hr group members | hr@manlinegroup.com */ function convertToDriver() { //: Preparation $id = isset($_POST['conf']['id']) ? $_POST['conf']['id'] : null; $type = isset($_POST['conf']['type']) ? $_POST['conf']['type'] : 'candidates'; if (!$id) { throw new man_exception('Insufficient parameters for drivers::convert'); } # set up the class variables $class = ucwords(strtolower($type)); $drivers = new Drivers(); $convert = new $class(); $convertme = $convert->getRow(array('where' => strtolower(substr($class, 0, 1)) . '.id=' . $id)); $data = (array) array(); foreach ($drivers->getCols() as $key => $val) { if ($val == 'id') { continue; } if (in_array($val, array_keys($convertme))) { $data[$val] = $convertme[$val]; } } $driverid = $drivers->create($data); //: Logging $data = (array) array(); $data['driverid'] = $driverid; $data['convertedby'] = $_SESSION['userid']; $data['convertdate'] = time(); $convert->update('id=' . $id, $data); goHere("index.php?mode=maxine/index&action=driverslist"); }
public function getDrivers() { $result = Drivers::all(); return json_encode($result); }