application/Espo/Core/Utils/Database/Orm/Converter.php
protected function correctFields($entityName, array $ormMetadata)
    {
        $entityDefs = $this->getEntityDefs();

        $entityMetadata = $ormMetadata[$entityName];
        //load custom field definitions and customCodes
        foreach ($entityMetadata['fields'] as $fieldName => $fieldParams) {
            if (empty($fieldParams['type'])) continue;

            $fieldType = ucfirst($fieldParams['type']);
            $className = '\Espo\Custom\Core\Utils\Database\Orm\Fields\\' . $fieldType;
            if (!class_exists($className)) {
                $className = '\Espo\Core\Utils\Database\Orm\Fields\\' . $fieldType;
            }

            if (class_exists($className) && method_exists($className, 'load')) {
                $helperClass = new $className($this->metadata, $ormMetadata, $entityDefs);
                $fieldResult = $helperClass->process($fieldName, $entityName);
                if (isset($fieldResult['unset'])) {
                    $ormMetadata = Util::unsetInArray($ormMetadata, $fieldResult['unset']);
                    unset($fieldResult['unset']);
                }

                $ormMetadata = Util::merge($ormMetadata, $fieldResult);
            }

            $defaultAttributes = $this->metadata->get(['entityDefs', $entityName, 'fields', $fieldName, 'defaultAttributes']);
            if ($defaultAttributes && array_key_exists($fieldName, $defaultAttributes)) {
                $defaultMetadataPart = array(
                    $entityName => array(
                        'fields' => array(
                            $fieldName => array(
                                'default' => $defaultAttributes[$fieldName]
                            )
                        )
                    )
                );
                $ormMetadata = Util::merge($ormMetadata, $defaultMetadataPart);
            }
        }

        //todo move to separate file
        //add a field 'isFollowed' for scopes with 'stream => true'
        $scopeDefs = $this->getMetadata()->get('scopes.'.$entityName);
        if (isset($scopeDefs['stream']) && $scopeDefs['stream']) {
            if (!isset($entityMetadata['fields']['isFollowed'])) {
                $ormMetadata[$entityName]['fields']['isFollowed'] = array(
                    'type' => 'varchar',
                    'notStorable' => true,
                    'notExportable' => true,
                );

                $ormMetadata[$entityName]['fields']['followersIds'] = array(
                    'type' => 'jsonArray',
                    'notStorable' => true,
                    'notExportable' => true,
                );
                $ormMetadata[$entityName]['fields']['followersNames'] = array(
                    'type' => 'jsonObject',
                    'notStorable' => true,
                    'notExportable' => true,
                );
            }
        } //END: add a field 'isFollowed' for stream => true

        return $ormMetadata;
    }
protected function correctFields($entityName, array $ormMetadata)
    {
        $entityDefs = $this->getEntityDefs();

        $entityMetadata = $ormMetadata[$entityName];
        //load custom field definitions and customCodes
        foreach ($entityMetadata['fields'] as $fieldName => $fieldParams) {
            if (empty($fieldParams['type'])) continue;

            $fieldType = ucfirst($fieldParams['type']);
            $className = '\Espo\Custom\Core\Utils\Database\Orm\Fields\\' . $fieldType;
            if (!class_exists($className)) {
                $className = '\Espo\Core\Utils\Database\Orm\Fields\\' . $fieldType;
            }

            if (class_exists($className) && method_exists($className, 'load')) {
                $helperClass = new $className($this->metadata, $ormMetadata, $entityDefs);
                $fieldResult = $helperClass->process($fieldName, $entityName);
                if (isset($fieldResult['unset'])) {
                    $ormMetadata = Util::unsetInArray($ormMetadata, $fieldResult['unset']);
                    unset($fieldResult['unset']);
                }

                $ormMetadata = Util::merge($ormMetadata, $fieldResult);
            }

            $defaultAttributes = $this->metadata->get(['entityDefs', $entityName, 'fields', $fieldName, 'defaultAttributes']);
            if ($defaultAttributes && array_key_exists($fieldName, $defaultAttributes)) {
                $defaultMetadataPart = array(
                    $entityName => array(
                        'fields' => array(
                            $fieldName => array(
                                'default' => $defaultAttributes[$fieldName]
                            )
                        )
                    )
                );
                $ormMetadata = Util::merge($ormMetadata, $defaultMetadataPart);
            }
        }

        //todo move to separate file
        //add a field 'isFollowed' for scopes with 'stream => true'
        $scopeDefs = $this->getMetadata()->get('scopes.'.$entityName);
        if (isset($scopeDefs['stream']) && $scopeDefs['stream']) {
            if (!isset($entityMetadata['fields']['isFollowed'])) {
                $ormMetadata[$entityName]['fields']['isFollowed'] = array(
                    'type' => 'varchar',
                    'notStorable' => true,
                    'notExportable' => true,
                );

                $ormMetadata[$entityName]['fields']['followersIds'] = array(
                    'type' => 'jsonArray',
                    'notStorable' => true,
                    'notExportable' => true,
                );
                $ormMetadata[$entityName]['fields']['followersNames'] = array(
                    'type' => 'jsonObject',
                    'notStorable' => true,
                    'notExportable' => true,
                );
            }
        } //END: add a field 'isFollowed' for stream => true

        return $ormMetadata;
    }
