@@ 68-106 (lines=39) @@ | ||
65 | * @param ClassMetadataInterface $classMetadata |
|
66 | * @param array $mapping |
|
67 | */ |
|
68 | private function addFieldMapping(ClassMetadataInterface $classMetadata, $mapping) |
|
69 | { |
|
70 | if (isset($mapping['name'])) { |
|
71 | $name = $mapping['name']; |
|
72 | if (!isset($mapping['fieldName'])) { |
|
73 | $mapping['fieldName'] = $name; |
|
74 | } |
|
75 | } elseif (isset($mapping['fieldName'])) { |
|
76 | $name = $mapping['fieldName']; |
|
77 | if (!isset($mapping['name'])) { |
|
78 | $mapping['name'] = $name; |
|
79 | } |
|
80 | } else { |
|
81 | throw new \InvalidArgumentException('Cannot infer a name from the mapping'); |
|
82 | } |
|
83 | ||
84 | $isIdentifier = false; |
|
85 | if (isset($mapping['id']) && $mapping['id'] === true) { |
|
86 | $isIdentifier = true; |
|
87 | $mapping['name'] = '_id'; |
|
88 | } |
|
89 | ||
90 | $propertyMetadata = new PropertyMetadata( |
|
91 | $classMetadata->className(), |
|
92 | $mapping['fieldName'] |
|
93 | ); |
|
94 | ||
95 | $propertyMetadata->addMetadata('identifier', $isIdentifier); |
|
96 | $propertyMetadata->addMetadata('name', $mapping['name']); |
|
97 | ||
98 | if (isset($mapping['type'])) { |
|
99 | $propertyMetadata->addMetadata('type', $mapping['type']); |
|
100 | if (isset($mapping['of'])) { |
|
101 | $propertyMetadata->addMetadata('of', $mapping['of']); |
|
102 | } |
|
103 | } |
|
104 | ||
105 | $classMetadata->addPropertyMetadata($propertyMetadata); |
|
106 | } |
|
107 | } |
|
108 |
@@ 52-90 (lines=39) @@ | ||
49 | * @param ClassMetadataInterface $classMetadata |
|
50 | * @param array $mapping |
|
51 | */ |
|
52 | private function addFieldMapping(ClassMetadataInterface $classMetadata, $mapping) |
|
53 | { |
|
54 | if (isset($mapping['name'])) { |
|
55 | $name = $mapping['name']; |
|
56 | if (!isset($mapping['fieldName'])) { |
|
57 | $mapping['fieldName'] = $name; |
|
58 | } |
|
59 | } elseif (isset($mapping['fieldName'])) { |
|
60 | $name = $mapping['fieldName']; |
|
61 | if (!isset($mapping['name'])) { |
|
62 | $mapping['name'] = $name; |
|
63 | } |
|
64 | } else { |
|
65 | throw new \InvalidArgumentException('Cannot infer a name from the mapping'); |
|
66 | } |
|
67 | ||
68 | $isIdentifier = false; |
|
69 | if (isset($mapping['id']) && $mapping['id'] === true) { |
|
70 | $isIdentifier = true; |
|
71 | $mapping['name'] = '_id'; |
|
72 | } |
|
73 | ||
74 | $propertyMetadata = new PropertyMetadata( |
|
75 | $classMetadata->className(), |
|
76 | $mapping['fieldName'] |
|
77 | ); |
|
78 | ||
79 | $propertyMetadata->addMetadata('identifier', $isIdentifier); |
|
80 | $propertyMetadata->addMetadata('name', $mapping['name']); |
|
81 | ||
82 | if (isset($mapping['type'])) { |
|
83 | $propertyMetadata->addMetadata('type', $mapping['type']); |
|
84 | if (isset($mapping['of'])) { |
|
85 | $propertyMetadata->addMetadata('of', $mapping['of']); |
|
86 | } |
|
87 | } |
|
88 | ||
89 | $classMetadata->addPropertyMetadata($propertyMetadata); |
|
90 | } |
|
91 | } |
|
92 |