コード例 #1
0
 /**
  * @param ColumnInfoInterface  $columnInfo
  * @param ORMClassMetadataInfo $metadata
  *
  * @return array
  */
 private function getORMTransformerInfo(ColumnInfoInterface $columnInfo, ORMClassMetadataInfo $metadata)
 {
     if (!$metadata->hasAssociation($columnInfo->getPropertyPath())) {
         return;
     }
     $mapping = $metadata->getAssociationMapping($columnInfo->getPropertyPath());
     if (!$this->doctrine->getRepository($mapping['targetEntity']) instanceof ReferableEntityRepositoryInterface) {
         return;
     }
     return array($this->transformer, array('class' => $mapping['targetEntity'], 'multiple' => ORMClassMetadataInfo::MANY_TO_MANY === $mapping['type']));
 }
コード例 #2
0
 /**
  * @param $association
  * @param ClassMetadataInfo $meta
  * @return ManyToMany|ManyToOne|OneToMany|OneToOne
  * @throws \Doctrine\ORM\Mapping\MappingException
  */
 private function getAssocicationHandler($association, ClassMetadataInfo $meta)
 {
     $mapping = $meta->getAssociationMapping($association);
     switch ($mapping['type']) {
         case ClassMetadataInfo::ONE_TO_ONE:
             $assoc = new OneToOne($this->accessor, $this);
             break;
         case ClassMetadataInfo::MANY_TO_ONE:
             $assoc = new ManyToOne($this->accessor, $this);
             break;
         case ClassMetadataInfo::ONE_TO_MANY:
             $assoc = new OneToMany($this->accessor, $this);
             break;
         case ClassMetadataInfo::MANY_TO_MANY:
             $assoc = new ManyToMany($this->accessor, $this);
             break;
     }
     return $assoc;
 }
コード例 #3
0
 protected function findTranslationsCollection(Reader $reader, ClassMetadataInfo $classMetadata)
 {
     foreach ($classMetadata->getReflectionClass()->getProperties() as $property) {
         $annotation = $reader->getPropertyAnnotation($property, 'Webfactory\\Bundle\\PolyglotBundle\\Annotation\\TranslationCollection');
         if ($annotation !== null) {
             $property->setAccessible(true);
             $this->translationsCollectionProperty = $property;
             $am = $classMetadata->getAssociationMapping($property->getName());
             $this->parseTranslationsEntity($reader, $am['targetEntity']);
             $translationMappingProperty = $this->translationClass->getProperty($am['mappedBy']);
             $translationMappingProperty->setAccessible(true);
             $this->translationMappingProperty = $translationMappingProperty;
             break;
         }
     }
 }
コード例 #4
0
 private function isUniDirectional()
 {
     $mapping = $this->meta->getAssociationMapping($this->association);
     return null === $mapping['mappedBy'] && null === $mapping['inversedBy'];
 }
コード例 #5
0
ファイル: RevisionManager.php プロジェクト: opifer/revisions
 /**
  * @param ClassMetadataInfo $meta
  * @param string            $field
  * @param mixed             $value
  */
 protected function mapValue(ClassMetadataInfo $meta, $field, &$value)
 {
     if ($meta->isSingleValuedAssociation($field)) {
         $mapping = $meta->getAssociationMapping($field);
         $value = $value ? $this->em->getReference($mapping['targetEntity'], $value) : null;
         return;
     }
     $type = Type::getType($meta->fieldMappings[$field]['type']);
     $value = $type->convertToPHPValue($value, $this->em->getConnection()->getDatabasePlatform());
 }
コード例 #6
0
 /**
  * @param ClassMetadataInfo $metadata
  * @param Field             $field
  * @param SchemaContainer   $schemaContainer
  * @return TypeGuess
  * @throws MappingException
  */
 private function guessAssociation(ClassMetadataInfo $metadata, Field $field, SchemaContainer $schemaContainer)
 {
     $property = $field->getProperty() ?: $field->getName();
     $multiple = $metadata->isCollectionValuedAssociation($property);
     $mapping = $metadata->getAssociationMapping($property);
     foreach ($schemaContainer->getTypes() as $type) {
         $containerContext = new ContainerContext($type, $schemaContainer);
         if (!$this->isFieldContainerSupported($containerContext)) {
             continue;
         }
         if ($type->getModel() === $mapping['targetEntity']) {
             $typeName = $type->getName();
             if ($multiple) {
                 $typeName = sprintf('[%s]', $typeName);
             }
             return new TypeGuess($typeName, Guess::HIGH_CONFIDENCE);
         }
     }
 }