* refactoring of DomainObject and Utility classes
authorJochen Rau <j.rau@web.de>
Fri, 30 Jan 2009 08:15:55 +0000 (08:15 +0000)
committerJochen Rau <j.rau@web.de>
Fri, 30 Jan 2009 08:15:55 +0000 (08:15 +0000)
typo3/sysext/extbase/Classes/DomainObject/TX_EXTMVC_DomainObject_AbstractDomainObject.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/DomainObject/TX_EXTMVC_DomainObject_Entity.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/DomainObject/TX_EXTMVC_DomainObject_ValueObject.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Persistence/TX_EXTMVC_Persistence_Repository.php
typo3/sysext/extbase/Classes/Persistence/TX_EXTMVC_Persistence_Session.php
typo3/sysext/extbase/Classes/TX_EXTMVC_AbstractDomainObject.php [deleted file]
typo3/sysext/extbase/Classes/TX_EXTMVC_Entity.php [deleted file]
typo3/sysext/extbase/Classes/TX_EXTMVC_ExtensionUtility.php [deleted file]
typo3/sysext/extbase/Classes/TX_EXTMVC_ValueObject.php [deleted file]
typo3/sysext/extbase/Classes/Utility/TX_EXTMVC_Utility_Strings.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/View/TX_EXTMVC_View_TemplateView.php

