\CaptchaCaptchaManager

Class for dealing with CAPTCHA adapters.

Usage:

Rendering the CAPTCHA form element in any template

CaptchaManager::adapter()->render($this->Form);

Validating CAPTCHA in controller

CaptchaManager::adapter()->validate($this->request->data());

Registering CAPTCHA adapters

CaptchaManager::addAdapter('reCaptcha', 'MyPlugin\Adapter\RecaptchaAdapter');

Once registered it can be used as follows:

$adapter = CaptchaManager::adapter('reCaptcha');

Summary

Methods
Properties
Constants
adapter()
adapters()
addAdapter()
No public properties found
No constants found
No protected methods found
$_adapters
N/A
No private methods found
No private properties found
N/A

Properties

$_adapters

$_adapters : array

List of registered adapters.

Type

array

Methods

adapter()

adapter(string|null $name, array $config) : \Captcha\Adapter\BaseAdapter

Gets an instance of the given adapter name (or default adapter if not given).

Parameters

string|null $name

Name of the adapter, or null to use default adapter selected in Captcha plugin's setting page. The latest registered adapter will be used if no default adapter has been selected yet

array $config

Options to be passed to Adapter's config() method, if not given it will try to get such parameters from Captcha plugin's settings

Throws

\Captcha\Error\AdapterNotFoundException

When no adapter was found

Returns

\Captcha\Adapter\BaseAdapter

adapters()

adapters() : array

Gets the full list of all registered adapters.

Returns

array

addAdapter()

addAdapter(string $name, \Captcha\Adapter\BaseAdapter|string $class)

Registers a new CAPTCHA adapter, or overwrites if already registered.

Usage:

CaptchaManager::addAdapter('reCaptcha', 'MyPlugin\Adapter\RecaptchaAdapter');

Parameters

string $name

Name of identify this particular adapter.

\Captcha\Adapter\BaseAdapter|string $class

Either an instanced adapter class or a fully qualified class name