From 7703d9748cfc8924afc044e1f4ae0368d4c690a6 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sat, 31 Mar 2012 16:18:37 +0200 Subject: [PATCH] Autosets className in DBOEditor and AbstractDBOAction --- .../lib/data/AbstractDatabaseObjectAction.class.php | 9 +++++++++ .../files/lib/data/DatabaseObjectList.class.php | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php b/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php index 6a2bb9a27e..cbe53272bc 100644 --- a/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php +++ b/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php @@ -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')); diff --git a/wcfsetup/install/files/lib/data/DatabaseObjectList.class.php b/wcfsetup/install/files/lib/data/DatabaseObjectList.class.php index 530becdad3..ca0e83a021 100644 --- a/wcfsetup/install/files/lib/data/DatabaseObjectList.class.php +++ b/wcfsetup/install/files/lib/data/DatabaseObjectList.class.php @@ -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(); } -- 2.20.1