3 namespace wcf\system\captcha
;
5 use wcf\data\
object\type\ObjectType
;
6 use wcf\data\
object\type\ObjectTypeCache
;
7 use wcf\system\SingletonFactory
;
13 * @author Matthias Schmidt
14 * @copyright 2001-2019 WoltLab GmbH
15 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
17 class CaptchaHandler
extends SingletonFactory
20 * available captcha object types
23 protected $objectTypes = [];
26 * Returns the available captcha types for selection.
30 public function getCaptchaSelection()
33 foreach ($this->objectTypes
as $objectType) {
34 if ($objectType->getProcessor()->isAvailable()) {
35 $selection[$objectType->objectType
] = WCF
::getLanguage()->get('wcf.captcha.' . $objectType->objectType
);
43 * Returns the captcha object type with the given id or `null` if no such
46 * @param int $objectTypeID
47 * @return ObjectType|null
49 public function getObjectType($objectTypeID)
51 return $this->objectTypes
[$objectTypeID] ??
null;
55 * Returns the captcha object type with the given name or null if no such
58 * @param string $objectType
59 * @return ObjectType|null
61 public function getObjectTypeByName($objectType)
63 return ObjectTypeCache
::getInstance()->getObjectTypeByName('com.woltlab.wcf.captcha', $objectType);
69 protected function init()
71 $objectTypes = ObjectTypeCache
::getInstance()->getObjectTypes('com.woltlab.wcf.captcha');
72 foreach ($objectTypes as $objectType) {
73 $this->objectTypes
[$objectType->objectTypeID
] = $objectType;