Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
CaptchaFactory Class Reference

Public Member Functions

 __construct (\Magento\Framework\ObjectManagerInterface $objectManager)
 
 create ($captchaType, $formId)
 

Protected Attributes

 $_objectManager
 

Detailed Description

Definition at line 10 of file CaptchaFactory.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\ObjectManagerInterface  $objectManager)
Parameters
\Magento\Framework\ObjectManagerInterface$objectManager

Definition at line 20 of file CaptchaFactory.php.

21  {
22  $this->_objectManager = $objectManager;
23  }
$objectManager
Definition: bootstrap.php:17

Member Function Documentation

◆ create()

create (   $captchaType,
  $formId 
)

Get captcha instance

Parameters
string$captchaType
string$formId
Returns
\Magento\Captcha\Model\CaptchaInterface
Exceptions

Definition at line 33 of file CaptchaFactory.php.

34  {
35  $className = 'Magento\Captcha\Model\\' . ucfirst($captchaType);
36 
37  $instance = $this->_objectManager->create($className, ['formId' => $formId]);
38  if (!$instance instanceof \Magento\Captcha\Model\CaptchaInterface) {
39  throw new \InvalidArgumentException(
40  $className . ' does not implement \Magento\Captcha\Model\CaptchaInterface'
41  );
42  }
43  return $instance;
44  }
if($currentSelectedMethod==$_code) $className
Definition: form.phtml:31

Field Documentation

◆ $_objectManager

$_objectManager
protected

Definition at line 15 of file CaptchaFactory.php.


The documentation for this class was generated from the following file: