[~TASK] Extbase: Improved exception messages in getPlainValue().
authorJochen Rau <j.rau@web.de>
Tue, 25 May 2010 15:52:12 +0000 (15:52 +0000)
committerJochen Rau <j.rau@web.de>
Tue, 25 May 2010 15:52:12 +0000 (15:52 +0000)
typo3/sysext/extbase/Classes/Persistence/Storage/Typo3DbBackend.php

index f92bd55..e11da33 100644 (file)
@@ -566,10 +566,17 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
         * @return mixed
         */
        protected function getPlainValue($input) {
+               if (is_array($input)) {
+                       throw new Tx_Extbase_Persistence_Exception_UnexpectedTypeException('An array could not be converted to a plain value.', 1274799932);
+               }
                if ($input instanceof DateTime) {
                        return $input->format('U');
-               } elseif ($input instanceof Tx_Extbase_DomainObject_DomainObjectInterface) {
-                       return $input->getUid();
+               } elseif (is_object($input)) {
+                       if ($input instanceof Tx_Extbase_DomainObject_DomainObjectInterface) {
+                               return $input->getUid();
+                       } else {
+                               throw new Tx_Extbase_Persistence_Exception_UnexpectedTypeException('An object of class "' . get_class($input) . '" could not be converted to a plain value.', 1274799934);
+                       }
                } elseif (is_bool($input)) {
                        return $input === TRUE ? 1 : 0;
                } else {