protected function parseEmbeddedClass($name, Annotation $annotation, EntityDefinition &$entityMetadata, $primaryKeyOnly = false)
    {
        // check if related class is valid
        $annotation->class = $this->getRealEntity($annotation->class, $entityMetadata['class']);

        $reflectionClass = new ReflectionClass($annotation->class);

        $classAnnotations = $this->reader->getClassAnnotations($reflectionClass);

        // check if class is embedded class
        $this->validator->validateEmbeddedClass($annotation->class, $classAnnotations);

        $embeddedColumnPrefix = ($annotation->columnPrefix || $annotation->columnPrefix === false)
            ? $annotation->columnPrefix
            : $name;

        $embeddedClassMetadata = new EmbeddedClassDefinition([
            'name' => $name,
            'class' => $annotation->class,
            'columnPrefix' => $embeddedColumnPrefix,
            'attributes' => [],
        ]);

        // scan property annotations
        foreach ($reflectionClass->getProperties() as $reflectionProperty) {
            $name = $this->getSanitizedName($reflectionProperty->getName(), $entityMetadata['class']);

            $propertyAnnotations = $this->reader->getPropertyAnnotations($reflectionProperty);

            foreach ($propertyAnnotations as $annotation) {
                // property is column
                if ($annotation instanceof \ProAI\Datamapper\Annotations\Column) {
                    $this->setAdditionalColumnProperties($name, $annotation, $propertyAnnotations, true, $embeddedColumnPrefix);

                    $embeddedClassMetadata['attributes'][] = $this->parseColumn($name, $annotation, $entityMetadata, true, $primaryKeyOnly);
                }
            }
        }

        return $embeddedClassMetadata;
    }
protected function parseEmbeddedClass($name, Annotation $annotation, EntityDefinition &$entityMetadata, $primaryKeyOnly = false)
    {
        // check if related class is valid
        $annotation->class = $this->getRealEntity($annotation->class, $entityMetadata['class']);

        $reflectionClass = new ReflectionClass($annotation->class);

        $classAnnotations = $this->reader->getClassAnnotations($reflectionClass);

        // check if class is embedded class
        $this->validator->validateEmbeddedClass($annotation->class, $classAnnotations);

        $embeddedColumnPrefix = ($annotation->columnPrefix || $annotation->columnPrefix === false)
            ? $annotation->columnPrefix
            : $name;

        $embeddedClassMetadata = new EmbeddedClassDefinition([
            'name' => $name,
            'class' => $annotation->class,
            'columnPrefix' => $embeddedColumnPrefix,
            'attributes' => [],
        ]);

        // scan property annotations
        foreach ($reflectionClass->getProperties() as $reflectionProperty) {
            $name = $this->getSanitizedName($reflectionProperty->getName(), $entityMetadata['class']);

            $propertyAnnotations = $this->reader->getPropertyAnnotations($reflectionProperty);

            foreach ($propertyAnnotations as $annotation) {
                // property is column
                if ($annotation instanceof \ProAI\Datamapper\Annotations\Column) {
                    $this->setAdditionalColumnProperties($name, $annotation, $propertyAnnotations, true, $embeddedColumnPrefix);

                    $embeddedClassMetadata['attributes'][] = $this->parseColumn($name, $annotation, $entityMetadata, true, $primaryKeyOnly);
                }
            }
        }

        return $embeddedClassMetadata;
    }
protected function parseEmbeddedClass ( $ name , Annotation $ annotation , EntityDefinition & $ entityMetadata , $ primaryKeyOnly = false ) { // check if related class is valid $ annotation -> class = $ this -> getRealEntity ( $ annotation -> class , $ entityMetadata [ 'class' ] ) ; $ reflectionClass = new ReflectionClass ( $ annotation -> class ) ; $ classAnnotations = $ this -> reader -> getClassAnnotations ( $ reflectionClass ) ; // check if class is embedded class $ this -> validator -> validateEmbeddedClass ( $ annotation -> class , $ classAnnotations ) ; $ embeddedColumnPrefix = ( $ annotation -> columnPrefix || $ annotation -> columnPrefix === false ) ? $ annotation -> columnPrefix : $ name ; $ embeddedClassMetadata = new EmbeddedClassDefinition ( [ 'name' => $ name , 'class' => $ annotation -> class , 'columnPrefix' => $ embeddedColumnPrefix , 'attributes' => [ ] , ] ) ; // scan property annotations foreach ( $ reflectionClass -> getProperties ( ) as $ reflectionProperty ) { $ name = $ this -> getSanitizedName ( $ reflectionProperty -> getName ( ) , $ entityMetadata [ 'class' ] ) ; $ propertyAnnotations = $ this -> reader -> getPropertyAnnotations ( $ reflectionProperty ) ; foreach ( $ propertyAnnotations as $ annotation ) { // property is column if ( $ annotation instanceof \ ProAI \ Datamapper \ Annotations \ Column ) { $ this -> setAdditionalColumnProperties ( $ name , $ annotation , $ propertyAnnotations , true , $ embeddedColumnPrefix ) ; $ embeddedClassMetadata [ 'attributes' ] [ ] = $ this -> parseColumn ( $ name , $ annotation , $ entityMetadata , true , $ primaryKeyOnly ) ; } } } return $ embeddedClassMetadata ; }
Parse an embedded class.

@param string $name
@param \ProAI\Datamapper\Annotations\Annotation $annotation
@param \ProAI\Datamapper\Metadata\Definitions\Entity $entityMetadata
@return \ProAI\Datamapper\Metadata\Definitions\EmbeddedClass
Parse an embedded class .