+++ /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;
+
+use DataAccess\StepMania\ISimfileRepository;
+use Services\IHttpResponse;
+
+class IndexController implements IDivineController
+{
+
+ private $_content;
+ private $_simfileRepository;
+ private $_jsonResponse;
+ private $_response;
+
+ //override
+ public function __construct(
+ IHttpResponse $response,
+ ISimfileRepository $repository
+ ) {
+ $this->_response = $response;
+ $this->_simfileRepository = $repository;
+ }
+
+ public function setJsonResponse() {
+ $this->_jsonResponse = true;
+ }
+
+ public function getAction() {
+ /* @var $simfile Domain\Entities\StepMania\ISimfile */
+ $simfile = $this->_simfileRepository->find(1);
+ $modes = array();
+ /* @var $steps Domain\VOs\StepMania\IStepChart */
+ foreach ($simfile->getSteps() as $steps) {
+ $modes[] = $steps->getArtist()->getTag();
+ }
+
+ $this->_response->setHeader('Content-Type', 'application/json')
+ ->setBody(json_encode($modes))
+ ->sendResponse();
+ }
+}
$options = array(PDO::ATTR_EMULATE_PREPARES => false,\r
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);\r
\r
- $this->_db = new PDO($dsn, $username, null, $options); \r
+ $this->_db = new PDO($dsn, $username, $password, $options); \r
$this->_maps = include $maps;\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);
-}
-
-<?php\r
-\r
-namespace DataAccess\StepMania;\r
-\r
-use Domain\Entities\StepMania\Simfile;\r
-\r
-interface ISimfileRepository\r
-{\r
- public function find($id);\r
- public function save(Simfile $simfile);\r
- public function remove(Simfile $simfile);\r
-}\r
+<?php
+
+namespace DataAccess\StepMania;
+
+use Domain\Entities\StepMania\ISimfile;
+
+interface ISimfileRepository
+{
+ public function find($id);
+ public function save(ISimfile $entity);
+ public function remove(ISimfile $entity);
+}
+
\r
namespace DataAccess\StepMania;\r
\r
-use DataAccess\IRepository;\r
+use DataAccess\StepMania\ISimfileRepository;\r
use DataAccess\DataMapper\IDataMapper;\r
-use Domain\Entities\IDivineEntity;\r
+use Domain\Entities\StepMania\ISimfile;\r
\r
//TODO: Implement some sort of caching. Probably OK for now not to worry.\r
-class SimfileRepository implements IRepository\r
+class SimfileRepository implements ISimfileRepository\r
{\r
private $dataMapper;\r
\r
}\r
\r
public function find($id) {\r
- return $this->dataMapper->find($id, 'simfiles');\r
+ return $this->dataMapper->find($id, 'Simfile');\r
}\r
\r
- public function save(IDivineEntity $entity) {\r
+ public function save(ISimfile $entity) {\r
$this->dataMapper->save($entity);\r
}\r
\r
//TODO: Implement\r
- public function remove(IDivineEntity $entity) {\r
+ public function remove(ISimfile $entity) {\r
;\r
}\r
}\r
\r
public function setId($id) {\r
if(isset($this->id)) {\r
- // throw new Exception('ID already set.');\r
+ throw new Exception('ID already set.');\r
}\r
\r
$this->id = $id;\r
namespace Domain\Entities\StepMania;\r
\r
use Domain\VOs\StepMania\IStepChart;\r
+use Domain\Entities\IDivineEntity;\r
\r
-interface ISimfile\r
+interface ISimfile extends IDivineEntity\r
{\r
public function getTitle();\r
public function getArtist();\r
public function setBody($content)
{
$this->_body = $content;
+
+ return $this;
}
public function getBody()
private function sendBody()
{
echo $this->_body;
+
+ return $this;
}
public function sendResponse()
public function setStatusCode($code);
public function setHeader($name, $value);
public function getHeaders();
- public function setBody();
+ public function setBody($body);
public function getBody();
public function isRedirect();
public function sendResponse();
"autoload": {\r
"psr-0": {\r
"Domain" : "./",\r
- "DataAccess" : "./"\r
+ "DataAccess" : "./",\r
+ "Controllers" : "./",\r
+ "Services" : "./"\r
},\r
"files" : ["./DataAccess/functions.php"]\r
}\r
<?php\r
\r
return [\r
- 'Domain\Entities\BarInterface' => DI\object('Domain\Entities\Bar'),\r
+ //values\r
+ 'datamapper.maps' => '../config/DataMaps.php',\r
+ \r
+ 'Domain\Entities\StepMania\ISimfile' => DI\object('Domain\Entities\StepMania\Simfile'),\r
+ 'Services\IHttpResponse' => DI\object('Services\HttpResponse'),\r
+ 'DataAccess\StepMania\ISimfileRepository' => DI\object('DataAccess\StepMania\SimfileRepository'),\r
+ 'DataAccess\DataMapper\IDataMapper' => DI\object('DataAccess\DataMapper\DataMapper')\r
+ ->constructor(DI\link('datamapper.maps')), \r
];\r
\r
$containerBuilder = new DI\ContainerBuilder();\r
$containerBuilder->addDefinitions('../config/DI.php');\r
+$containerBuilder->useAutowiring(true);\r
\r
$container = $containerBuilder->build();\r
\r
+\r
+$indexController = $container->get('Controllers\IndexController');\r
+$indexController->getAction();\r
+\r
/* @var $foo Domain\Entities\Foo */\r
//$foo = $container->get('Domain\Entities\Foo');\r
//$foo->returnMe();\r
-\r
-$DataMapper = new \DataAccess\DataMapper\DataMapper('../config/DataMaps.php');\r
-$user = $DataMapper->find(1,'User');\r
-\r
-$simfileFactory = new SimfileFactory();\r
-$simfileBuilder = new SimfileBuilder($simfileFactory);\r
-$simfileStepByStepBuilder = new SimfileStepByStepBuilder($simfileBuilder);\r
-\r
-$danceMode = new DanceMode('dance-single');\r
-$difficulty = new Difficulty('challenge');\r
-$stepArtist = new StepArtist('Someone new fuck');\r
-$artist = new Artist('A brand new awesome artist!');\r
-$rating = '10';\r
-\r
-$bpm = new BPM('256', '128');\r
-$stepChart = new StepChart($danceMode,\r
- $difficulty,\r
- $stepArtist,\r
- $rating);\r
-\r
-$steps = array($stepChart);\r
-\r
-\r
-$simfile = $simfileStepByStepBuilder->With_Title('Brand New Simfile')\r
- ->With_Artist($artist)\r
- ->With_Uploader($user)\r
- ->With_BPM($bpm)\r
- ->With_BpmChanges(SimfileConstants::NO_BPM_CHANGES)\r
- ->With_Stops(SimfileConstants::NO_STOPS)\r
- ->With_FgChanges(SimfileConstants::NO_FG_CHANGES)\r
- ->With_BgChanges(SimfileConstants::NO_BG_CHANGES)\r
- ->With_Steps($steps)\r
- ->build();\r
-\r
-\r
-//$user->setId(NULL);\r
-\r
-$simfile = $DataMapper->find(1, 'Simfile');\r
-$simfile->addStepChart($stepChart);\r
-$DataMapper->save($simfile);\r
+//\r
+//$DataMapper = new \DataAccess\DataMapper\DataMapper('../config/DataMaps.php');\r
+//$user = $DataMapper->find(1,'User');\r
+//\r
+//$simfileFactory = new SimfileFactory();\r
+//$simfileBuilder = new SimfileBuilder($simfileFactory);\r
+//$simfileStepByStepBuilder = new SimfileStepByStepBuilder($simfileBuilder);\r
+//\r
+//$danceMode = new DanceMode('dance-single');\r
+//$difficulty = new Difficulty('challenge');\r
+//$stepArtist = new StepArtist('Someone new fuck');\r
+//$artist = new Artist('A brand new awesome artist!');\r
+//$rating = '10';\r
+//\r
+//$bpm = new BPM('256', '128');\r
+//$stepChart = new StepChart($danceMode,\r
+// $difficulty,\r
+// $stepArtist,\r
+// $rating);\r
+//\r
+//$steps = array($stepChart);\r
+//\r
+//\r
+//$simfile = $simfileStepByStepBuilder->With_Title('Brand New Simfile')\r
+// ->With_Artist($artist)\r
+// ->With_Uploader($user)\r
+// ->With_BPM($bpm)\r
+// ->With_BpmChanges(SimfileConstants::NO_BPM_CHANGES)\r
+// ->With_Stops(SimfileConstants::NO_STOPS)\r
+// ->With_FgChanges(SimfileConstants::NO_FG_CHANGES)\r
+// ->With_BgChanges(SimfileConstants::NO_BG_CHANGES)\r
+// ->With_Steps($steps)\r
+// ->build();\r
+//\r
+//\r
+////$user->setId(NULL);\r
+//\r
+//$simfile = $DataMapper->find(1, 'Simfile');\r
+//$simfile->addStepChart($stepChart);\r
+//$DataMapper->save($simfile);\r
\r
\r
\r