use wcf\data\object\type\ObjectType;
use wcf\page\AbstractPage;
use wcf\system\category\CategoryHandler;
+use wcf\system\exception\InvalidObjectTypeException;
use wcf\system\exception\PermissionDeniedException;
-use wcf\system\exception\SystemException;
use wcf\system\user\collapsible\content\UserCollapsibleContentHandler;
use wcf\system\WCF;
public function readData() {
$this->objectType = CategoryHandler::getInstance()->getObjectTypeByName($this->objectTypeName);
if ($this->objectType === null) {
- throw new SystemException("Unknown category object type with name '".$this->objectTypeName."'");
+ throw new InvalidObjectTypeException($this->objectTypeName, 'com.woltlab.wcf.category');
}
// check permissions
--- /dev/null
+<?php
+namespace wcf\system\exception;
+
+/**
+ * Exception implementation for cases when an object type of a certain object type
+ * definition is expected but the object type is of a different object type definition.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Exception
+ * @since 3.0
+ */
+class InvalidObjectTypeException extends \UnexpectedValueException {
+ /**
+ * InvalidObjectTypeException constructor.
+ *
+ * @param string $objectType invalid object type name
+ * @param string $definitionName name of the required object type definition
+ */
+ public function __construct($objectType, $definitionName) {
+ parent::__construct("Invalid object type '{$objectType}' for definition '{$definitionName}'.");
+ }
+}
\ No newline at end of file
<?php
namespace wcf\system\html;
use wcf\data\object\type\ObjectTypeCache;
-use wcf\system\exception\SystemException;
+use wcf\system\exception\InvalidObjectTypeException;
/**
* Default implementation for html processors.
*
* @param string $objectType object type identifier
* @param integer $objectID object id
- * @throws SystemException
+ * @throws InvalidObjectTypeException
*/
public function setContext($objectType, $objectID) {
$objectTypeID = ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.message', $objectType);
if ($objectTypeID === null) {
- throw new SystemException("Invalid object type '" . $objectType . "' for definition 'com.woltlab.wcf.message'.");
+ throw new InvalidObjectTypeException($objectType, 'com.woltlab.wcf.message');
}
$this->context = [
use wcf\data\object\type\ObjectTypeCache;
use wcf\system\bbcode\BBCodeParser;
use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\exception\InvalidObjectTypeException;
use wcf\system\html\input\HtmlInputProcessor;
use wcf\system\SingletonFactory;
use wcf\system\WCF;
/**
* Loads the embedded objects for given messages.
*
- * @param string $messageObjectType
- * @param integer[] $messageIDs
+ * @param string $messageObjectType
+ * @param integer[] $messageIDs
+ * @throws InvalidObjectTypeException
*/
public function loadObjects($messageObjectType, array $messageIDs) {
$messageObjectTypeID = ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.message', $messageObjectType);
if ($messageObjectTypeID === null) {
- throw new \UnexpectedValueException("Expected a valid object type for definition 'com.woltlab.wcf.message'.");
+ throw new InvalidObjectTypeException($messageObjectType, 'com.woltlab.wcf.message');
}
$conditionBuilder = new PreparedStatementConditionBuilder();
use wcf\data\user\UserProfile;
use wcf\data\DatabaseObject;
use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\exception\InvalidObjectTypeException;
use wcf\system\exception\SystemException;
use wcf\system\moderation\queue\activation\IModerationQueueActivationHandler;
use wcf\system\moderation\queue\report\IModerationQueueReportHandler;
public function removeQueues(array $objectIDs) {
$objectTypeID = ModerationQueueManager::getInstance()->getObjectTypeID($this->definitionName, $this->objectType);
if ($objectTypeID === null) {
- throw new SystemException("Object type '".$this->objectType."' is not valid for definition '".$this->definitionName."'");
+ throw new InvalidObjectTypeException($this->objectType, $this->definitionName);
}
$conditions = new PreparedStatementConditionBuilder();
namespace wcf\system\moderation\queue;
use wcf\data\moderation\queue\ModerationQueue;
use wcf\data\moderation\queue\ViewableModerationQueue;
-use wcf\system\exception\SystemException;
+use wcf\system\exception\InvalidObjectTypeException;
use wcf\system\request\LinkHandler;
/**
* @param string $objectType
* @param integer $objectID
* @param array $additionalData
- * @throws SystemException
+ * @throws InvalidObjectTypeException
*/
public function addModeratedContent($objectType, $objectID, array $additionalData = []) {
if (!$this->isValid($objectType)) {
- throw new SystemException("Object type '".$objectType."' is not valid for definition 'com.woltlab.wcf.moderation.activation'");
+ throw new InvalidObjectTypeException($objectType, 'com.woltlab.wcf.moderation.activation');
}
$this->addEntry(
*
* @param string $objectType
* @param integer[] $objectIDs
- * @throws SystemException
+ * @throws InvalidObjectTypeException
*/
public function removeModeratedContent($objectType, array $objectIDs) {
if (!$this->isValid($objectType)) {
- throw new SystemException("Object type '".$objectType."' is not valid for definition 'com.woltlab.wcf.moderation.activation'");
+ throw new InvalidObjectTypeException($objectType, 'com.woltlab.wcf.moderation.activation');
}
$this->removeEntries($this->getObjectTypeID($objectType), $objectIDs);
use wcf\data\moderation\queue\ModerationQueue;
use wcf\data\moderation\queue\ModerationQueueAction;
use wcf\data\moderation\queue\ViewableModerationQueue;
-use wcf\system\exception\SystemException;
+use wcf\system\exception\InvalidObjectTypeException;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
* @param integer $objectID
* @param string $message
* @param array $additionalData
- * @throws SystemException
+ * @throws InvalidObjectTypeException
*/
public function addReport($objectType, $objectID, $message, array $additionalData = []) {
if (!$this->isValid($objectType)) {
- throw new SystemException("Object type '".$objectType."' is not valid for definition 'com.woltlab.wcf.moderation.report'");
+ throw new InvalidObjectTypeException($objectType, 'com.woltlab.wcf.moderation.report');
}
$additionalData['message'] = $message;
use wcf\data\tag\Tag;
use wcf\data\tag\TagAction;
use wcf\system\database\util\PreparedStatementConditionBuilder;
-use wcf\system\exception\SystemException;
+use wcf\system\exception\InvalidObjectTypeException;
use wcf\system\SingletonFactory;
use wcf\system\WCF;
*
* @param string $objectType
* @return integer
- * @throws SystemException
+ * @throws InvalidObjectTypeException
*/
public function getObjectTypeID($objectType) {
// get object type
$objectTypeObj = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.tagging.taggableObject', $objectType);
if ($objectTypeObj === null) {
- throw new SystemException("Object type '".$objectType."' is not valid for definition 'com.woltlab.wcf.tagging.taggableObject'");
+ throw new InvalidObjectTypeException($objectType, 'com.woltlab.wcf.tagging.taggableObject');
}
return $objectTypeObj->objectTypeID;
use wcf\data\object\type\ObjectTypeCache;
use wcf\data\user\UserProfileAction;
use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\exception\InvalidObjectTypeException;
use wcf\system\exception\SystemException;
use wcf\system\user\group\assignment\UserGroupAssignmentHandler;
use wcf\system\SingletonFactory;
* @param integer $objectID
* @param integer $userID
* @param mixed[] $additionalData
- * @throws SystemException
+ * @throws InvalidObjectTypeException
*/
public function fireEvent($objectType, $objectID, $userID = null, array $additionalData = []) {
$objectTypeObj = $this->getObjectTypeByName($objectType);
if ($objectTypeObj === null) {
- throw new SystemException("Object type '".$objectType."' is not valid for object type definition 'com.woltlab.wcf.user.activityPointEvent'");
+ throw new InvalidObjectTypeException($objectType, 'com.woltlab.wcf.user.activityPointEvent');
}
if ($userID === null) $userID = WCF::getUser()->userID;
* @param string $objectType
* @param integer[] $itemsToUser
* @param boolean $updateUsers
- * @throws SystemException
+ * @throws InvalidObjectTypeException
*/
public function fireEvents($objectType, array $itemsToUser, $updateUsers = true) {
$objectTypeObj = $this->getObjectTypeByName($objectType);
if ($objectTypeObj === null) {
- throw new SystemException("Object type '".$objectType."' is not valid for object type definition 'com.woltlab.wcf.user.activityPointEvent'");
+ throw new InvalidObjectTypeException($objectType, 'com.woltlab.wcf.user.activityPointEvent');
}
if (empty($itemsToUser)) {
*
* @param string $objectType
* @param integer[] $userToItems
- * @throws SystemException
+ * @throws InvalidObjectTypeException
*/
public function removeEvents($objectType, array $userToItems) {
if (empty($userToItems)) return;
// get and validate object type
$objectTypeObj = $this->getObjectTypeByName($objectType);
if ($objectTypeObj === null) {
- throw new SystemException("Object type '".$objectType."' is not valid for object type definition 'com.woltlab.wcf.user.activityPointEvent'");
+ throw new InvalidObjectTypeException($objectType, 'com.woltlab.wcf.user.activityPointEvent');
}
// remove activity points
* Resets activity points and items for a given object type.
*
* @param string $objectType
- * @throws SystemException
+ * @throws InvalidObjectTypeException
*/
public function reset($objectType) {
// get and validate object type
$objectTypeObj = $this->getObjectTypeByName($objectType);
if ($objectTypeObj === null) {
- throw new SystemException("Object type '".$objectType."' is not valid for object type definition 'com.woltlab.wcf.user.activityPointEvent'");
+ throw new InvalidObjectTypeException($objectType, 'com.woltlab.wcf.user.activityPointEvent');
}
$sql = "UPDATE wcf".WCF_N."_user_activity_point
namespace wcf\system\user\collapsible\content;
use wcf\data\object\type\ObjectTypeCache;
use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\exception\InvalidObjectTypeException;
use wcf\system\exception\SystemException;
use wcf\system\user\storage\UserStorageHandler;
use wcf\system\SingletonFactory;
* @param string $objectType
* @param string $objectID
* @return boolean
- * @throws SystemException
+ * @throws InvalidObjectTypeException
*/
public function isCollapsed($objectType, $objectID) {
$objectTypeID = $this->getObjectTypeID($objectType);
if ($objectTypeID === null) {
- throw new SystemException("Unknown object type '".$objectType."' for definition 'com.woltlab.wcf.collapsibleContent'");
+ throw new InvalidObjectTypeException($objectType, 'com.woltlab.wcf.collapsibleContent');
}
return in_array($objectID, $this->getCollapsedContent($objectTypeID));
public function resetAll($objectType, $objectID = null) {
$objectTypeID = $this->getObjectTypeID($objectType);
if (!$objectTypeID) {
- throw new SystemException("Unknown collapsible object type '".$objectType."'");
+ throw new InvalidObjectTypeException($objectType, 'com.woltlab.wcf.collapsibleContent');
}
$conditionBuilder = new PreparedStatementConditionBuilder();