Extbase - first attempt for hook
authorSebastian Kurfürst <sebastian@typo3.org>
Sat, 28 Mar 2009 22:12:29 +0000 (22:12 +0000)
committerSebastian Kurfürst <sebastian@typo3.org>
Sat, 28 Mar 2009 22:12:29 +0000 (22:12 +0000)
typo3/sysext/extbase/Classes/Persistence/Hook/TCEMainValueObjectUpdater.php [new file with mode: 0644]
typo3/sysext/extbase/Documentation/todo.txt
typo3/sysext/extbase/ext_localconf.php

diff --git a/typo3/sysext/extbase/Classes/Persistence/Hook/TCEMainValueObjectUpdater.php b/typo3/sysext/extbase/Classes/Persistence/Hook/TCEMainValueObjectUpdater.php
new file mode 100644 (file)
index 0000000..e92ccc5
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+/* WE NEED TO DO IT STRTOLOWER */
+class tx_ExtBase_Persistence_Hook_TCEMainValueObjectUpdater {
+       public function processDatamap_preProcessFieldArray(&$incomingFieldArray, $table, &$id, $tcemain) {
+               global $TCA;
+               if (isset($TCA[$table]['ctrl']['objectType']) && $TCA[$table]['ctrl']['objectType'] === 'ValueObject') {
+                       $uid = $this->findUid($incomingFieldArray, $table);
+                       if ($uid !== NULL) {
+                               //var_dump($incomingFieldArray, $table, $id, $uid);
+                               $id = (int)$uid;
+                               $incomingFieldArray['uid'] = $uid;
+                       } else {
+                               // $id = 'NEW' . $uid;
+                       }
+
+               }
+       }
+
+       protected function findUid($incomingFieldArray, $table) {
+               $whereClauseArray = array();
+               unset($incomingFieldArray['uid']);
+               foreach ($incomingFieldArray as $key => $value) {
+                       $whereClauseArray[] = $key . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($value, 'dummy');
+               }
+               $resultArray = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', $table, implode(' AND ', $whereClauseArray));
+
+               if (count($resultArray)) {
+                       return $resultArray[0];
+               }
+               return NULL;
+       }
+}
+?>
\ No newline at end of file
index 9259256..659f36f 100644 (file)
        • Caching -> Talk with Stucki
 
 
+* ValueObjects dürfen sich NIE MEHR verändern!!
+* ValueObjects -> RefCount - TCEMAIN HOOK?
+       * Alternative: Merge on insert??
+
 
 KICKSTARTER -> GSoC
 
index 0c8ccbe..f4162c5 100644 (file)
@@ -1,4 +1,5 @@
 <?php
 if (!defined ('TYPO3_MODE'))   die ('Access denied.');
 
+# $GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'EXT:extbase/Classes/Persistence/Hook/TCEMainValueObjectUpdater.php:tx_ExtBase_Persistence_Hook_TCEMainValueObjectUpdater';
 ?>
\ No newline at end of file