Option cache builder supports various objects
authorAlexander Ebert <ebert@woltlab.com>
Tue, 8 Nov 2011 11:32:27 +0000 (12:32 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 8 Nov 2011 11:32:27 +0000 (12:32 +0100)
wcfsetup/install/files/lib/system/cache/builder/OptionCacheBuilder.class.php

index 04700e508a26c5b32a33fc78951b43f8597c3575..5e8d82cb3254e7612d9fd330d7a71fa52c8b831b 100644 (file)
@@ -91,6 +91,19 @@ class OptionCacheBuilder implements ICacheBuilder {
                }
                
                if (count($optionIDs) > 0) {
+                       // get option class from type
+                       $className = 'wcf\data\option\Option';
+                       if (!empty($type)) {
+                               preg_match_all('~((?:^|[A-Z])[a-z]+)~', $type, $matches);
+                               if (isset($matches[1])) {
+                                       $className = 'wcf\data\\';
+                                       for ($i = 0, $length = sizeof($matches[1]); $i < $length; $i++) {
+                                               $className .= $matches[1][$i] . '\\';
+                                       }
+                                       $className .= ucfirst($type);
+                               }
+                       }
+                       
                        // get needed options
                        $conditions = new PreparedStatementConditionBuilder();
                        $conditions->add("optionID IN (?)", array($optionIDs));
@@ -102,7 +115,7 @@ class OptionCacheBuilder implements ICacheBuilder {
                        $statement = WCF::getDB()->prepareStatement($sql);
                        $statement->execute($conditions->getParameters());
                        while ($row = $statement->fetchArray()) {
-                               $data['options'][$row['optionName']] = new Option(null, $row);
+                               $data['options'][$row['optionName']] = new $className(null, $row);
                                if (!isset($data['optionToCategories'][$row['categoryName']])) {
                                        $data['optionToCategories'][$row['categoryName']] = array();
                                }