Blame view

app/library/App/Controllers/ProjectController.php 1.31 KB
895c22b9   Alex Savenko   project entity
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  <?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 {
  
9bf99563   Alex Savenko   test
16
      public function test_post() {
895c22b9   Alex Savenko   project entity
17
  
bb82efbf   Alex Savenko   project entity
18
19
20
21
          $response = [
              'test' => '123'
          ];
  
567d2c92   Alex Savenko   user registration
22
          return $response;
895c22b9   Alex Savenko   project entity
23
24
25
  
      }
  
be063157   Alex Savenko   test
26
      public function test_get($id)
a2321aea   Alex Savenko   test
27
      {
89b5dccb   Alex Savenko   test
28
29
30
  
  
  
9b9bc6cb   Alex Savenko   test
31
          $item = $this->getFindData($id);
4a613a0d   Alex Savenko   test
32
33
          return $this->getModelPrimaryKey();
  
407cbf40   Alex Savenko   test
34
          return 'breakpoint';
a2321aea   Alex Savenko   test
35
36
37
38
39
40
41
          if (!$item) {
              return $this->onItemNotFound($id);
          }
  
          if (!$this->findAllowed($id, $item)) {
              return $this->onNotAllowed();
          }
d41ac1d1   Alex Savenko   test
42
  
a2321aea   Alex Savenko   test
43
44
45
46
47
          $response = $this->getFindResponse($item);
  
          return '123';
      }
  
89b5dccb   Alex Savenko   test
48
49
50
51
52
      protected function getFindData($id)
      {
          $phqlBuilder = $this->phqlQueryParser->fromQuery($this->query, $this->getResource());
  
          $phqlBuilder
d3ddef74   Alex Savenko   test
53
              ->andWhere('[' . $this->getResource()->getModel() . '].' . 'id = '.$id);
89b5dccb   Alex Savenko   test
54
55
56
57
58
59
60
61
62
  
          $this->modifyReadQuery($phqlBuilder);
          $this->modifyFindQuery($phqlBuilder, $id);
  
          $results = $phqlBuilder->getQuery()->execute();
  
          return count($results) >= 1 ? $results->getFirst() : null;
      }
  
67c81060   Alex Savenko   test
63
64
65
66
67
      protected function getModelPrimaryKey()
      {
          return 'id';
      }
  
895c22b9   Alex Savenko   project entity
68
  }