* Returns true if the given category fulfills all needed conditions to
* be included in the list.
*
- * @param wcf\data\category\Category $category
+ * @param wcf\data\DatabaseObject $category
* @return boolean
*/
- public function fulfillsConditions(Category $category) {
+ protected function fulfillsConditions(DatabaseObject $category) {
return !in_array($category->categoryID, $this->excludedCategoryIDs) && ($this->includeDisabledCategories || !$category->isDisabled);
}
* name of the category node class
* @var string
*/
- protected $nodeClassName = 'wcf\data\category\CategoryNode';
+ protected $nodeClassName = '';
/**
* id of the parent category
* @param array<integer> $excludedCategoryIDs
*/
public function __construct($objectType, $parentCategoryID = 0, $includeDisabledCategories = false, array $excludedCategoryIDs = array()) {
+ if (empty($this->nodeClassName)) {
+ $this->nodeClassName = str_replace('List', '', get_class($this));
+ if (!class_exists($this->nodeClassName)) {
+ throw new SystemException("Unknown category node class '".$this->nodeClassName."'.");
+ }
+ }
+
$this->parentCategoryID = $parentCategoryID;
// get parent category
<?php
namespace wcf\system\category;
use wcf\data\category\Category;
+use wcf\data\DatabaseObject;
+use wcf\data\DatabaseObjectDecorator;
use wcf\system\SingletonFactory;
use wcf\data\object\type\ObjectTypeCache;
use wcf\system\cache\CacheHandler;
+use wcf\system\exception\SystemException;
/**
* Handles categories.
/**
* Returns the child categories of the given category.
*
- * @param wcf\data\category\Category $category
+ * @param wcf\data\DatabaseObject $category
* @return array<wcf\data\category\Category>
*/
- public function getChildCategories(Category $category) {
- $categories = array();
+ public function getChildCategories(DatabaseObject $category) {
+ if (!($category instanceof Category) && (!($category instanceof DatabaseObjectDecorator) || !($category->getDecoratedObject() instanceof Category))) {
+ throw new SystemException("Invalid object given (class: ".get_class($category).")");
+ }
+ $categories = array();
foreach ($this->categories as $__category) {
if ($__category->parentCategoryID == $category->categoryID && ($category->categoryID || $category->objectTypeID == $__category->objectTypeID)) {
$categories[$__category->categoryID] = $__category;