<?php
namespace wcf\data\category;
-use wcf\data\DatabaseObject;
+use wcf\data\ProcessibleDatabaseObject;
use wcf\system\category\CategoryHandler;
use wcf\system\request\IRouteController;
use wcf\system\WCF;
* @subpackage data.category
* @category Community Framework
*/
-class Category extends DatabaseObject implements IRouteController {
- /**
- * category type of this category
- * @var wcf\system\category\ICategoryType
- */
- protected $categoryType = null;
-
+class Category extends ProcessibleDatabaseObject implements IRouteController {
/**
* list of all parent category generations of this category
* @var array<wcf\data\category\Category>
*/
protected static $databaseTableName = 'category';
+ /**
+ * @see wcf\data\ProcessibleDatabaseObject::$processorInterface
+ */
+ protected static $processorInterface = 'wcf\system\category\ICategoryType';
+
/**
* @see wcf\data\IStorableObject::__get()
*/
public function __get($name) {
+ // forward 'className' property requests to object type
+ if ($name == 'className') {
+ return $this->getObjectType()->className;
+ }
+
$value = parent::__get($name);
// check additional data
}
/**
- * Returns the category type of this category.
- *
- * @return wcf\system\category\ICategoryType
- */
- public function getCategoryType() {
- if ($this->categoryType === null) {
- $this->categoryType = CategoryHandler::getInstance()->getObjectType($this->objectTypeID)->getProcessor();
- }
-
- return $this->categoryType;
- }
-
- /**
- * Returns the name of the category type of this category.
- *
- * @return string
+ * @see wcf\system\request\IRouteController::getID()
*/
- public function getCategoryTypeName() {
- return CategoryHandler::getInstance()->getObjectType($this->objectTypeID)->objectType;
+ public function getID() {
+ return $this->categoryID;
}
/**
- * @see wcf\system\request\IRouteController::getID()
+ * Returns the category object type of the category.
+ *
+ * @return wcf\data\category\Category
*/
- public function getID() {
- return $this->categoryID;
+ public function getObjectType() {
+ return CategoryHandler::getInstance()->getObjectType($this->objectTypeID);
}
/**
// call category types
foreach ($this->objects as $categoryEditor) {
- $categoryEditor->getCategoryType()->afterDeletion($categoryEditor);
+ $categoryEditor->getProcessor()->afterDeletion($categoryEditor);
}
return $returnValue;
* @see wcf\data\ICollapsibleContainerAction::toggleContainer()
*/
public function toggleContainer() {
- $collapsibleObjectTypeName = $this->objects[0]->getCategoryType()->getObjectTypeName('com.woltlab.wcf.collapsibleContent');
+ $collapsibleObjectTypeName = $this->objects[0]->getProcessor()->getObjectTypeName('com.woltlab.wcf.collapsibleContent');
if ($collapsibleObjectTypeName === null) {
throw new SystemException("Categories of this type don't support collapsing");
}
* @see wcf\data\AbstractDatabaseObjectAction::validateDelete()
*/
public function validateCreate() {
- // validate permissions
- if (!empty($this->permissionsCreate)) {
- WCF::getSession()->checkPermissions($this->permissionsCreate);
- }
-
if (!isset($this->parameters['data']['objectTypeID'])) {
throw new UserInputException('objectTypeID');
}
* @see wcf\data\AbstractDatabaseObjectAction::validateDelete()
*/
public function validateDelete() {
- // validate permissions
- if (!empty($this->permissionsDelete)) {
- try {
- WCF::getSession()->checkPermissions($this->permissionsDelete);
- }
- catch (PermissionDeniedException $e) {
- throw new PermissionDeniedException();
- }
- }
-
// read objects
if (empty($this->objects)) {
$this->readObjects();
}
foreach ($this->objects as $categoryEditor) {
- if (!$categoryEditor->getCategoryType()->canDeleteCategory()) {
+ if (!$categoryEditor->getProcessor()->canDeleteCategory()) {
throw new PermissionDeniedException();
}
}
* @see wcf\data\AbstractDatabaseObjectAction::validateUpdate()
*/
public function validateUpdate() {
- // validate permissions
- if (!empty($this->permissionsUpdate)) {
- WCF::getSession()->checkPermissions($this->permissionsUpdate);
- }
-
// read objects
if (empty($this->objects)) {
$this->readObjects();
}
foreach ($this->objects as $categoryEditor) {
- if (!$categoryEditor->getCategoryType()->canEditCategory()) {
+ if (!$categoryEditor->getProcessor()->canEditCategory()) {
throw new PermissionDeniedException();
}
}
* @see wcf\data\ISortableAction::validateUpdatePosition()
*/
public function validateUpdatePosition() {
- // validate permissions
- if (!empty($this->permissionsUpdate)) {
- try {
- WCF::getSession()->checkPermissions($this->permissionsUpdate);
- }
- catch (PermissionDeniedException $e) {
- throw new PermissionDeniedException();
- }
- }
-
// validate 'structure' parameter
if (!isset($this->parameters['data']['structure']) || !is_array($this->parameters['data']['structure'])) {
throw new UserInputException('structure');
throw new UserInputException('structure');
}
- $this->objects[$category->categoryID] = new $this->className($category);
-
// validate permissions
- if (!$category->getCategoryType()->canEditCategory()) {
+ if (!$category->getProcessor()->canEditCategory()) {
throw new PermissionDeniedException();
}
+
+ $this->objects[$category->categoryID] = new $this->className($category);
}
foreach ($categoryIDs as $categoryID) {
throw new UserInputException('structure');
}
- $this->objects[$category->categoryID] = new $this->className($category);
-
// validate permissions
- if (!$category->getCategoryType()->canEditCategory()) {
+ if (!$category->getProcessor()->canEditCategory()) {
throw new PermissionDeniedException();
}
+
+ $this->objects[$category->categoryID] = new $this->className($category);
}
}
}