private function setAttributes(ClassMetadataInfo $metadata, Metadata\AttributeInterface $entity)
    {
        foreach ($metadata->fieldMappings as $fieldKey => $mapping) {
            if (isset($mapping['id'])) {
                // Id field. Skip.
                continue;
            }
            if (isset($mapping['reference'])) {
                // Relationship. Skip.
                continue;
            }
            if (isset($mapping['inherited']) || isset($mapping['declared'])) {
                // Inherited. Skip.
                continue;
            }
            if (!isset($mapping['type'])) {
                // Unable to map. No type.
                throw new RuntimeException(sprintf('Cannot create an attribute for field "%s" because no data type was found', $fieldKey));
            }

            $entityDataType = isset($mapping['embedded']) ? 'object' : $this->getDataType($mapping['type']);
            // $this->validator->validateDataType($apiDataType);

            switch ($entityDataType) {
                // case 'object':
                //     $attribute = new Metadata\ObjectAttributeMetadata($fieldKey, 'object');
                //     // @todo This needs some work. How do we determine the child attributes of polymorphic embedded documents?
                //     if (isset($mapping['embedded']) && isset($mapping['targetDocument'])) {
                //         $childMetadata = $this->mf->getMetadataFor($mapping['targetDocument']);
                //         if (false === $this->isPolymorphicType($childMetadata)) {
                //             $this->setAttributes($childMetadata, $attribute);
                //         }
                //     }
                //     break;
                // case 'array':
                //     $attribute = new Metadata\ArrayAttributeMetadata($fieldKey, 'array', 'mixed');
                //     break;
                default:
                    $attribute = new Metadata\AttributeMetadata($fieldKey, $entityDataType);
                    break;
            }
            $entity->addAttribute($attribute);
        }
        return $entity;
    }
private function setAttributes(ClassMetadataInfo $metadata, Metadata\AttributeInterface $entity)
    {
        foreach ($metadata->fieldMappings as $fieldKey => $mapping) {
            if (isset($mapping['id'])) {
                // Id field. Skip.
                continue;
            }
            if (isset($mapping['reference'])) {
                // Relationship. Skip.
                continue;
            }
            if (isset($mapping['inherited']) || isset($mapping['declared'])) {
                // Inherited. Skip.
                continue;
            }
            if (!isset($mapping['type'])) {
                // Unable to map. No type.
                throw new RuntimeException(sprintf('Cannot create an attribute for field "%s" because no data type was found', $fieldKey));
            }

            $entityDataType = isset($mapping['embedded']) ? 'object' : $this->getDataType($mapping['type']);
            // $this->validator->validateDataType($apiDataType);

            switch ($entityDataType) {
                // case 'object':
                //     $attribute = new Metadata\ObjectAttributeMetadata($fieldKey, 'object');
                //     // @todo This needs some work. How do we determine the child attributes of polymorphic embedded documents?
                //     if (isset($mapping['embedded']) && isset($mapping['targetDocument'])) {
                //         $childMetadata = $this->mf->getMetadataFor($mapping['targetDocument']);
                //         if (false === $this->isPolymorphicType($childMetadata)) {
                //             $this->setAttributes($childMetadata, $attribute);
                //         }
                //     }
                //     break;
                // case 'array':
                //     $attribute = new Metadata\ArrayAttributeMetadata($fieldKey, 'array', 'mixed');
                //     break;
                default:
                    $attribute = new Metadata\AttributeMetadata($fieldKey, $entityDataType);
                    break;
            }
            $entity->addAttribute($attribute);
        }
        return $entity;
    }
private function setAttributes ( ClassMetadataInfo $ metadata , Metadata \ AttributeInterface $ entity ) { foreach ( $ metadata -> fieldMappings as $ fieldKey => $ mapping ) { if ( isset ( $ mapping [ 'id' ] ) ) { // Id field. Skip. continue ; } if ( isset ( $ mapping [ 'reference' ] ) ) { // Relationship. Skip. continue ; } if ( isset ( $ mapping [ 'inherited' ] ) || isset ( $ mapping [ 'declared' ] ) ) { // Inherited. Skip. continue ; } if ( ! isset ( $ mapping [ 'type' ] ) ) { // Unable to map. No type. throw new RuntimeException ( sprintf ( 'Cannot create an attribute for field "%s" because no data type was found' , $ fieldKey ) ) ; } $ entityDataType = isset ( $ mapping [ 'embedded' ] ) ? 'object' : $ this -> getDataType ( $ mapping [ 'type' ] ) ; // $this->validator->validateDataType($apiDataType); switch ( $ entityDataType ) { // case 'object': //     $attribute = new Metadata\ObjectAttributeMetadata($fieldKey, 'object'); //     // @todo This needs some work. How do we determine the child attributes of polymorphic embedded documents? //     if (isset($mapping['embedded']) && isset($mapping['targetDocument'])) { //         $childMetadata = $this->mf->getMetadataFor($mapping['targetDocument']); //         if (false === $this->isPolymorphicType($childMetadata)) { //             $this->setAttributes($childMetadata, $attribute); //         } //     } //     break; // case 'array': //     $attribute = new Metadata\ArrayAttributeMetadata($fieldKey, 'array', 'mixed'); //     break; default : $ attribute = new Metadata \ AttributeMetadata ( $ fieldKey , $ entityDataType ) ; break ; } $ entity -> addAttribute ( $ attribute ) ; } return $ entity ; }
Sets the entity attribute metadata from the Doctrine class metadata.

@todo    Validate data types / handle Doctrine to Modlr conversion.
@todo    Handle complex attribute types like objects and arrays (embededded docs?)
@param   ClassMetadataInfo           $metadata
@param   Metadata\AttributeInterface $entity
@return  Metadata\EntityMetadata
@throws  RuntimeException            If a Doctrine data type was not foind on the Doctrine field mapping.
Sets the entity attribute metadata from the Doctrine class metadata .