5bf7e789a1b92bb7451845e227352b986ee3fec0
[rock.divinelegy.git] / Controllers / SimfileController.php
1 <?php
2
3 namespace Controllers;
4
5 use Controllers\IDivineController;
6 use Services\Http\IHttpRequest;
7 use Services\Http\IHttpResponse;
8 use DataAccess\StepMania\ISimfileRepository;
9
10 class SimfileController implements IDivineController
11 {
12 private $_simfileRepository;
13 private $_response;
14 private $_request;
15
16 public function __construct(
17 IHttpRequest $request,
18 IHttpResponse $response,
19 ISimfileRepository $repository
20 ) {
21 $this->_request = $request;
22 $this->_response = $response;
23 $this->_simfileRepository = $repository;
24 }
25
26 public function indexAction() {
27 ;
28 }
29
30 // list simfiles
31 public function listAction()
32 {
33 /* @var $simfile Domain\Entities\StepMania\ISimfile */
34 $simfiles = $this->_simfileRepository->findRange(1, 10);
35 $returnArray = array();
36
37 foreach($simfiles as $simfile)
38 {
39 $returnArray[$simfile->getTitle()] = array('artist' => $simfile->getArtist()->getName());
40 }
41
42 $this->_response->setHeader('Content-Type', 'application/json')
43 ->setBody(json_encode($returnArray))
44 ->sendResponse();
45 }
46
47 public function testAction($testArg)
48 {
49 $this->_response->setHeader('Content-Type', 'application/json')
50 ->setBody(json_encode(array('testArg' => $testArg)))
51 ->sendResponse();
52 }
53 }