public function setup() { $this->metadata = new ClassMetadata(Mapped::class); $reflService = new RuntimeReflectionService(); $this->metadata->initializeReflection($reflService); $this->metadata->mapRid('rid'); $this->metadata->mapField(['fieldName' => 'field', 'name' => 'field', 'type' => 'string']); $this->metadata->mapLink(['fieldName' => 'assoc', 'name' => 'assoc']); $this->metadata->mapLinkSet(['fieldName' => 'multiassoc', 'name' => 'multiassoc']); $this->metadata->wakeupReflection($reflService); }
private function addLinkMapping(ClassMetadata $class, \SimpleXMLElement $embed, $type) { $attributes = $embed->attributes(); $mapping = ['cascade' => isset($embed->cascade) ? $this->_getCascadeMappings($embed->cascade) : []]; $this->_copyCommonPropertyAttributesToMapping($attributes, $mapping); if (isset($attributes['orphan-removal'])) { $mapping['orphanRemoval'] = (string) $attributes['orphan-removal'] === 'true'; } if (isset($attributes['parent-property'])) { $mapping['parentProperty'] = (string) $attributes['parent-property']; } if (isset($attributes['child-property'])) { $mapping['childProperty'] = (string) $attributes['child-property']; } switch ($type) { case 'one': $class->mapLink($mapping); break; case 'list': $class->mapLinkList($mapping); break; case 'set': $class->mapLinkSet($mapping); break; case 'map': $class->mapLinkMap($mapping); break; default: throw MappingException::invalidCollectionType($class->name, $type); } }