protected function correctFields ( $ entityName , array $ ormMetadata ) { $ entityDefs = $ this -> getEntityDefs ( ) ; $ entityMetadata = $ ormMetadata [ $ entityName ] ; //load custom field definitions and customCodes foreach ( $ entityMetadata [ 'fields' ] as $ fieldName => $ fieldParams ) { if ( empty ( $ fieldParams [ 'type' ] ) ) continue ; $ fieldType = ucfirst ( $ fieldParams [ 'type' ] ) ; $ className = '\Espo\Custom\Core\Utils\Database\Orm\Fields\\' . $ fieldType ; if ( ! class_exists ( $ className ) ) { $ className = '\Espo\Core\Utils\Database\Orm\Fields\\' . $ fieldType ; } if ( class_exists ( $ className ) && method_exists ( $ className , 'load' ) ) { $ helperClass = new $ className ( $ this -> metadata , $ ormMetadata , $ entityDefs ) ; $ fieldResult = $ helperClass -> process ( $ fieldName , $ entityName ) ; if ( isset ( $ fieldResult [ 'unset' ] ) ) { $ ormMetadata = Util :: unsetInArray ( $ ormMetadata , $ fieldResult [ 'unset' ] ) ; unset ( $ fieldResult [ 'unset' ] ) ; } $ ormMetadata = Util :: merge ( $ ormMetadata , $ fieldResult ) ; } $ defaultAttributes = $ this -> metadata -> get ( [ 'entityDefs' , $ entityName , 'fields' , $ fieldName , 'defaultAttributes' ] ) ; if ( $ defaultAttributes && array_key_exists ( $ fieldName , $ defaultAttributes ) ) { $ defaultMetadataPart = array ( $ entityName => array ( 'fields' => array ( $ fieldName => array ( 'default' => $ defaultAttributes [ $ fieldName ] ) ) ) ) ; $ ormMetadata = Util :: merge ( $ ormMetadata , $ defaultMetadataPart ) ; } } //todo move to separate file //add a field 'isFollowed' for scopes with 'stream => true' $ scopeDefs = $ this -> getMetadata ( ) -> get ( 'scopes.' . $ entityName ) ; if ( isset ( $ scopeDefs [ 'stream' ] ) && $ scopeDefs [ 'stream' ] ) { if ( ! isset ( $ entityMetadata [ 'fields' ] [ 'isFollowed' ] ) ) { $ ormMetadata [ $ entityName ] [ 'fields' ] [ 'isFollowed' ] = array ( 'type' => 'varchar' , 'notStorable' => true , 'notExportable' => true , ) ; $ ormMetadata [ $ entityName ] [ 'fields' ] [ 'followersIds' ] = array ( 'type' => 'jsonArray' , 'notStorable' => true , 'notExportable' => true , ) ; $ ormMetadata [ $ entityName ] [ 'fields' ] [ 'followersNames' ] = array ( 'type' => 'jsonObject' , 'notStorable' => true , 'notExportable' => true , ) ; } } //END: add a field 'isFollowed' for stream => true return $ ormMetadata ; }
Correct fields defenitions based on \Espo\Custom\Core\Utils\Database\Orm\Fields

@param  array  $ormMetadata

@return array
Correct fields defenitions based on \ Espo \ Custom \ Core \ Utils \ Database \ Orm \ Fields