e92ccc5a41885469d6ee0b2d5e4b9db406fb65f5
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / Hook / TCEMainValueObjectUpdater.php
1 <?php
2 /* WE NEED TO DO IT STRTOLOWER */
3 class tx_ExtBase_Persistence_Hook_TCEMainValueObjectUpdater {
4 public function processDatamap_preProcessFieldArray(&$incomingFieldArray, $table, &$id, $tcemain) {
5 global $TCA;
6 if (isset($TCA[$table]['ctrl']['objectType']) && $TCA[$table]['ctrl']['objectType'] === 'ValueObject') {
7 $uid = $this->findUid($incomingFieldArray, $table);
8 if ($uid !== NULL) {
9 //var_dump($incomingFieldArray, $table, $id, $uid);
10 $id = (int)$uid;
11 $incomingFieldArray['uid'] = $uid;
12 } else {
13 // $id = 'NEW' . $uid;
14 }
15
16 }
17 }
18
19 protected function findUid($incomingFieldArray, $table) {
20 $whereClauseArray = array();
21 unset($incomingFieldArray['uid']);
22 foreach ($incomingFieldArray as $key => $value) {
23 $whereClauseArray[] = $key . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($value, 'dummy');
24 }
25 $resultArray = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', $table, implode(' AND ', $whereClauseArray));
26
27 if (count($resultArray)) {
28 return $resultArray[0];
29 }
30 return NULL;
31 }
32 }
33 ?>