Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Provide ability to configure ReCaptcha Service public and private keys via options #4729

Closed
wants to merge 2 commits into from

2 participants

@richardjennings

Provide ability to configure ReCaptcha Service public and private keys via array specification to FormFactory::createForm()

eg:

array(
    'spec' => array(
        'type' => 'Zend\Form\Element\Captcha',
        'name' => 'captcha',
        'options' => array(
            'label' => '',
            'captcha' => array(
                'class' => 'recaptcha',
                'options' => array(
                    'public_key' => 'hshs',
                    'private_key' => penp',
                ),
            ),
        ),
    ),
);

Issue #4718

richardjennings added some commits
@richardjennings richardjennings Added test to ensure that an options argument to Zend\Captcha\ReCaptc…
…ha constructor with defined 'public_key' and/or 'private_key' key values are set on the ZendService\ReCaptcha\Recaptcha service via setPublicKey() and setPrivateKey().
8461b86
@richardjennings richardjennings Added setPrivateKey() and setPublicKey() calls to ZendService\ReCaptc…
…ha\ReCaptcha service if options provided to Zend\Captcha\ReCaptcha constructor contain a 'private_key' and/or 'public_key' key value.
f4d4c15
@mwillbanks mwillbanks was assigned
@mwillbanks mwillbanks closed this pull request from a commit
@mwillbanks mwillbanks Merge branch 'hotfix/4729'
Close #4729
02cf68e
@mwillbanks mwillbanks referenced this pull request from a commit
@mwillbanks mwillbanks Merge branch 'hotfix/4729' into develop
Forward port #4729
b3b3145
@ghost Unknown referenced this pull request from a commit
@mwillbanks mwillbanks Merge branch 'hotfix/4729'
Close #4729
fbf5bd3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 26, 2013
  1. @richardjennings

    Added test to ensure that an options argument to Zend\Captcha\ReCaptc…

    richardjennings authored
    …ha constructor with defined 'public_key' and/or 'private_key' key values are set on the ZendService\ReCaptcha\Recaptcha service via setPublicKey() and setPrivateKey().
  2. @richardjennings

    Added setPrivateKey() and setPublicKey() calls to ZendService\ReCaptc…

    richardjennings authored
    …ha\ReCaptcha service if options provided to Zend\Captcha\ReCaptcha constructor contain a 'private_key' and/or 'public_key' key value.
This page is out of date. Refresh to see the latest.
View
8 library/Zend/Captcha/ReCaptcha.php
@@ -126,6 +126,14 @@ public function __construct($options = null)
parent::__construct($options);
if (!empty($options)) {
+ //set private key if specified
+ if (array_key_exists('private_key', $options)) {
+ $this->getService()->setPrivateKey($options['private_key']);
+ }
+ //set public key if specified
+ if (array_key_exists('public_key', $options)) {
+ $this->getService()->setPublicKey($options['public_key']);
+ }
$this->setOptions($options);
}
}
View
13 tests/ZendTest/Captcha/ReCaptchaTest.php
@@ -88,6 +88,19 @@ public function testSetAndGetPublicAndPrivateKeys()
$this->assertSame($privKey, $captcha->getService()->getPrivateKey());
}
+ public function testSetAndGetRecaptchaServicePublicAndPrivateKeysFromOptions()
+ {
+ $publicKey = 'publicKey';
+ $privateKey = 'privateKey';
+ $options = array(
+ 'public_key' => $publicKey,
+ 'private_key' => $privateKey
+ );
+ $captcha = new ReCaptcha($options);
+ $this->assertSame($publicKey, $captcha->getService()->getPublicKey());
+ $this->assertSame($privateKey, $captcha->getService()->getPrivateKey());
+ }
+
/** @group ZF-7654 */
public function testConstructorShouldAllowSettingLangOptionOnServiceObject()
{
Something went wrong with that request. Please try again.