diff --git a/typo3/sysext/extbase/Classes/DomainObject/TX_EXTMVC_DomainObject_AbstractDomainObject.php b/typo3/sysext/extbase/Classes/DomainObject/TX_EXTMVC_DomainObject_AbstractDomainObject.php
new file mode 100644 (file)
index 0000000..23e1791
--- /dev/null
@@ -0,0 +1,121 @@
+<?php
+declare(ENCODING = 'utf-8');
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * A generic Domain Object
+ *
+ * @version $Id:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+abstract class TX_EXTMVC_DomainObject_AbstractDomainObject {
+       
+       /**
+        * An array of properties filled with database values of columns configured in $TCA.
+        *
+        * @var array
+        */
+       private $cleanProperties = NULL;
+       
+       /**
+        * An array properties configured as 1:n relations in $TCA.
+        *
+        * @var array
+        */
+       private $oneToManyProperties = NULL;
+       
+       /**
+        * An array properties configured as m:n relations in $TCA.
+        *
+        * @var array
+        */
+       private $manyToManyProperties = NULL;
+       
+       private function initCleanProperties() {
+                       $possibleTableName = strtolower(get_class($this));
+                       t3lib_div::loadTCA($possibleTableName);
+                       $tca = $GLOBALS['TCA'][$possibleTableName]['columns'];
+                       foreach ($tca as $columnName => $columnConfiguration) {
+                               $this->cleanProperties[$columnName] = NULL;
+                               if (array_key_exists('foreign_table', $columnConfiguration['config'])) {
+                                       // TODO take IRRE into account
+                                       if (array_key_exists('MM', $columnConfiguration['config'])) {
+                                               $this->manyToManyProperties[] = $columnName;
+                                       } else {
+                                               $this->cleanProperties[] = $columnName;
+                                       }
+                               }
+                               
+                       }
+                       $this->cleanProperties['uid'] = NULL;
+       }
+               
+       public function _reconstituteProperty($propertyName, $value) {
+               $possibleAddMethodName = 'add' . ucfirst($propertyName);
+               if (method_exists($this, $possibleAddMethodName)) {
+                       $this->$possibleAddMethodName($value);
+               } else {
+                       if (property_exists($this, $propertyName)) {
+                               $this->$propertyName = $value;
+                       } else {
+                               // throw new TX_EXTMVC_Persistence_Exception_UnknownProperty('The property "' . $propertyName . '" does not exist in this object.', 1233270476);
+                       }
+               }
+       }
+       
+       /**
+        * Register an object's clean state, e.g. after it has been reconstituted
+        * from the database
+        *
+        * @return void
+        * @author Jochen Rau <jochen.rau@typoplanet.de>
+        */
+       public function _memorizeCleanState() {
+               $this->initCleanProperties();
+               foreach ($this->cleanProperties as $propertyName => $propertyValue) {
+                       $cleanProperties[$propertyName] = $this->$propertyName;
+               }
+               $this->cleanProperties = $cleanProperties;
+       }
+       
+       /**
+        * returns TRUE if the properties configured in $TCA were modified after reconstitution
+        *
+        * @return boolean
+        * @author Jochen Rau <jochen.rau@typoplanet.de>
+        */
+       public function _isDirty() {
+               $isDirty = FALSE;
+               $cleanProperties = is_array($this->cleanProperties) ? $this->cleanProperties : array();
+               if ($this->uid !== NULL && $this->uid != $cleanProperties['uid']) {
+                       throw new TX_EXTMVC_Persistence_Exception_TooDirty('The uid "' . $this->uid . '" has been modified, that is simply too much.', 1222871239);
+               }
+               foreach ($cleanProperties as $propertyName => $propertyValue) {
+                       if ($cleanProperties[$propertyName] !== $this->$propertyName) {
+                               $isDirty = TRUE;
+                       }
+               }
+               return $isDirty;
+       }
+       
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/DomainObject/TX_EXTMVC_DomainObject_Entity.php b/typo3/sysext/extbase/Classes/DomainObject/TX_EXTMVC_DomainObject_Entity.php
new file mode 100644 (file)
index 0000000..0eabe81
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+declare(ENCODING = 'utf-8');
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/DomainObject/TX_EXTMVC_DomainObject_AbstractDomainObject.php');
+
+/**
+ * A generic Entity Object
+ *
+ * @version $Id:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class TX_EXTMVC_DomainObject_Entity extends TX_EXTMVC_DomainObject_AbstractDomainObject {
+
+       /**
+        * @var string The uid
+        */
+       protected $uid;
+
+       /**
+        * Getter for uid
+        *
+        * @return string
+        * @author Jochen Rau <jochen.rau@typoplanet.de>
+        */
+       public function getUid() {
+               return $this->uid;
+       }
+       
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/DomainObject/TX_EXTMVC_DomainObject_ValueObject.php b/typo3/sysext/extbase/Classes/DomainObject/TX_EXTMVC_DomainObject_ValueObject.php
new file mode 100644 (file)
index 0000000..7b4749c
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+declare(ENCODING = 'utf-8');
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/DomainObject/TX_EXTMVC_DomainObject_AbstractDomainObject.php');
+
+/**
+ * A generic Value Object
+ *
+ * @version $Id:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+abstract class TX_EXTMVC_DomainObject_ValueObject extends TX_EXTMVC_DomainObject_AbstractDomainObject {
+
+}
+?>
\ No newline at end of file
index 6c6b518..ddde30a 100644 (file)
@@ -22,7 +22,7 @@ declare(ENCODING = 'utf-8');
  *                                                                        */
 
 require_once(PATH_t3lib . 'interfaces/interface.t3lib_singleton.php');
-require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/TX_EXTMVC_ExtensionUtility.php');
+require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Utility/TX_EXTMVC_Utility_Strings.php');
 require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Persistence/TX_EXTMVC_Persistence_ObjectStorage.php');
 require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Persistence/TX_EXTMVC_Persistence_RepositoryInterface.php');
 
@@ -176,7 +176,7 @@ class TX_EXTMVC_Persistence_Repository implements TX_EXTMVC_Persistence_Reposito
         */
        public function __call($methodName, $arguments) {
                if (substr($methodName, 0, 6) === 'findBy') {
-                       $propertyName = TX_EXTMVC_ExtensionUtility::lowercaseFirst(substr($methodName,6));
+                       $propertyName = TX_EXTMVC_Utility_Strings::lowercaseFirst(substr($methodName,6));
                        if (in_array($propertyName, $this->allowedFindByProperties)) {
                                return $this->findByProperty($propertyName, $arguments);
                        }
index d7a849c..f18c4d1 100644 (file)
@@ -22,7 +22,7 @@ declare(ENCODING = 'utf-8');
  *                                                                        */
 
 require_once(PATH_t3lib . 'interfaces/interface.t3lib_singleton.php');
-require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/TX_EXTMVC_AbstractDomainObject.php');
+require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/DomainObject/TX_EXTMVC_DomainObject_AbstractDomainObject.php');
 require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Persistence/TX_EXTMVC_Persistence_ObjectStorage.php');
 
 /**
@@ -76,11 +76,11 @@ class TX_EXTMVC_Persistence_Session implements t3lib_singleton {
        /**
         * Registers an added object
         *
-        * @param TX_EXTMVC_AbstractDomainObject $object
+        * @param TX_EXTMVC_DomainObject_AbstractDomainObject $object
         * @return void
         * @author Jochen Rau <jochen.rau@typoplanet.de>
         */
-       public function registerAddedObject(TX_EXTMVC_AbstractDomainObject $object) {
+       public function registerAddedObject(TX_EXTMVC_DomainObject_AbstractDomainObject $object) {
                $this->removedObjects->detach($object);
                $this->addedObjects->attach($object);
        }
@@ -104,11 +104,11 @@ class TX_EXTMVC_Persistence_Session implements t3lib_singleton {
        /**
         * Registers a removed object
         *
-        * @param TX_EXTMVC_AbstractDomainObject $object
+        * @param TX_EXTMVC_DomainObject_AbstractDomainObject $object
         * @return void
         * @author Jochen Rau <jochen.rau@typoplanet.de>
         */
-       public function registerRemovedObject(TX_EXTMVC_AbstractDomainObject $object) {
+       public function registerRemovedObject(TX_EXTMVC_DomainObject_AbstractDomainObject $object) {
                if ($this->addedObjects->contains($object)) {
                        $this->addedObjects->detach($object);
                } else {
@@ -136,10 +136,10 @@ class TX_EXTMVC_Persistence_Session implements t3lib_singleton {
         * Registers a reconstituted object
         *
         * @param object $object
-        * @return TX_EXTMVC_AbstractDomainObject
+        * @return TX_EXTMVC_DomainObject_AbstractDomainObject
         * @author Jochen Rau <jochen.rau@typoplanet.de>
         */
-       public function registerReconstitutedObject(TX_EXTMVC_AbstractDomainObject $object) {
+       public function registerReconstitutedObject(TX_EXTMVC_DomainObject_AbstractDomainObject $object) {
                $this->reconstitutedObjects->attach($object);
                $object->_memorizeCleanState();
        }
diff --git a/typo3/sysext/extbase/Classes/TX_EXTMVC_AbstractDomainObject.php b/typo3/sysext/extbase/Classes/TX_EXTMVC_AbstractDomainObject.php
deleted file mode 100644 (file)
index 4804710..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-<?php
-declare(ENCODING = 'utf-8');
-
-/*                                                                        *
- * This script belongs to the FLOW3 framework.                            *
- *                                                                        *
- * It is free software; you can redistribute it and/or modify it under    *
- * the terms of the GNU Lesser General Public License as published by the *
- * Free Software Foundation, either version 3 of the License, or (at your *
- * option) any later version.                                             *
- *                                                                        *
- * This script is distributed in the hope that it will be useful, but     *
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
- * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
- * General Public License for more details.                               *
- *                                                                        *
- * You should have received a copy of the GNU Lesser General Public       *
- * License along with the script.                                         *
- * If not, see http://www.gnu.org/licenses/lgpl.html                      *
- *                                                                        *
- * The TYPO3 project - inspiring people to share!                         *
- *                                                                        */
-
-/**
- * A generic Domain Object
- *
- * @version $Id:$
- * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
- */
-abstract class TX_EXTMVC_AbstractDomainObject {
-       
-       /**
-        * An array of properties filled with database values of columns configured in $TCA.
-        *
-        * @var array
-        */
-       private $cleanProperties = NULL;
-       
-       /**
-        * An array properties configured as 1:n relations in $TCA.
-        *
-        * @var array
-        */
-       private $oneToManyProperties = NULL;
-       
-       /**
-        * An array properties configured as m:n relations in $TCA.
-        *
-        * @var array
-        */
-       private $manyToManyProperties = NULL;
-       
-       private function initCleanProperties() {
-                       $possibleTableName = strtolower(get_class($this));
-                       t3lib_div::loadTCA($possibleTableName);
-                       $tca = $GLOBALS['TCA'][$possibleTableName]['columns'];
-                       foreach ($tca as $columnName => $columnConfiguration) {
-                               $this->cleanProperties[$columnName] = NULL;
-                               if (array_key_exists('foreign_table', $columnConfiguration['config'])) {
-                                       // TODO take IRRE into account
-                                       if (array_key_exists('MM', $columnConfiguration['config'])) {
-                                               $this->manyToManyProperties[] = $columnName;
-                                       } else {
-                                               $this->cleanProperties[] = $columnName;
-                                       }
-                               }
-                               
-                       }
-                       $this->cleanProperties['uid'] = NULL;
-       }
-               
-       public function _reconstituteProperty($propertyName, $value) {
-               $possibleAddMethodName = 'add' . ucfirst($propertyName);
-               if (method_exists($this, $possibleAddMethodName)) {
-                       $this->$possibleAddMethodName($value);
-               } else {
-                       if (property_exists($this, $propertyName)) {
-                               $this->$propertyName = $value;
-                       } else {
-                               // throw new TX_EXTMVC_Persistence_Exception_UnknownProperty('The property "' . $propertyName . '" does not exist in this object.', 1233270476);
-                       }
-               }
-       }
-       
-       /**
-        * Register an object's clean state, e.g. after it has been reconstituted
-        * from the database
-        *
-        * @return void
-        * @author Jochen Rau <jochen.rau@typoplanet.de>
-        */
-       public function _memorizeCleanState() {
-               $this->initCleanProperties();
-               foreach ($this->cleanProperties as $propertyName => $propertyValue) {
-                       $cleanProperties[$propertyName] = $this->$propertyName;
-               }
-               $this->cleanProperties = $cleanProperties;
-       }
-       
-       /**
-        * returns TRUE if the properties configured in $TCA were modified after reconstitution
-        *
-        * @return boolean
-        * @author Jochen Rau <jochen.rau@typoplanet.de>
-        */
-       public function _isDirty() {
-               $isDirty = FALSE;
-               $cleanProperties = is_array($this->cleanProperties) ? $this->cleanProperties : array();
-               if ($this->uid !== NULL && $this->uid != $cleanProperties['uid']) {
-                       throw new TX_EXTMVC_Persistence_Exception_TooDirty('The uid "' . $this->uid . '" has been modified, that is simply too much.', 1222871239);
-               }
-               foreach ($cleanProperties as $propertyName => $propertyValue) {
-                       if ($cleanProperties[$propertyName] !== $this->$propertyName) {
-                               $isDirty = TRUE;
-                       }
-               }
-               return $isDirty;
-       }
-       
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/TX_EXTMVC_Entity.php b/typo3/sysext/extbase/Classes/TX_EXTMVC_Entity.php
deleted file mode 100644 (file)
index 883ce7d..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-<?php
-declare(ENCODING = 'utf-8');
-
-/*                                                                        *
- * This script belongs to the FLOW3 framework.                            *
- *                                                                        *
- * It is free software; you can redistribute it and/or modify it under    *
- * the terms of the GNU Lesser General Public License as published by the *
- * Free Software Foundation, either version 3 of the License, or (at your *
- * option) any later version.                                             *
- *                                                                        *
- * This script is distributed in the hope that it will be useful, but     *
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
- * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
- * General Public License for more details.                               *
- *                                                                        *
- * You should have received a copy of the GNU Lesser General Public       *
- * License along with the script.                                         *
- * If not, see http://www.gnu.org/licenses/lgpl.html                      *
- *                                                                        *
- * The TYPO3 project - inspiring people to share!                         *
- *                                                                        */
-
-require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/TX_EXTMVC_AbstractDomainObject.php');
-
-/**
- * A generic Entity Object
- *
- * @version $Id:$
- * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
- */
-class TX_EXTMVC_Entity extends TX_EXTMVC_AbstractDomainObject {
-
-       /**
-        * @var string The uid
-        */
-       protected $uid;
-
-       /**
-        * Getter for uid
-        *
-        * @return string
-        * @author Jochen Rau <jochen.rau@typoplanet.de>
-        */
-       public function getUid() {
-               return $this->uid;
-       }
-       
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/TX_EXTMVC_ExtensionUtility.php b/typo3/sysext/extbase/Classes/TX_EXTMVC_ExtensionUtility.php
deleted file mode 100644 (file)
index a8a2b7c..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-declare(ENCODING = 'utf-8');
-
-/*                                                                        *
- * This script belongs to the FLOW3 framework.                            *
- *                                                                        *
- * It is free software; you can redistribute it and/or modify it under    *
- * the terms of the GNU Lesser General Public License as published by the *
- * Free Software Foundation, either version 3 of the License, or (at your *
- * option) any later version.                                             *
- *                                                                        *
- * This script is distributed in the hope that it will be useful, but     *
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
- * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
- * General Public License for more details.                               *
- *                                                                        *
- * You should have received a copy of the GNU Lesser General Public       *
- * License along with the script.                                         *
- * If not, see http://www.gnu.org/licenses/lgpl.html                      *
- *                                                                        *
- * The TYPO3 project - inspiring people to share!                         *
- *                                                                        */
-
-/**
- * A collection of utilities for extensions
- *
- * @version $Id:$
- * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
- */
-abstract class TX_EXTMVC_ExtensionUtility {
-       
-       /**
-        * Returns a given string with underscores as UpperCamelCase (not UTF8 safe)
-        *
-        * @param string String to be converted to camel case
-        * @return string UpperCamelCasedWord
-        * @author Jochen Rau <jochen.rau@typoplanet.de>
-        */
-       public static function underscoredToUpperCamelCase($string) {
-               $upperCamelCase = (str_replace(' ', '', ucwords(preg_replace('![^A-Z^a-z^0-9]+!', ' ', strtolower($string)))));
-               return $upperCamelCase;
-       }
-       
-       /**
-        * Returns a given string with underscores as lowerCamelCase (not UTF8 safe)
-        *
-        * @param string String to be converted to camel case
-        * @return string lowerCamelCasedWord
-        * @author Jochen Rau <jochen.rau@typoplanet.de>
-        */
-       public static function underscoredToLowerCamelCase($string) {
-               $upperCamelCase = (str_replace(' ', '', ucwords(preg_replace('![^A-Z^a-z^0-9]+!', ' ', strtolower($string)))));
-               $lowerCamelCase = strtolower(substr($upperCamelCase,0,1) ) . substr($upperCamelCase,1);
-               return $lowerCamelCase;
-       }
-       
-       /**
-        * Returns a given CamelCasedString as an lowercase string with underscores (not UTF8 safe)
-        *
-        * @param string String to be converted to lowercase underscore
-        * @return string lowercase_and_underscored_string
-        * @author Jochen Rau <jochen.rau@typoplanet.de>
-        */
-       public static function camelCaseToLowerCaseUnderscored($string) {
-               return strtolower(preg_replace('/(?<=\w)([A-Z])/', '_\\1', $string));
-       }
-               
-       /**
-        * Sets the first char of a string to lowercase (not UTF8 safe)
-        *
-        * @param string $string 
-        * @return void
-        * @author Jochen Rau <jochen.rau@typoplanet.de>
-        */
-       public static function lowercaseFirst($string) {
-               return strtolower(substr($string,0,1) ) . substr($string,1);
-       }
-       
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/TX_EXTMVC_ValueObject.php b/typo3/sysext/extbase/Classes/TX_EXTMVC_ValueObject.php
deleted file mode 100644 (file)
index 524137f..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-declare(ENCODING = 'utf-8');
-
-/*                                                                        *
- * This script belongs to the FLOW3 framework.                            *
- *                                                                        *
- * It is free software; you can redistribute it and/or modify it under    *
- * the terms of the GNU Lesser General Public License as published by the *
- * Free Software Foundation, either version 3 of the License, or (at your *
- * option) any later version.                                             *
- *                                                                        *
- * This script is distributed in the hope that it will be useful, but     *
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
- * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
- * General Public License for more details.                               *
- *                                                                        *
- * You should have received a copy of the GNU Lesser General Public       *
- * License along with the script.                                         *
- * If not, see http://www.gnu.org/licenses/lgpl.html                      *
- *                                                                        *
- * The TYPO3 project - inspiring people to share!                         *
- *                                                                        */
-
-require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/TX_EXTMVC_AbstractDomainObject.php');
-
-/**
- * A generic Value Object
- *
- * @version $Id:$
- * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
- */
-abstract class TX_EXTMVC_ValueObject extends TX_EXTMVC_AbstractDomainObject {
-
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Utility/TX_EXTMVC_Utility_Strings.php b/typo3/sysext/extbase/Classes/Utility/TX_EXTMVC_Utility_Strings.php
new file mode 100644 (file)
index 0000000..2d09ec2
--- /dev/null
@@ -0,0 +1,99 @@
+<?php
+declare(ENCODING = 'utf-8');
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * A collection of utilities for extensions
+ *
+ * @version $Id:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+abstract class TX_EXTMVC_Utility_Strings {
+       
+       /**
+        * Returns a given string with underscores as UpperCamelCase (not UTF8 safe)
+        *
+        * @param string String to be converted to camel case
+        * @return string UpperCamelCasedWord
+        * @author Jochen Rau <jochen.rau@typoplanet.de>
+        */
+       public static function underscoredToUpperCamelCase($string) {
+               $upperCamelCase = (str_replace(' ', '', ucwords(preg_replace('![^A-Z^a-z^0-9]+!', ' ', strtolower($string)))));
+               return $upperCamelCase;
+       }
+       
+       /**
+        * Returns a given string with underscores as lowerCamelCase (not UTF8 safe)
+        *
+        * @param string String to be converted to camel case
+        * @return string lowerCamelCasedWord
+        * @author Jochen Rau <jochen.rau@typoplanet.de>
+        */
+       public static function underscoredToLowerCamelCase($string) {
+               $upperCamelCase = (str_replace(' ', '', ucwords(preg_replace('![^A-Z^a-z^0-9]+!', ' ', strtolower($string)))));
+               $lowerCamelCase = strtolower(substr($upperCamelCase,0,1) ) . substr($upperCamelCase,1);
+               return $lowerCamelCase;
+       }
+       
+       /**
+        * Returns a given CamelCasedString as an lowercase string with underscores (not UTF8 safe)
+        *
+        * @param string String to be converted to lowercase underscore
+        * @return string lowercase_and_underscored_string
+        * @author Jochen Rau <jochen.rau@typoplanet.de>
+        */
+       public static function camelCaseToLowerCaseUnderscored($string) {
+               return strtolower(preg_replace('/(?<=\w)([A-Z])/', '_\\1', $string));
+       }
+               
+       /**
+        * Sets the first char of a string to lowercase (not UTF8 safe)
+        *
+        * @param string $string 
+        * @return void
+        * @author Jochen Rau <jochen.rau@typoplanet.de>
+        */
+       public static function lowercaseFirst($string) {
+               return strtolower(substr($string,0,1) ) . substr($string,1);
+       }
+       
+       /**
+        * Returns the extension key. Automatically detects the extension key from the classname.
+        *
+        * @return string The extension key
+        */
+       public static function getExtensionKey() {
+               if(preg_match('/^TX_([^_]+)/', get_class($this), $matches)) {
+                       $possibleExtensionKey = $matches[1];
+                       if($possibleExtensionKey != 'lib') {
+                               $loadedExtensionKeys = t3lib_div::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList']);
+                               foreach($loadedExtensionKeys as $extensionKey) {
+                                       if($possibleExtensionKey == str_replace('_', '', $extensionKey)) {
+                                               return $extensionKey;
+                                       }
+                               }
+                       }
+               }
+       }
+       
+}
+?>
\ No newline at end of file
index e993d0c..79aa9b2 100644 (file)
@@ -22,7 +22,7 @@ declare(ENCODING = 'utf-8');
  *                                                                        */
 
 require_once(PATH_t3lib . 'class.t3lib_parsehtml.php');
-require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/TX_EXTMVC_ExtensionUtility.php');
+require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Utility/TX_EXTMVC_Utility_Strings.php');
 
 /**
  * A basic Template View
@@ -209,14 +209,14 @@ class TX_EXTMVC_View_TemplateView extends TX_EXTMVC_View_AbstractView {
                
        protected function getMarkerContent($markerName, $value) {
                $explodedMarkerName = explode('.', $markerName);
-               $possibleMethodName = 'get' . TX_EXTMVC_ExtensionUtility::underscoredToUpperCamelCase($explodedMarkerName[1]);
+               $possibleMethodName = 'get' . TX_EXTMVC_Utility_Strings::underscoredToUpperCamelCase($explodedMarkerName[1]);
                if ($value === NULL) {
                        if (!empty($this->contextVariables[strtolower($markerName)])) {
                                $result = $this->contextVariables[strtolower($markerName)];
                        }
-               } elseif ($value instanceof TX_EXTMVC_AbstractDomainObject) {
+               } elseif ($value instanceof TX_EXTMVC_DomainObject_AbstractDomainObject) {
                        $explodedMarkerName = explode('.', $markerName);
-                       $possibleMethodName = 'get' . TX_EXTMVC_ExtensionUtility::underscoredToUpperCamelCase($explodedMarkerName[1]);
+                       $possibleMethodName = 'get' . TX_EXTMVC_Utility_Strings::underscoredToUpperCamelCase($explodedMarkerName[1]);
                        if (method_exists($value, $possibleMethodName)) {
                                $result = $value->$possibleMethodName();
                        }
@@ -247,8 +247,8 @@ class TX_EXTMVC_View_TemplateView extends TX_EXTMVC_View_AbstractView {
                        if (!empty($this->contextVariables[strtolower($subpartName)])) {
                                $result = $this->contextVariables[strtolower($subpartName)];
                        }
-               } elseif ($value instanceof TX_EXTMVC_AbstractDomainObject) {
-                       $possibleMethodName = 'get' . TX_EXTMVC_ExtensionUtility::underscoredToUpperCamelCase($subpartName);
+               } elseif ($value instanceof TX_EXTMVC_DomainObject_AbstractDomainObject) {
+                       $possibleMethodName = 'get' . TX_EXTMVC_Utility_Strings::underscoredToUpperCamelCase($subpartName);
                        if (method_exists($value, $possibleMethodName)) {
                                $result = $value->$possibleMethodName();
                        }