protected function _getRelationColumnName($modelId, $iterator) { $postfix = $this->_getModelPostFix($modelId, $iterator); $column = Garp_Spawn_Relation_Set::getRelationColumn($modelId, $postfix); return $column; }
protected function _renderContentMigrationSql() { $target = $this->getTarget(); $i18nTableName = strtolower($target->name . Garp_Spawn_Config_Model_I18n::I18N_MODEL_ID_POSTFIX); $model = $this->getModel(); $relationColumnName = Garp_Spawn_Relation_Set::getRelationColumn($model->id); $language = $this->_getDefaultLanguage(); $fieldNames = $this->_getMultilingualFieldNames(); $existingColumns = $this->getOverlappingColumnsFromBase($fieldNames); if (!count($existingColumns)) { return ''; } $fieldNamesString = implode(',', $existingColumns); if (!$this->_tableHasRecords($i18nTableName)) { $statement = "INSERT IGNORE INTO `{$i18nTableName}` ({$relationColumnName}, lang, {$fieldNamesString}) " . "SELECT id, '{$language}', {$fieldNamesString} " . "FROM `{$target->name}`"; } else { $sqlSetStatements = implode(',', $this->_getSqlSetStatementsForUpdate($target->name, $i18nTableName, $existingColumns)); $statement = "UPDATE `{$i18nTableName}` " . "INNER JOIN `{$target->name}` ON `{$i18nTableName}`.`{$relationColumnName}` = " . "`{$target->name}`.`id` " . "SET {$sqlSetStatements} WHERE " . "`{$i18nTableName}`.`{$relationColumnName}` = `{$target->name}`.`id` AND " . "`lang` = '{$language}'"; } return $statement; }
/** * @return String The name of the column that refers to the translatable parent model */ protected function _getRelationColumnToParent() { $parentModelId = $this->getParentId(); $columnName = Garp_Spawn_Relation_Set::getRelationColumn($parentModelId); return $columnName; }
/** * Registers this relation as a Field in the Model. * * @return void */ protected function _addRelationFieldInLocalModel() { if (!$this->isSingular()) { return; } $column = Garp_Spawn_Relation_Set::getRelationColumn($this->name); $fieldParams = array('model' => $this->model, 'type' => 'numeric', 'editable' => true, 'visible' => true, 'primary' => $this->primary, 'required' => $this->required, 'relationAlias' => $this->name, 'relationType' => $this->type); if ($this->multilingual && $this->_localModel->isMultilingual()) { // The relation is added to the i18n model by Garp_Spawn_Config_Model_I18n return; } $this->_localModel->fields->add('relation', $column, $fieldParams); }