@@ 23-37 (lines=15) @@ | ||
20 | $this->registry = $registry; |
|
21 | } |
|
22 | ||
23 | public function handle($object) |
|
24 | { |
|
25 | $class = get_class($object); |
|
26 | ||
27 | $metadata = $this->registry |
|
28 | ->getManagerForClass($class) |
|
29 | ->getClassMetadata($class); |
|
30 | $identifier = $metadata->getIdentifierValues($object); |
|
31 | ||
32 | if (!$metadata instanceof ClassMetadata || $metadata->isIdentifierComposite) { |
|
33 | return $identifier; |
|
34 | } |
|
35 | ||
36 | return array_shift($identifier); |
|
37 | } |
|
38 | } |
|
39 |
@@ 46-58 (lines=13) @@ | ||
43 | throw new \BadMethodCallException('Not supported at the moment'); |
|
44 | } |
|
45 | ||
46 | private function convertEntityToIds($entity) |
|
47 | { |
|
48 | $class = get_class($entity); |
|
49 | $metadata = $this->registry->getManagerForClass($class)->getClassMetadata($class); |
|
50 | ||
51 | $ids = $metadata->getIdentifierValues($entity); |
|
52 | ||
53 | if (!$metadata instanceof ClassMetadata || $metadata->isIdentifierComposite) { |
|
54 | return $ids; |
|
55 | } |
|
56 | ||
57 | return array_shift($ids); |
|
58 | } |
|
59 | } |
|
60 |