1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the Zemit Framework. |
5
|
|
|
* |
6
|
|
|
* (c) Zemit Team <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE.txt |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Zemit\Mvc\Controller\Traits\Actions\Rest; |
13
|
|
|
|
14
|
|
|
use Phalcon\Http\ResponseInterface; |
15
|
|
|
use Zemit\Mvc\Controller\Traits\Abstracts\AbstractExpose; |
16
|
|
|
use Zemit\Mvc\Controller\Traits\Abstracts\AbstractInjectable; |
17
|
|
|
use Zemit\Mvc\Controller\Traits\Abstracts\AbstractParams; |
18
|
|
|
use Zemit\Mvc\Controller\Traits\Abstracts\AbstractQuery; |
19
|
|
|
use Zemit\Mvc\Controller\Traits\Abstracts\AbstractRestResponse; |
20
|
|
|
|
21
|
|
|
trait FindAction |
22
|
|
|
{ |
23
|
|
|
use AbstractExpose; |
24
|
|
|
use AbstractParams; |
25
|
|
|
use AbstractQuery; |
26
|
|
|
use AbstractInjectable; |
27
|
|
|
use AbstractRestResponse; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Find and expose the resultset. |
31
|
|
|
* @link findAction() |
32
|
|
|
* |
33
|
|
|
* @deprecated use {@link findAction()} |
34
|
|
|
* @return ResponseInterface The HTTP response that indicates the success of retrieving all records. |
35
|
|
|
* @throws \Exception |
36
|
|
|
*/ |
37
|
|
|
public function getAllAction(): ResponseInterface |
38
|
|
|
{ |
39
|
|
|
return $this->findAction(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Find with relationships and expose the resultset. |
44
|
|
|
* @link findWithAction() |
45
|
|
|
* |
46
|
|
|
* @deprecated use {@link findWithAction()} |
47
|
|
|
* @return ResponseInterface The HTTP response that contains the resultset with the relationships. |
48
|
|
|
* @throws \Exception |
49
|
|
|
*/ |
50
|
|
|
public function getAllWithAction(): ResponseInterface |
51
|
|
|
{ |
52
|
|
|
return $this->findWithAction(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Find and expose the resultset. |
57
|
|
|
* |
58
|
|
|
* This method finds the resultset and exposes it for further processing. |
59
|
|
|
* |
60
|
|
|
* @return ResponseInterface The HTTP response that indicates the success of finding and exposing the resultset. |
61
|
|
|
* @throws \Exception |
62
|
|
|
*/ |
63
|
|
|
public function findAction(): ResponseInterface |
64
|
|
|
{ |
65
|
|
|
$this->view->setVar('data', $this->listExpose($this->find()->toArray())); |
66
|
|
|
return $this->setRestResponse(true); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Find with relationships and expose the resultset. |
71
|
|
|
* |
72
|
|
|
* This method finds the resultset with relationships and exposes it for further processing. |
73
|
|
|
* |
74
|
|
|
* @return ResponseInterface The HTTP response that indicates the success of finding and exposing the resultset. |
75
|
|
|
* @throws \Exception |
76
|
|
|
*/ |
77
|
|
|
public function findWithAction(): ResponseInterface |
78
|
|
|
{ |
79
|
|
|
$this->view->setVar('data', $this->listExpose($this->findWith())); |
80
|
|
|
return $this->setRestResponse(true); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|