1 | <?php |
||
9 | abstract class BaseRepository |
||
10 | { |
||
11 | /** @var \Doctrine\DBAL\Connection */ |
||
12 | protected $_con; |
||
13 | |||
14 | /** @var int */ |
||
15 | public $totalRows = 0; |
||
16 | |||
17 | |||
18 | /** @var array */ |
||
19 | private $_classFields = null; |
||
20 | |||
21 | |||
22 | |||
23 | function __construct(Connection $connection) { |
||
|
|||
24 | $this->_con = $connection; |
||
25 | } |
||
26 | |||
27 | |||
28 | protected function _getPrimaryKeyColumnName() { |
||
29 | return 'id'; |
||
30 | } |
||
31 | |||
32 | protected function _isAutoincrement() { |
||
33 | return true; |
||
34 | } |
||
35 | |||
36 | abstract function _getTableName(); |
||
37 | |||
38 | |||
39 | abstract function _getClassName(); |
||
40 | |||
41 | |||
42 | |||
43 | /** |
||
44 | * @param object|array|null $row |
||
45 | * @param string $prefix |
||
46 | * @return object|null |
||
47 | */ |
||
48 | function hydrateObject($row, $prefix = '') { |
||
57 | |||
58 | |||
59 | protected function _getNonDbFields() { |
||
62 | |||
63 | |||
64 | /** |
||
65 | * @return array field=>defaultValue |
||
66 | */ |
||
67 | protected function getClassFields() { |
||
78 | |||
79 | |||
80 | /** |
||
81 | * @return string[] |
||
82 | */ |
||
83 | function getFields() { |
||
92 | |||
93 | |||
94 | /** |
||
95 | * @param string $fieldName |
||
96 | * @return bool |
||
97 | */ |
||
98 | protected function hasClassField($fieldName) { |
||
102 | |||
103 | /** |
||
104 | * @param array $array |
||
105 | * @param string $prefix |
||
106 | * @return object[] |
||
107 | */ |
||
108 | function hydrateArray(array $array, $prefix = '') { |
||
115 | |||
116 | |||
117 | |||
118 | /** |
||
119 | * @return \BWC\Share\Data\Select |
||
120 | */ |
||
121 | protected function getCommonSelect() { |
||
124 | |||
125 | |||
126 | /** |
||
127 | * @param int $id |
||
128 | * @return object|null |
||
129 | */ |
||
130 | protected function _getByID($id) { |
||
137 | |||
138 | |||
139 | /** |
||
140 | * @param array $filter column=>value |
||
141 | * @param int $pageNum |
||
142 | * @param int $pageSize |
||
143 | * @param array|string|null $orderBy |
||
144 | * @throws \InvalidArgumentException |
||
145 | * @return object[] |
||
146 | */ |
||
147 | protected function _getAllBy(array $filter = null, $pageNum = 0, $pageSize = 0, $orderBy = null) { |
||
175 | |||
176 | |||
177 | |||
178 | /** |
||
179 | * @param object $object Entity to save |
||
180 | * @param array|null $unsetColumns |
||
181 | * @return int Affected rows |
||
182 | */ |
||
183 | protected function _save($object, array $unsetColumns = null) { |
||
206 | |||
207 | protected function _getObjectData($object) |
||
211 | |||
212 | /** |
||
213 | * @param null|array|string $columns |
||
214 | * @param null|string $alias |
||
215 | * @return Select |
||
216 | */ |
||
217 | function select($columns = null, $alias = null) { |
||
220 | |||
221 | |||
222 | /** |
||
223 | * @param $id |
||
224 | * @return int affected rows |
||
225 | */ |
||
226 | function deleteByID($id) { |
||
229 | |||
230 | |||
231 | function transactional(\Closure $func) { |
||
234 | } |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.