示例#1
0
 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);
     }
 }