1 | <?php |
||
10 | abstract class BaseRow implements RowInterface |
||
11 | { |
||
12 | protected $entity; |
||
13 | protected $methods = []; |
||
14 | protected $properties = []; |
||
15 | |||
16 | /** |
||
17 | * Constructor. |
||
18 | * |
||
19 | * @param Entity $entity |
||
20 | */ |
||
21 | public function __construct(Entity $entity) |
||
25 | |||
26 | /** |
||
27 | * @see RowInterface |
||
28 | * |
||
29 | * {@inheritdoc} |
||
30 | */ |
||
31 | public function getEntity() |
||
35 | |||
36 | /** |
||
37 | * @see RowInterface |
||
38 | * |
||
39 | * {@inheritdoc} |
||
40 | */ |
||
41 | public function getAttribute($name) |
||
45 | |||
46 | /** |
||
47 | * @see RowInterface |
||
48 | * |
||
49 | * {@inheritdoc} |
||
50 | * |
||
51 | * @return self |
||
52 | */ |
||
53 | public function registerMethod($name, callable $callable) |
||
54 | { |
||
55 | $this->methods[$name] = $callable; |
||
56 | |||
57 | return $this; |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * @see RowInterface |
||
62 | * |
||
63 | * {@inheritdoc} |
||
64 | * |
||
65 | * @return self |
||
66 | */ |
||
67 | public function registerProperty($name, callable $callable) |
||
68 | { |
||
69 | $this->properties[$name] = $callable; |
||
70 | |||
71 | return $this; |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * @see JsonSerializable |
||
76 | * |
||
77 | * @return array |
||
78 | */ |
||
79 | public function jsonSerialize() |
||
83 | |||
84 | /** |
||
85 | * Deletes the row(s) in the database. |
||
86 | * |
||
87 | * @return self |
||
88 | */ |
||
89 | public function delete() |
||
103 | |||
104 | /** |
||
105 | * Magic method to execute custom methods defined in the entity class. |
||
106 | * |
||
107 | * @param string $name |
||
108 | */ |
||
109 | public function __call($name, $arguments) |
||
131 | } |
||
132 |