Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CaptchaFactory.php
Go to the documentation of this file.
1 <?php
9 
11 {
15  protected $_objectManager;
16 
20  public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager)
21  {
22  $this->_objectManager = $objectManager;
23  }
24 
33  public function create($captchaType, $formId)
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  }
45 }
$objectManager
Definition: bootstrap.php:17
__construct(\Magento\Framework\ObjectManagerInterface $objectManager)
if($currentSelectedMethod==$_code) $className
Definition: form.phtml:31