Autosets className in DBOEditor and AbstractDBOAction
authorMatthias Schmidt <gravatronics@live.com>
Sat, 31 Mar 2012 14:18:37 +0000 (16:18 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 31 Mar 2012 14:18:37 +0000 (16:18 +0200)
wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php
wcfsetup/install/files/lib/data/DatabaseObjectList.class.php

index 6a2bb9a27e6a80300a04ad175f2b68fe18b7db77..cbe53272bcde49a6abf109963abffee08a6eea1e 100644 (file)
@@ -88,6 +88,15 @@ abstract class AbstractDatabaseObjectAction implements IDatabaseObjectAction {
         * @param       array           $parameters
         */
        public function __construct(array $objects, $action, array $parameters = array()) {
+               // set class name
+               if (empty($this->className)) {
+                       $className = get_called_class();
+                       
+                       if (StringUtil::substring($className, -6) == 'Action') {
+                               $this->className = StringUtil::substring($className, 0, -6).'Editor';
+                       }
+               }
+               
                $indexName = call_user_func(array($this->className, 'getDatabaseTableIndexName'));
                $baseClass = call_user_func(array($this->className, 'getBaseClass'));
                
index 530becdad32b41311c2f2f3e0a01ba7c6a2f5aa0..ca0e83a0214f541edd63f3dd518fb0a3faddceee 100644 (file)
@@ -3,6 +3,7 @@ namespace wcf\data;
 use wcf\system\database\util\PreparedStatementConditionBuilder;
 use wcf\system\exception\SystemException;
 use wcf\system\WCF;
+use wcf\util\StringUtil;
 
 /**
  * Abstract class for a list of database objects.
@@ -103,6 +104,15 @@ abstract class DatabaseObjectList implements \Countable, ITraversableObject {
         * Creates a new DatabaseObjectList object.
         */
        public function __construct() {
+               // set class name
+               if (empty($this->className)) {
+                       $className = get_called_class();
+                       
+                       if (StringUtil::substring($className, -4) == 'List') {
+                               $this->className = StringUtil::substring($className, 0, -4);
+                       }
+               }
+               
                $this->conditionBuilder = new PreparedStatementConditionBuilder();
        }