Switched getTicketForId to a static method; no more need for singleton
This commit is contained in:
parent
71911acc35
commit
8e48a431af
@ -7,16 +7,7 @@ class TicketRepository {
|
|||||||
private function __construct() {
|
private function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getInstance() {
|
public static function getTicketForId($id, $settings) {
|
||||||
static $instance = null;
|
|
||||||
if ($instance == null)
|
|
||||||
{
|
|
||||||
$instance = new TicketRepository();
|
|
||||||
}
|
|
||||||
return $instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTicketForId($id, $settings) {
|
|
||||||
|
|
||||||
$connection = new mysqli($settings['db_host'], $settings['db_user'], $settings['db_pass'], $settings['db_name']);
|
$connection = new mysqli($settings['db_host'], $settings['db_user'], $settings['db_pass'], $settings['db_name']);
|
||||||
if ($connection->connect_error)
|
if ($connection->connect_error)
|
||||||
|
@ -12,7 +12,7 @@ if(isset($_GET['id']))
|
|||||||
{
|
{
|
||||||
|
|
||||||
$ticketRepository = TicketRepository::getInstance();
|
$ticketRepository = TicketRepository::getInstance();
|
||||||
$ticket = $ticketRepository->getTicketForId($_GET['id'], $hesk_settings);
|
$ticket = TicketRepository::getTicketForId($_GET['id'], $hesk_settings);
|
||||||
//--A quick and dirty RESTful test using PHP.
|
//--A quick and dirty RESTful test using PHP.
|
||||||
echo json_encode($ticket);
|
echo json_encode($ticket);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user