From 6e9aed8cdfdaa7614a9bc394d20ec6d4c2f3577e Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Tue, 2 Sep 2014 20:50:32 +0200 Subject: [PATCH] Add auto-guessing of application abbreviation These changes are relevant for application's `*Core` classes, category types, deleted content providers and taggables. --- .../application/AbstractApplication.class.php | 6 ++++- .../category/AbstractCategoryType.class.php | 3 ++- .../category/SmileyCategoryType.class.php | 7 ------ .../AbstractDeletedContentProvider.class.php | 23 +++++++++++++++++++ .../AbstractSearchableObjectType.class.php | 3 ++- .../system/tagging/AbstractTaggable.class.php | 23 +++++++++++++++++++ 6 files changed, 55 insertions(+), 10 deletions(-) create mode 100644 wcfsetup/install/files/lib/system/moderation/AbstractDeletedContentProvider.class.php create mode 100644 wcfsetup/install/files/lib/system/tagging/AbstractTaggable.class.php diff --git a/wcfsetup/install/files/lib/system/application/AbstractApplication.class.php b/wcfsetup/install/files/lib/system/application/AbstractApplication.class.php index bc8803ecb9..26f23e7d6b 100644 --- a/wcfsetup/install/files/lib/system/application/AbstractApplication.class.php +++ b/wcfsetup/install/files/lib/system/application/AbstractApplication.class.php @@ -43,7 +43,11 @@ abstract class AbstractApplication extends SingletonFactory implements IApplicat * @see \wcf\system\SingletonFactory::init() */ protected final function init() { - if (empty($this->abbreviation) || $this->abbreviation == 'wcf') { + if (empty($this->abbreviation)) { + $classParts = explode('\\', get_called_class()); + $this->abbreviation = $classParts[0]; + } + else if ($this->abbreviation == 'wcf') { throw new SystemException("Unable to determine application, abbreviation is missing"); } diff --git a/wcfsetup/install/files/lib/system/category/AbstractCategoryType.class.php b/wcfsetup/install/files/lib/system/category/AbstractCategoryType.class.php index 07cd527165..b4e17d9c66 100644 --- a/wcfsetup/install/files/lib/system/category/AbstractCategoryType.class.php +++ b/wcfsetup/install/files/lib/system/category/AbstractCategoryType.class.php @@ -109,7 +109,8 @@ abstract class AbstractCategoryType extends SingletonFactory implements ICategor * @see \wcf\system\category\ICategoryType::getApplication() */ public function getApplication() { - return 'wcf'; + $classParts = explode('\\', get_called_class()); + return $classParts[0]; } /** diff --git a/wcfsetup/install/files/lib/system/category/SmileyCategoryType.class.php b/wcfsetup/install/files/lib/system/category/SmileyCategoryType.class.php index 639664233b..b9c7cb4d83 100644 --- a/wcfsetup/install/files/lib/system/category/SmileyCategoryType.class.php +++ b/wcfsetup/install/files/lib/system/category/SmileyCategoryType.class.php @@ -29,13 +29,6 @@ class SmileyCategoryType extends AbstractCategoryType { */ protected $maximumNestingLevel = 0; - /** - * @see \wcf\system\category\ICategoryType::getApplication() - */ - public function getApplication() { - return 'wcf'; - } - /** * @see \wcf\system\category\ICategoryType::canAddCategory() */ diff --git a/wcfsetup/install/files/lib/system/moderation/AbstractDeletedContentProvider.class.php b/wcfsetup/install/files/lib/system/moderation/AbstractDeletedContentProvider.class.php new file mode 100644 index 0000000000..05cb196d0b --- /dev/null +++ b/wcfsetup/install/files/lib/system/moderation/AbstractDeletedContentProvider.class.php @@ -0,0 +1,23 @@ + + * @package com.woltlab.wcf + * @subpackage system.moderation + * @category Community Framework + */ +abstract class AbstractDeletedContentProvider extends AbstractObjectTypeProcessor implements IDeletedContentProvider { + /** + * @see \wcf\system\moderation\IDeletedContentProvider::getApplication() + */ + public function getApplication() { + $classParts = explode('\\', get_called_class()); + return $classParts[0]; + } +} diff --git a/wcfsetup/install/files/lib/system/search/AbstractSearchableObjectType.class.php b/wcfsetup/install/files/lib/system/search/AbstractSearchableObjectType.class.php index 6a25675f6a..4545ef8aea 100644 --- a/wcfsetup/install/files/lib/system/search/AbstractSearchableObjectType.class.php +++ b/wcfsetup/install/files/lib/system/search/AbstractSearchableObjectType.class.php @@ -30,7 +30,8 @@ abstract class AbstractSearchableObjectType extends AbstractObjectTypeProcessor * @see \wcf\system\search\ISearchableObjectType::getApplication() */ public function getApplication() { - return 'wcf'; + $classParts = explode('\\', get_called_class()); + return $classParts[0]; } /** diff --git a/wcfsetup/install/files/lib/system/tagging/AbstractTaggable.class.php b/wcfsetup/install/files/lib/system/tagging/AbstractTaggable.class.php new file mode 100644 index 0000000000..1b2fa6204a --- /dev/null +++ b/wcfsetup/install/files/lib/system/tagging/AbstractTaggable.class.php @@ -0,0 +1,23 @@ + + * @package com.woltlab.wcf + * @subpackage system.tagging + * @category Community Framework + */ +abstract class AbstractTaggable extends AbstractObjectTypeProcessor implements ITaggable { + /** + * @see \wcf\system\tagging\ITaggable::getApplication() + */ + public function getApplication() { + $classParts = explode('\\', get_called_class()); + return $classParts[0]; + } +} -- 2.20.1