protected function replaceMapping($entityMetadata, &$stub)
    {
        $attributes = [];
        foreach ($entityMetadata['attributes'] as $attributeMetadata) {
            $attributes[$attributeMetadata['name']] = $attributeMetadata['columnName'];
        }

        $embeddeds = [];
        foreach ($entityMetadata['embeddeds'] as $embeddedMetadata) {
            $embedded = [];
            $embedded['class'] = $embeddedMetadata['class'];
            $embedded['columnPrefix'] = $embeddedMetadata['columnPrefix'];
            $embeddedAttributes = [];
            foreach ($embeddedMetadata['attributes'] as $attributeMetadata) {
                $embeddedAttributes[$attributeMetadata['name']] = $attributeMetadata['columnName'];
            }
            $embedded['attributes'] = $embeddedAttributes;
            $embeddeds[$embeddedMetadata['name']] = $embedded;
        }

        $relations = [];
        foreach ($entityMetadata['relations'] as $relationMetadata) {
            $relation = [];
            
            $relation['type'] = $relationMetadata['type'];
            if ($relation['type'] == 'belongsToMany' || $relation['type'] == 'morphToMany') {
                $relation['inverse'] = (! empty($relationMetadata['options']['inverse']));
            }

            $relations[$relationMetadata['name']] = $relation;
        }

        $mapping = [
            'attributes' => $attributes,
            'embeddeds' => $embeddeds,
            'relations' => $relations,
        ];

        $stub = str_replace('{{mapping}}', $this->getArrayAsText($mapping), $stub);
    }
protected function replaceMapping($entityMetadata, &$stub)
    {
        $attributes = [];
        foreach ($entityMetadata['attributes'] as $attributeMetadata) {
            $attributes[$attributeMetadata['name']] = $attributeMetadata['columnName'];
        }

        $embeddeds = [];
        foreach ($entityMetadata['embeddeds'] as $embeddedMetadata) {
            $embedded = [];
            $embedded['class'] = $embeddedMetadata['class'];
            $embedded['columnPrefix'] = $embeddedMetadata['columnPrefix'];
            $embeddedAttributes = [];
            foreach ($embeddedMetadata['attributes'] as $attributeMetadata) {
                $embeddedAttributes[$attributeMetadata['name']] = $attributeMetadata['columnName'];
            }
            $embedded['attributes'] = $embeddedAttributes;
            $embeddeds[$embeddedMetadata['name']] = $embedded;
        }

        $relations = [];
        foreach ($entityMetadata['relations'] as $relationMetadata) {
            $relation = [];
            
            $relation['type'] = $relationMetadata['type'];
            if ($relation['type'] == 'belongsToMany' || $relation['type'] == 'morphToMany') {
                $relation['inverse'] = (! empty($relationMetadata['options']['inverse']));
            }

            $relations[$relationMetadata['name']] = $relation;
        }

        $mapping = [
            'attributes' => $attributes,
            'embeddeds' => $embeddeds,
            'relations' => $relations,
        ];

        $stub = str_replace('{{mapping}}', $this->getArrayAsText($mapping), $stub);
    }
protected function replaceMapping ( $ entityMetadata , & $ stub ) { $ attributes = [ ] ; foreach ( $ entityMetadata [ 'attributes' ] as $ attributeMetadata ) { $ attributes [ $ attributeMetadata [ 'name' ] ] = $ attributeMetadata [ 'columnName' ] ; } $ embeddeds = [ ] ; foreach ( $ entityMetadata [ 'embeddeds' ] as $ embeddedMetadata ) { $ embedded = [ ] ; $ embedded [ 'class' ] = $ embeddedMetadata [ 'class' ] ; $ embedded [ 'columnPrefix' ] = $ embeddedMetadata [ 'columnPrefix' ] ; $ embeddedAttributes = [ ] ; foreach ( $ embeddedMetadata [ 'attributes' ] as $ attributeMetadata ) { $ embeddedAttributes [ $ attributeMetadata [ 'name' ] ] = $ attributeMetadata [ 'columnName' ] ; } $ embedded [ 'attributes' ] = $ embeddedAttributes ; $ embeddeds [ $ embeddedMetadata [ 'name' ] ] = $ embedded ; } $ relations = [ ] ; foreach ( $ entityMetadata [ 'relations' ] as $ relationMetadata ) { $ relation = [ ] ; $ relation [ 'type' ] = $ relationMetadata [ 'type' ] ; if ( $ relation [ 'type' ] == 'belongsToMany' || $ relation [ 'type' ] == 'morphToMany' ) { $ relation [ 'inverse' ] = ( ! empty ( $ relationMetadata [ 'options' ] [ 'inverse' ] ) ) ; } $ relations [ $ relationMetadata [ 'name' ] ] = $ relation ; } $ mapping = [ 'attributes' => $ attributes , 'embeddeds' => $ embeddeds , 'relations' => $ relations , ] ; $ stub = str_replace ( '{{mapping}}' , $ this -> getArrayAsText ( $ mapping ) , $ stub ) ; }
Replace mapping.

@param \ProAI\Datamapper\Metadata\Definitions\Entity $entityMetadata
@param string $stub
@return void
Replace mapping .