Skip to content

Commit

Permalink
Forgot to make things Twig 2 compatible!
Browse files Browse the repository at this point in the history
  • Loading branch information
BytewaveMLP committed Jul 2, 2017
1 parent 0217b84 commit 06b3ca4
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions app/Twig/Extensions/ReCaptchaExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* Provides reCAPTCHA support to Twig views
*/
class ReCaptchaExtension extends \Twig_Extension
class ReCaptchaExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface
{
/**
* reCAPTCHA site key
Expand All @@ -34,30 +34,14 @@ public function getName() {
return 'reCAPTCHA';
}

/**
* Generates and returns the HTML code necessary for reCAPTCHA on a form
* @return string The HTML needed for a reCAPTCHA form element
*/
public function reCaptchaForm() {
return "<div class=\"g-recaptcha\" data-sitekey=" . $this->siteKey . "></div>";
}

/**
* Returns the script necessary for
* @return string The HTML script tag needed for reCAPTCHA to function
*/
public function reCaptchaScript() {
return '<script src="https://www.google.com/recaptcha/api.js" async defer></script>';
}

/**
* {@inheritdoc}
*/
public function getGlobals() {
return [
'recaptcha' => [
'script' => $this->reCaptchaScript(),
'form' => $this->reCaptchaForm(),
'script' => '<script src="https://www.google.com/recaptcha/api.js" async defer></script>',
'form' => '<div class="g-recaptcha" data-sitekey="' . $this->siteKey . '"></div>',
],
];
}
Expand Down

0 comments on commit 06b3ca4

Please sign in to comment.