private function getPreparedModelData(\Tx_Oelib_Model $model)
    {
        if (!$model->hasUid()) {
            $model->setCreationDate();
        }
        $model->setTimestamp();

        $data = $model->getData();

        foreach ($this->relations as $key => $relation) {
            if ($this->isOneToManyRelationConfigured($key)) {
                $functionName = 'count';
            } elseif ($this->isManyToOneRelationConfigured($key)) {
                $functionName = 'getUid';

                if ($data[$key] instanceof \Tx_Oelib_Model) {
                    $this->saveManyToOneRelatedModels(
                        $data[$key],
                        \Tx_Oelib_MapperRegistry::get($relation)
                    );
                }
            } else {
                if ($this->isManyToManyRelationConfigured($key)) {
                    $functionName = 'count';
                } else {
                    $functionName = 'getUids';
                }

                if ($data[$key] instanceof \Tx_Oelib_List) {
                    $this->saveManyToManyAndCommaSeparatedRelatedModels(
                        $data[$key],
                        \Tx_Oelib_MapperRegistry::get($relation)
                    );
                }
            }

            $data[$key] = (isset($data[$key]) && is_object($data[$key]))
                ? $data[$key]->$functionName() : 0;
        }

        return $data;
    }
private function getPreparedModelData(\Tx_Oelib_Model $model)
    {
        if (!$model->hasUid()) {
            $model->setCreationDate();
        }
        $model->setTimestamp();

        $data = $model->getData();

        foreach ($this->relations as $key => $relation) {
            if ($this->isOneToManyRelationConfigured($key)) {
                $functionName = 'count';
            } elseif ($this->isManyToOneRelationConfigured($key)) {
                $functionName = 'getUid';

                if ($data[$key] instanceof \Tx_Oelib_Model) {
                    $this->saveManyToOneRelatedModels(
                        $data[$key],
                        \Tx_Oelib_MapperRegistry::get($relation)
                    );
                }
            } else {
                if ($this->isManyToManyRelationConfigured($key)) {
                    $functionName = 'count';
                } else {
                    $functionName = 'getUids';
                }

                if ($data[$key] instanceof \Tx_Oelib_List) {
                    $this->saveManyToManyAndCommaSeparatedRelatedModels(
                        $data[$key],
                        \Tx_Oelib_MapperRegistry::get($relation)
                    );
                }
            }

            $data[$key] = (isset($data[$key]) && is_object($data[$key]))
                ? $data[$key]->$functionName() : 0;
        }

        return $data;
    }
private function getPreparedModelData ( \ Tx_Oelib_Model $ model ) { if ( ! $ model -> hasUid ( ) ) { $ model -> setCreationDate ( ) ; } $ model -> setTimestamp ( ) ; $ data = $ model -> getData ( ) ; foreach ( $ this -> relations as $ key => $ relation ) { if ( $ this -> isOneToManyRelationConfigured ( $ key ) ) { $ functionName = 'count' ; } elseif ( $ this -> isManyToOneRelationConfigured ( $ key ) ) { $ functionName = 'getUid' ; if ( $ data [ $ key ] instanceof \ Tx_Oelib_Model ) { $ this -> saveManyToOneRelatedModels ( $ data [ $ key ] , \ Tx_Oelib_MapperRegistry :: get ( $ relation ) ) ; } } else { if ( $ this -> isManyToManyRelationConfigured ( $ key ) ) { $ functionName = 'count' ; } else { $ functionName = 'getUids' ; } if ( $ data [ $ key ] instanceof \ Tx_Oelib_List ) { $ this -> saveManyToManyAndCommaSeparatedRelatedModels ( $ data [ $ key ] , \ Tx_Oelib_MapperRegistry :: get ( $ relation ) ) ; } } $ data [ $ key ] = ( isset ( $ data [ $ key ] ) && is_object ( $ data [ $ key ] ) ) ? $ data [ $ key ] -> $ functionName ( ) : 0 ; } return $ data ; }
Prepares the model's data for the database. Changes the relations into a
database-applicable format. Sets the timestamp and sets the "crdate" for
new models.

@param \Tx_Oelib_Model $model the model to write to the database

@return array the model's data prepared for the database, will not be empty
Prepares the model s data for the database . Changes the relations into a database - applicable format . Sets the timestamp and sets the crdate for new models .