library/Garp/Content/Export/Abstract.php
protected function _bindModels(Garp_Model_Db $model) {
        // Add HABTM related records
        $relations = $model->getConfiguration('relations');
        foreach ($relations as $key => $config) {
            if ($config['type'] !== 'hasAndBelongsToMany' && $config['type'] !== 'hasMany') {
                continue;
            }
            $otherModelName = 'Model_' . $config['model'];
            $otherModel = new $otherModelName();
            $multilingual = false;
            $modelFactory = new Garp_I18n_ModelFactory();

            if ($otherModel->getObserver('Translatable')) {
                $otherModel = $modelFactory->getModel($otherModel);
                $multilingual = true;
            }

            $otherModelAlias = $otherModel->getName();
            $bindingModel = null;
            if ($config['type'] === 'hasAndBelongsToMany') {
                $bindingModelName = 'Model_' . $config['bindingModel'];
                $bindingModel = new $bindingModelName;
                if ($multilingual) {
                    $refmapLocaliser = new Garp_Model_ReferenceMapLocalizer($bindingModel);
                    $refmapLocaliser->populate($otherModelName);
                }
                $otherModelAlias = 'm';
            }

            $labelFields = $otherModel->getListFields();
            $prefixedLabelFields = array();
            foreach ($labelFields as $labelField) {
                $prefixedLabelFields[] = "$otherModelAlias.$labelField";
            }
            $labelFields = 'CONCAT_WS(", ", ' . implode(', ', $prefixedLabelFields) . ')';

            // If the Translatable behavior would be effective,
            // the output would be in a localized array, which is overkill for this
            // purpose.
            $otherModel->unregisterObserver('Translatable');

            $options = array(
                'bindingModel' => $bindingModel,
                'modelClass' => $otherModel,
                'conditions' => $otherModel->select()
                    ->setIntegrityCheck(false)
                    ->from(
                        array($otherModelAlias => $otherModel->getName()),
                        array($config['label'] => $labelFields)
                    )
                    ->order("$otherModelAlias.id")
            );
            $model->bindModel($config['label'], $options);
        }
    }
protected function _bindModels(Garp_Model_Db $model) {
        // Add HABTM related records
        $relations = $model->getConfiguration('relations');
        foreach ($relations as $key => $config) {
            if ($config['type'] !== 'hasAndBelongsToMany' && $config['type'] !== 'hasMany') {
                continue;
            }
            $otherModelName = 'Model_' . $config['model'];
            $otherModel = new $otherModelName();
            $multilingual = false;
            $modelFactory = new Garp_I18n_ModelFactory();

            if ($otherModel->getObserver('Translatable')) {
                $otherModel = $modelFactory->getModel($otherModel);
                $multilingual = true;
            }

            $otherModelAlias = $otherModel->getName();
            $bindingModel = null;
            if ($config['type'] === 'hasAndBelongsToMany') {
                $bindingModelName = 'Model_' . $config['bindingModel'];
                $bindingModel = new $bindingModelName;
                if ($multilingual) {
                    $refmapLocaliser = new Garp_Model_ReferenceMapLocalizer($bindingModel);
                    $refmapLocaliser->populate($otherModelName);
                }
                $otherModelAlias = 'm';
            }

            $labelFields = $otherModel->getListFields();
            $prefixedLabelFields = array();
            foreach ($labelFields as $labelField) {
                $prefixedLabelFields[] = "$otherModelAlias.$labelField";
            }
            $labelFields = 'CONCAT_WS(", ", ' . implode(', ', $prefixedLabelFields) . ')';

            // If the Translatable behavior would be effective,
            // the output would be in a localized array, which is overkill for this
            // purpose.
            $otherModel->unregisterObserver('Translatable');

            $options = array(
                'bindingModel' => $bindingModel,
                'modelClass' => $otherModel,
                'conditions' => $otherModel->select()
                    ->setIntegrityCheck(false)
                    ->from(
                        array($otherModelAlias => $otherModel->getName()),
                        array($config['label'] => $labelFields)
                    )
                    ->order("$otherModelAlias.id")
            );
            $model->bindModel($config['label'], $options);
        }
    }
protected function _bindModels ( Garp_Model_Db $ model ) { // Add HABTM related records $ relations = $ model -> getConfiguration ( 'relations' ) ; foreach ( $ relations as $ key => $ config ) { if ( $ config [ 'type' ] !== 'hasAndBelongsToMany' && $ config [ 'type' ] !== 'hasMany' ) { continue ; } $ otherModelName = 'Model_' . $ config [ 'model' ] ; $ otherModel = new $ otherModelName ( ) ; $ multilingual = false ; $ modelFactory = new Garp_I18n_ModelFactory ( ) ; if ( $ otherModel -> getObserver ( 'Translatable' ) ) { $ otherModel = $ modelFactory -> getModel ( $ otherModel ) ; $ multilingual = true ; } $ otherModelAlias = $ otherModel -> getName ( ) ; $ bindingModel = null ; if ( $ config [ 'type' ] === 'hasAndBelongsToMany' ) { $ bindingModelName = 'Model_' . $ config [ 'bindingModel' ] ; $ bindingModel = new $ bindingModelName ; if ( $ multilingual ) { $ refmapLocaliser = new Garp_Model_ReferenceMapLocalizer ( $ bindingModel ) ; $ refmapLocaliser -> populate ( $ otherModelName ) ; } $ otherModelAlias = 'm' ; } $ labelFields = $ otherModel -> getListFields ( ) ; $ prefixedLabelFields = array ( ) ; foreach ( $ labelFields as $ labelField ) { $ prefixedLabelFields [ ] = "$otherModelAlias.$labelField" ; } $ labelFields = 'CONCAT_WS(", ", ' . implode ( ', ' , $ prefixedLabelFields ) . ')' ; // If the Translatable behavior would be effective, // the output would be in a localized array, which is overkill for this // purpose. $ otherModel -> unregisterObserver ( 'Translatable' ) ; $ options = array ( 'bindingModel' => $ bindingModel , 'modelClass' => $ otherModel , 'conditions' => $ otherModel -> select ( ) -> setIntegrityCheck ( false ) -> from ( array ( $ otherModelAlias => $ otherModel -> getName ( ) ) , array ( $ config [ 'label' ] => $ labelFields ) ) -> order ( "$otherModelAlias.id" ) ) ; $ model -> bindModel ( $ config [ 'label' ] , $ options ) ; } }
Bind all HABTM related models so they, too, get exported

@param Garp_Model_Db $model
@return void
Bind all HABTM related models so they too get exported