1 | <?php |
||
13 | class CodeigniterModel extends \CI_Model |
||
14 | { |
||
15 | /** |
||
16 | * @var \Rougin\Credo\Credo |
||
17 | */ |
||
18 | protected $credo; |
||
19 | |||
20 | /** |
||
21 | * @var \Doctrine\ORM\EntityRepository |
||
22 | */ |
||
23 | protected $repository; |
||
24 | |||
25 | 3 | public function __construct() |
|
32 | |||
33 | /** |
||
34 | * Returns all of the models from the database. |
||
35 | * |
||
36 | * @return array |
||
37 | */ |
||
38 | 3 | public function all() |
|
42 | |||
43 | /** |
||
44 | * Deletes the specified ID of the model from the database. |
||
45 | * |
||
46 | * @param integer $id |
||
47 | * @return void |
||
48 | */ |
||
49 | 3 | public function delete($id) |
|
58 | |||
59 | /** |
||
60 | * Finds an entity by its primary key / identifier. |
||
61 | * |
||
62 | * @param mixed $id |
||
63 | * @param int|null $lockMode |
||
64 | * @param int|null $lockVersion |
||
65 | * @return object|null |
||
66 | */ |
||
67 | 9 | public function find($id, $lockMode = null, $lockVersion = null) |
|
71 | |||
72 | /** |
||
73 | * Finds models by a set of criteria. |
||
74 | * |
||
75 | * @param array $criteria |
||
76 | * @param array|null $orderBy |
||
77 | * @param integer|null $limit |
||
78 | * @param integer|null $offset |
||
79 | * @return array |
||
80 | */ |
||
81 | 3 | public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
|
82 | { |
||
83 | 3 | return $this->repository->findBy($criteria, $orderBy, $limit, $offset); |
|
84 | } |
||
85 | |||
86 | /** |
||
87 | * Inserts a new row into the table. |
||
88 | * |
||
89 | * @param array $data |
||
90 | * @return integer |
||
91 | */ |
||
92 | 3 | public function insert(array $data) |
|
105 | |||
106 | /** |
||
107 | * Updates the selected row from the table. |
||
108 | * |
||
109 | * @param integer $id |
||
110 | * @param array $data |
||
111 | * @return boolean |
||
112 | */ |
||
113 | 3 | public function update($id, array $data) |
|
127 | |||
128 | /** |
||
129 | * Calls methods from CodeigniterModel in underscore case. |
||
130 | * |
||
131 | * @param string $method |
||
132 | * @param mixed $parameters |
||
133 | * @return mixed |
||
134 | */ |
||
135 | 6 | public function __call($method, $parameters) |
|
139 | } |
||
140 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: