Skip to content

Commit

Permalink
Migration ZF3
Browse files Browse the repository at this point in the history
  • Loading branch information
basselin committed Jun 30, 2016
1 parent e6f4c29 commit d58f4bc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
12 changes: 9 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"type": "library",
"keywords": [
"zendframework", "zf2",
"zendframework",
"google", "recaptcha", "captcha"
],
"homepage": "https://github.com/basselin/zf2-new-recaptcha",
Expand All @@ -16,8 +16,14 @@
}
],
"require": {
"php": "^5.5 || ^7.0",
"zendframework/zendframework": "~2.4"
"php": "^5.6 || ^7.0",
"zendframework/zend-form": "^2.9",
"zendframework/zend-http": "^2.5.4",
"zendframework/zend-inputfilter": "^2.7.2",
"zendframework/zend-modulemanager": "^2.7.1",
"zendframework/zend-servicemanager": "^3.1",
"zendframework/zend-stdlib": "^3.0.1",
"zendframework/zend-view": "^2.8"
},
"autoload": {
"psr-4": {
Expand Down
11 changes: 10 additions & 1 deletion config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace NewReCaptcha;

use Zend\ServiceManager\Factory\InvokableFactory;

return [
'new_recaptcha' => [
//'site_key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
Expand All @@ -15,15 +17,22 @@
],
'form_elements' => [
'aliases' => [
'newreraptcha' => Form\Element\NewReCaptcha::class,
'newReCaptcha' => Form\Element\NewReCaptcha::class,
'NewReCaptcha' => Form\Element\NewReCaptcha::class,
],
'factories' => [
Form\Element\NewReCaptcha::class => Form\Element\Service\NewReCaptchaFactory::class,
],
],
'view_helpers' => [
'invokables' => [
'aliases' => [
'formnewrecaptcha' => Form\View\Helper\FormNewReCaptcha::class,
'formNewReCaptcha' => Form\View\Helper\FormNewReCaptcha::class,
'FormNewReCaptcha' => Form\View\Helper\FormNewReCaptcha::class,
],
'factories' => [
Form\View\Helper\FormNewReCaptcha::class => InvokableFactory::class,
],
],
];
18 changes: 8 additions & 10 deletions src/NewReCaptcha/Form/Element/Service/NewReCaptchaFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,21 @@

namespace NewReCaptcha\Form\Element\Service;

use Interop\Container\ContainerInterface;
use NewReCaptcha\Form\Element\NewReCaptcha;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\ServiceManager\Factory\FactoryInterface;

class NewReCaptchaFactory implements FactoryInterface
{
/**
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
* @param ContainerInterface $container
* @param string $requestedName
* @param array| $options
* @return NewReCaptcha
*/
public function createService(ServiceLocatorInterface $serviceLocator)
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
/* @var ServiceLocatorInterface $sl */
$sl = $serviceLocator->getServiceLocator();
$config = $sl->get('Config');
$config = $container->get('Config');

$element = new NewReCaptcha();
if (isset($config['new_recaptcha'])) {
Expand All @@ -36,7 +34,7 @@ public function createService(ServiceLocatorInterface $serviceLocator)
$element->setRemoteIp($configCaptcha['remote_ip']);
}
}
$element->setRequest($sl->get('Request'));
$element->setRequest($container->get('Request'));
return $element;
}
}

0 comments on commit d58f4bc

Please sign in to comment.