Beispiel #1
0
 /**
  * Inserts mm-relation into a relation table
  *
  * @param Tx_Extbase_DomainObject_DomainObjectInterface $object The related object
  * @param Tx_Extbase_DomainObject_DomainObjectInterface $parentObject The parent object
  * @param string $propertyName The name of the parent object's property where the related objects are stored in
  * @return void
  */
 protected function insertRelationInRelationtable(Tx_Extbase_DomainObject_DomainObjectInterface $object, Tx_Extbase_DomainObject_DomainObjectInterface $parentObject, $propertyName, $sortingPosition = NULL)
 {
     $dataMap = $this->dataMapper->getDataMap(get_class($parentObject));
     $columnMap = $dataMap->getColumnMap($propertyName);
     $row = array($columnMap->getParentKeyFieldName() => (int) $parentObject->getUid(), $columnMap->getChildKeyFieldName() => (int) $object->getUid(), $columnMap->getChildSortByFieldName() => !is_null($sortingPosition) ? (int) $sortingPosition : 0);
     $relationTableName = $columnMap->getRelationTableName();
     // FIXME Reenable support for tablenames
     // $childTableName = $columnMap->getChildTableName();
     // if (isset($childTableName)) {
     // 	$row['tablenames'] = $childTableName;
     // }
     if ($columnMap->getRelationTablePageIdColumnName() !== NULL) {
         $row[$columnMap->getRelationTablePageIdColumnName()] = $this->determineStoragePageIdForNewRecord();
     }
     $relationTableInsertFields = $columnMap->getRelationTableInsertFields();
     if (count($relationTableInsertFields)) {
         foreach ($relationTableInsertFields as $insertField => $insertValue) {
             $row[$insertField] = $insertValue;
         }
     }
     $res = $this->storageBackend->addRow($relationTableName, $row, TRUE);
     return $res;
 }