/**
  * @param ServiceLocatorInterface $serviceLocator
  * @return ReCaptcha
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     if ($serviceLocator instanceof AbstractPluginManager) {
         $serviceLocator = $serviceLocator->getServiceLocator();
     }
     $config = $serviceLocator->get('config');
     if (empty($config['mxreCaptcha']['sitekey'])) {
         throw new \InvalidArgumentException('mxreCaptcha.sitekey is missing');
     }
     // register custom renderer for the element
     $serviceLocator->get('ViewHelperManager')->get('FormElement')->addClass(ReCaptcha::class, ReCaptchaElement::class);
     $element = new ReCaptcha();
     $element->setSiteKey($config['mxreCaptcha']['sitekey']);
     return $element;
 }
 public function __invoke(ReCaptcha $element)
 {
     return $this->getView()->render('mxreCaptcha/element', ['element' => $element, 'options' => json_encode(array_merge(['sitekey' => $element->getSiteKey()], (array) $element->getOption('widget_options')))]);
 }