1 | <?php |
||
28 | class RelationalEntity extends Entity implements \JsonSerializable { |
||
29 | |||
30 | private $_relations = array(); |
||
31 | private $_resolvedProperties = []; |
||
32 | |||
33 | /** |
||
34 | * Mark a property as relation so it will not get updated using Mapper::update |
||
35 | * @param string $property string Name of the property |
||
36 | */ |
||
37 | public function addRelation($property) { |
||
42 | |||
43 | /** |
||
44 | * Mark a property as resolvable via resolveRelation() |
||
45 | * @param string $property string Name of the property |
||
46 | */ |
||
47 | public function addResolvable($property) { |
||
50 | |||
51 | /** |
||
52 | * Mark am attribute as updated |
||
53 | * overwritten from \OCP\AppFramework\Db\Entity to avoid writing relational attributes |
||
54 | * @param string $attribute the name of the attribute |
||
55 | * @since 7.0.0 |
||
56 | */ |
||
57 | protected function markFieldUpdated($attribute) { |
||
62 | |||
63 | /** |
||
64 | * @return array serialized data |
||
65 | * @throws \ReflectionException |
||
66 | */ |
||
67 | public function jsonSerialize() { |
||
86 | |||
87 | /* |
||
88 | * Resolve relational data from external methods |
||
89 | * |
||
90 | * example usage: |
||
91 | * |
||
92 | * in Board::__construct() |
||
93 | * $this->addResolvable('owner') |
||
94 | * |
||
95 | * in BoardMapper |
||
96 | * $board->resolveRelation('owner', function($owner) use (&$userManager) { |
||
97 | * return new \OCA\Deck\Db\User($userManager->get($owner)); |
||
98 | * }); |
||
99 | * |
||
100 | * resolved values can be obtained by calling resolveProperty |
||
101 | * e.g. $board->resolveOwner() |
||
102 | * |
||
103 | * @param string $property name of the property |
||
104 | * @param callable $resolver anonymous function to resolve relational |
||
105 | * data defined by $property as unique identifier |
||
106 | * @throws \Exception |
||
107 | */ |
||
108 | public function resolveRelation($property, $resolver) { |
||
120 | |||
121 | public function __call($methodName, $args) { |
||
140 | |||
141 | } |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.