public static function getInstance() { if (self::$theInstance == null) { self::$theInstance = new PollService(); } return self::$theInstance; }
require_once "ElectionService.php"; $allElections = ElectionService::getInstance()->getElections(); echo $allElections; break; case 'loadElectionPolls': require_once "PollService.php"; PollService::getInstance()->setIdElection($_POST['idElection']); PollService::getInstance()->getElectionPolls(); $allPolls = PollService::getInstance()->getAllPolls(); echo $allPolls; break; case 'openPoll': require_once "PollService.php"; PollService::getInstance()->setIdElection($_POST['idpoll']); PollService::getInstance()->openPoll(); $result = PollService::getInstance()->getLatestResult(); echo $result; break; } } else { echo <<<_OUT \t\t<!DOCTYPE html> <html> <head> \t<script type="text/javascript" src="openpoll.js"></script> \t\t\t\t\t<link rel="stylesheet" href="usecase.css" /> </head> <body onload="loadAllElections()"> <div class="mainForm"> <label for="elections">Select an election:</label> <select id="elections" onchange="loadElectionPolls(this)"></select>