ProjectController.php
1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
* Created by PhpStorm.
* User: Alex Savenko
* Date: 06.02.2017
* Time: 19:06
*/
namespace App\Controllers;
use PhalconRest\Mvc\Controllers\CrudResourceController;
class ProjectController extends CrudResourceController {
public function test_post() {
$response = [
'test' => '123'
];
return $response;
}
public function test_get($id)
{
$item = $this->getFindData($id);
return $this->getModelPrimaryKey();
return 'breakpoint';
if (!$item) {
return $this->onItemNotFound($id);
}
if (!$this->findAllowed($id, $item)) {
return $this->onNotAllowed();
}
$response = $this->getFindResponse($item);
return '123';
}
protected function getFindData($id)
{
$phqlBuilder = $this->phqlQueryParser->fromQuery($this->query, $this->getResource());
$phqlBuilder
->andWhere('[' . $this->getResource()->getModel() . '].' . 'id = '.$id);
$this->modifyReadQuery($phqlBuilder);
$this->modifyFindQuery($phqlBuilder, $id);
$results = $phqlBuilder->getQuery()->execute();
return count($results) >= 1 ? $results->getFirst() : null;
}
protected function getModelPrimaryKey()
{
return 'id';
}
}