Started rewriting the new version
json_sms.php already reflects that. The old class files are still around, though.
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace SmsGateway\Backend;
|
||||
|
||||
use SmsGateway\BackendInterface;
|
||||
|
||||
class DatabaseBackend implements BackendInterface
|
||||
{
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
namespace SmsGateway;
|
||||
|
||||
interface BackendInterface
|
||||
{
|
||||
}
|
45
src/SmsGateway/Logger/DatabaseLogger.php
Normal file
45
src/SmsGateway/Logger/DatabaseLogger.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
namespace SmsGateway\Logger;
|
||||
|
||||
use SmsGateway\LoggerInterface;
|
||||
use PDO;
|
||||
|
||||
class DatabaseLogger implements LoggerInterface
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $dsn The PDO datasource string
|
||||
* @param string $username The username to use during the connection
|
||||
* @param string $password The password for the above username
|
||||
* @throws PDOException Upon database connection error
|
||||
*/
|
||||
public function __construct($dsn, $username, $password)
|
||||
{
|
||||
$this->dbh = new PDO($dsn, $username, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an audit event
|
||||
*
|
||||
* @param integer $type The message type
|
||||
* @param string $username The user this audit log connects to. Can be
|
||||
* NULL if the user is unauthenticated
|
||||
* @param string $message The audit message
|
||||
* @return boolean TRUE if the message was saved, FALSE otherwise
|
||||
*/
|
||||
public function auditLog($type, $username, $message)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a sent message
|
||||
*
|
||||
* @param string $username The username who sent this message
|
||||
* @param string $recipient The recipient of the message
|
||||
* @param string $message The message itself
|
||||
*/
|
||||
public function messageLog($username, $recipient, $message)
|
||||
{
|
||||
}
|
||||
}
|
27
src/SmsGateway/LoggerInterface.php
Normal file
27
src/SmsGateway/LoggerInterface.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace SmsGateway;
|
||||
|
||||
interface LoggerInterface
|
||||
{
|
||||
const SMSSENDER_AUDIT_LOGIN = 1;
|
||||
|
||||
/**
|
||||
* Log an audit event
|
||||
*
|
||||
* @param integer $type The message type
|
||||
* @param string $username The user this audit log connects to. Can be
|
||||
* NULL if the user is unauthenticated
|
||||
* @param string $message The audit message
|
||||
* @return boolean TRUE if the message was saved, FALSE otherwise
|
||||
*/
|
||||
public function auditLog($type, $username, $message);
|
||||
|
||||
/**
|
||||
* Log a sent message
|
||||
*
|
||||
* @param string $username The username who sent this message
|
||||
* @param string $recipient The recipient of the message
|
||||
* @param string $message The message itself
|
||||
*/
|
||||
public function messageLog($username, $recipient, $message);
|
||||
}
|
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
namespace SmsGateway;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
use SmsGateway\BackendInterface;
|
||||
use SmsGateway\LoggerInterface;
|
||||
use SmsGateway\SenderInterface;
|
||||
|
||||
class RpcServer
|
||||
{
|
||||
/**
|
||||
* The user backend
|
||||
*
|
||||
* @var SmsGateway\BackendInterface $backend
|
||||
*/
|
||||
private $backend;
|
||||
|
||||
/**
|
||||
* The logger
|
||||
*
|
||||
* @var SmsGateway\LoggerInterface $logger
|
||||
*/
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* The sender
|
||||
*
|
||||
* @var SmsGateway\SenderInterface $sender
|
||||
*/
|
||||
private $sender;
|
||||
|
||||
public function __construct(BackendInterface $backend, LoggerInterface $logger, SenderInterface $sender)
|
||||
{
|
||||
}
|
||||
|
||||
protected function login(array $params)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function send(array $params)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function logout(array $params)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handle(Request $request, array $jsonData)
|
||||
{
|
||||
$params = $jsonData['params'];
|
||||
switch ($jsonData['method']) {
|
||||
case 'login':
|
||||
break;
|
||||
case 'send':
|
||||
break;
|
||||
case 'logout':
|
||||
break;
|
||||
default:
|
||||
throw new \Exception('Invalid request');
|
||||
}
|
||||
return 'ajaj';
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace SmsGateway\Sender;
|
||||
|
||||
use SmsGateway\SenderInterface;
|
||||
|
||||
class GnokiiSender implements SenderInterface
|
||||
{
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
namespace SmsGateway;
|
||||
|
||||
interface SenderInterface
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user