--- /dev/null
+<?php
+
+namespace Controllers;
+
+use Controllers\IDivineController;
+
+abstract class AbstractController implements IDivineController
+{
+ protected $_isJsonResponse;
+ protected $_response;
+
+
+ public function __construct
+
+ public function setJsonResponse()
+ {
+ $this->_isJsonResponse = true;
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+class HomeController
+{
+
+ private $content;
+
+
+ public function defaultAction()
+ {
+
+ }
+}
--- /dev/null
+<?php
+
+namespace Controllers;
+
+interface IDivineController
+{
+ public function setJsonResponse();
+ public function getAction();
+}
\r
public function __construct($maps)\r
{\r
- //should probably do all this through a configuration object or something\r
+ //TODO: should probably do all this through a configuration object or something\r
$dsn = 'mysql:host=localhost;dbname=divinelegy;charset=utf8';\r
$username = 'root';\r
$password = 'toor';\r
echo '</pre>';\r
}\r
\r
+ //TODO: Implement\r
public function remove(IDivineEntity $entity) {\r
;\r
}\r
--- /dev/null
+<?php
+
+namespace DataAccess;
+
+use Domain\Entities\IDivineEntity;
+
+interface IRepository
+{
+ public function find($id);
+ public function save(IDivineEntity $entity);
+ public function remove(IDivineEntity $entity);
+}
+
--- /dev/null
+<?php\r
+\r
+namespace DataAccess\StepMania;\r
+\r
+use DataAccess\IRepository;\r
+use DataAccess\DataMapper\IDataMapper;\r
+use Domain\Entities\IDivineEntity;\r
+\r
+//TODO: Implement some sort of caching. Probably OK for now not to worry.\r
+class SimfileRepository implements IRepository\r
+{\r
+ private $dataMapper;\r
+ \r
+ public function __construct(IDataMapper $dataMapper) {\r
+ $this->dataMapper = $dataMapper;\r
+ }\r
+ \r
+ public function find($id) {\r
+ return $this->dataMapper->find($id, 'simfiles');\r
+ }\r
+ \r
+ public function save(IDivineEntity $entity) {\r
+ $this->dataMapper->save($entity);\r
+ }\r
+ \r
+ //TODO: Implement\r
+ public function remove(IDivineEntity $entity) {\r
+ ;\r
+ }\r
+}\r
--- /dev/null
+<?php
+
+namespace Services;
+
+use Services\IHttpResponse;
+use Exception;
+
+class HttpResponse implements IHttpResponse
+{
+ private $_statusCode = 200;
+ private $_headers = array();
+ private $_body;
+ private $_isRedirect = false;
+
+ public function setStatusCode($code)
+ {
+ if(!is_int($code) || (100 > $code) || (599 < $code)) {
+ throw new Exception(sprintf('Invalid HTTP response code, %u', $code));
+ }
+
+ $this->_isRedirect = (300 <= $code) && (307 >= $code);
+ $this->_statusCode = $code;
+
+ return $this;
+ }
+
+ public function isRedirect()
+ {
+ return $this->_isRedirect;
+ }
+
+ public function setHeader($name, $value)
+ {
+ $value = (string) $value;
+
+ $this->_headers[$name] = $value;
+
+ return $this;
+ }
+
+ public function getHeaders()
+ {
+ return $this->_headers;
+ }
+
+ private function sendHeaders()
+ {
+ $statusCodeSent = false;
+
+ if(!count($this->_headers)) {
+ return $this;
+ }
+
+ foreach($this->_headers as $headerName => $headerValue) {
+ if(!$statusCodeSent) {
+ header(
+ sprintf('%s:%s', $headerName, $headerValue),
+ false,
+ $this->_statusCode);
+
+ $statusCodeSent = true;
+ }
+ }
+
+ return $this;
+ }
+
+ public function setBody($content)
+ {
+ $this->_body = $content;
+ }
+
+ public function getBody()
+ {
+ return $this->_body;
+ }
+
+
+ private function sendBody()
+ {
+ echo $this->_body;
+ }
+
+ public function sendResponse()
+ {
+ $this->sendHeaders()
+ ->sendBody();
+ }
+}
--- /dev/null
+<?php
+
+namespace Services;
+
+interface IHttpResponse
+{
+ // TODO: Maybe we want a method to do an internal redirect to a different controller.
+ // Maybe that should be done by the abstract controller class, though?
+ public function setStatusCode($code);
+ public function setHeader($name, $value);
+ public function getHeaders();
+ public function setBody();
+ public function getBody();
+ public function isRedirect();
+ public function sendResponse();
+}
\ No newline at end of file