|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Bluz Framework Component |
|
4
|
|
|
* |
|
5
|
|
|
* @copyright Bluz PHP Team |
|
6
|
|
|
* @link https://github.com/bluzphp/framework |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
declare(strict_types=1); |
|
10
|
|
|
|
|
11
|
|
|
namespace Bluz\Crud; |
|
12
|
|
|
|
|
13
|
|
|
use Bluz\Application\Exception\NotImplementedException; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Crud |
|
17
|
|
|
* |
|
18
|
|
|
* @package Bluz\Crud |
|
19
|
|
|
* @author Anton Shevchuk |
|
20
|
|
|
* @link https://github.com/bluzphp/framework/wiki/Crud |
|
21
|
|
|
*/ |
|
22
|
|
|
abstract class AbstractCrud |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* Default limit for READ SET of elements |
|
26
|
|
|
*/ |
|
27
|
|
|
const DEFAULT_LIMIT = 10; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Get CRUD Instance |
|
31
|
|
|
* |
|
32
|
|
|
* @return static |
|
33
|
|
|
*/ |
|
34
|
16 |
|
public static function getInstance() |
|
35
|
|
|
{ |
|
36
|
16 |
|
static $instance; |
|
37
|
16 |
|
if (null === $instance) { |
|
38
|
1 |
|
$instance = new static(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
16 |
|
return $instance; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Return primary key signature |
|
46
|
|
|
* |
|
47
|
|
|
* @return array |
|
48
|
|
|
*/ |
|
49
|
|
|
abstract public function getPrimaryKey(); |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Get item by primary key(s) |
|
53
|
|
|
* |
|
54
|
|
|
* @param mixed $primary |
|
55
|
|
|
* |
|
56
|
|
|
* @return mixed |
|
57
|
|
|
* @throws NotImplementedException |
|
58
|
|
|
*/ |
|
59
|
1 |
|
public function readOne($primary) |
|
60
|
|
|
{ |
|
61
|
1 |
|
throw new NotImplementedException(); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Get collection of items |
|
66
|
|
|
* |
|
67
|
|
|
* @param integer $offset |
|
68
|
|
|
* @param integer $limit |
|
69
|
|
|
* @param array $params |
|
70
|
|
|
* @param null $total |
|
71
|
|
|
* |
|
72
|
|
|
* @return mixed |
|
73
|
|
|
* @throws NotImplementedException |
|
74
|
|
|
*/ |
|
75
|
1 |
|
public function readSet($offset = 0, $limit = self::DEFAULT_LIMIT, $params = [], &$total = null) |
|
|
|
|
|
|
76
|
|
|
{ |
|
77
|
1 |
|
throw new NotImplementedException(); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Create new item |
|
82
|
|
|
* |
|
83
|
|
|
* @param array $data |
|
84
|
|
|
* |
|
85
|
|
|
* @return mixed |
|
86
|
|
|
* @throws NotImplementedException |
|
87
|
|
|
*/ |
|
88
|
1 |
|
public function createOne($data) |
|
89
|
|
|
{ |
|
90
|
1 |
|
throw new NotImplementedException(); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* Create items |
|
95
|
|
|
* |
|
96
|
|
|
* @param array $data |
|
97
|
|
|
* |
|
98
|
|
|
* @return mixed |
|
99
|
|
|
* @throws NotImplementedException |
|
100
|
|
|
*/ |
|
101
|
1 |
|
public function createSet($data) |
|
|
|
|
|
|
102
|
|
|
{ |
|
103
|
1 |
|
throw new NotImplementedException(); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Update item |
|
108
|
|
|
* |
|
109
|
|
|
* @param mixed $primary |
|
110
|
|
|
* @param array $data |
|
111
|
|
|
* |
|
112
|
|
|
* @return integer |
|
113
|
|
|
* @throws NotImplementedException |
|
114
|
|
|
*/ |
|
115
|
1 |
|
public function updateOne($primary, $data) |
|
116
|
|
|
{ |
|
117
|
1 |
|
throw new NotImplementedException(); |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* Update items |
|
122
|
|
|
* |
|
123
|
|
|
* @param array $data |
|
124
|
|
|
* |
|
125
|
|
|
* @return integer |
|
126
|
|
|
* @throws NotImplementedException |
|
127
|
|
|
*/ |
|
128
|
1 |
|
public function updateSet($data) |
|
|
|
|
|
|
129
|
|
|
{ |
|
130
|
1 |
|
throw new NotImplementedException(); |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* Delete item |
|
135
|
|
|
* |
|
136
|
|
|
* @param mixed $primary |
|
137
|
|
|
* |
|
138
|
|
|
* @return integer |
|
139
|
|
|
* @throws NotImplementedException |
|
140
|
|
|
*/ |
|
141
|
1 |
|
public function deleteOne($primary) |
|
142
|
|
|
{ |
|
143
|
1 |
|
throw new NotImplementedException(); |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* Delete items |
|
148
|
|
|
* |
|
149
|
|
|
* @param array $data |
|
150
|
|
|
* |
|
151
|
|
|
* @return integer |
|
152
|
|
|
* @throws NotImplementedException |
|
153
|
|
|
*/ |
|
154
|
1 |
|
public function deleteSet($data) |
|
|
|
|
|
|
155
|
|
|
{ |
|
156
|
1 |
|
throw new NotImplementedException(); |
|
157
|
|
|
} |
|
158
|
|
|
} |
|
159
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.