]> dev.renevier.net Git - syj.git/blob - application/controllers/GeomController.php
version 0.1
[syj.git] / application / controllers / GeomController.php
1 <?php
2 /*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
3     and is published under the AGPL license. */
4
5 class GeomController extends Zend_Controller_Action
6 {
7
8     public function indexAction() {
9         $request = $this->getRequest();
10         $response = $this->getResponse();
11
12         $idx = $request->idx;
13         $pathMapper = new Syj_Model_PathMapper();
14         $path = new Syj_Model_Path();
15
16         $api = $this->_helper->SyjApi;
17
18         if (!$pathMapper->find($idx, $path)) {
19             if ($pathMapper->hasexisted($idx)) {
20                 $api->setCode(410);
21             } else {
22                 $api->setCode(404);
23             }
24             return;
25         }
26
27         $api->setCheckIfNoneMatch(true)->setBody(json_encode(
28             array('owner' => (string)$path->owner->pseudo, 'geom' => (string)$path->geom)
29         ));
30     }
31 }