From 206ead0d5e204fcaba56bbb1f583e0d90172c5a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Str=C3=B8m?= Date: Sun, 8 Jun 2014 22:38:58 +0200 Subject: [PATCH 01/59] Fix login/logout redirect method --- src/ZfcUser/Controller/UserController.php | 4 ++-- tests/ZfcUserTest/Controller/UserControllerTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ZfcUser/Controller/UserController.php b/src/ZfcUser/Controller/UserController.php index 228222a7..6229d24b 100644 --- a/src/ZfcUser/Controller/UserController.php +++ b/src/ZfcUser/Controller/UserController.php @@ -118,7 +118,7 @@ public function logoutAction() $redirect = $this->params()->fromPost('redirect', $this->params()->fromQuery('redirect', false)); if ($this->getOptions()->getUseRedirectParameterIfPresent() && $redirect) { - return $this->redirect()->toUrl($redirect); + return $this->redirect()->toRoute($redirect); } return $this->redirect()->toRoute($this->getOptions()->getLogoutRedirectRoute()); @@ -155,7 +155,7 @@ public function authenticateAction() } if ($this->getOptions()->getUseRedirectParameterIfPresent() && $redirect) { - return $this->redirect()->toUrl($redirect); + return $this->redirect()->toRoute($redirect); } return $this->redirect()->toRoute($this->getOptions()->getLoginRedirectRoute()); diff --git a/tests/ZfcUserTest/Controller/UserControllerTest.php b/tests/ZfcUserTest/Controller/UserControllerTest.php index 15b575f6..95aab0a3 100644 --- a/tests/ZfcUserTest/Controller/UserControllerTest.php +++ b/tests/ZfcUserTest/Controller/UserControllerTest.php @@ -391,7 +391,7 @@ public function testLogoutAction($withRedirect, $post, $query) ->method('getUseRedirectParameterIfPresent') ->will($this->returnValue((bool) $withRedirect)); $redirect->expects($this->any()) - ->method('toUrl') + ->method('toRoute') ->with($expectedLocation) ->will($this->returnValue($response)); } else { @@ -510,7 +510,7 @@ public function testAuthenticateAction($wantRedirect, $post, $query, $prepareRes } elseif ($wantRedirect && $hasRedirect) { $redirect->expects($this->once()) - ->method('toUrl') + ->method('toRoute') ->with(($post ?: $query ?: false)) ->will($this->returnValue($response)); } else { From 6dd4372574d583207753f41cf692b07ad3ce2d71 Mon Sep 17 00:00:00 2001 From: Danielss89 Date: Thu, 3 Jul 2014 16:03:09 +0200 Subject: [PATCH 02/59] Change redirect strategy --- Module.php | 12 + config/module.config.php | 18 +- src/ZfcUser/Controller/RedirectCallback.php | 116 ++++ src/ZfcUser/Controller/UserController.php | 30 +- .../Controller/RedirectCallbackTest.php | 329 ++++++++++++ .../Controller/UserControllerTest.php | 506 ++++++++---------- 6 files changed, 728 insertions(+), 283 deletions(-) create mode 100644 src/ZfcUser/Controller/RedirectCallback.php create mode 100644 tests/ZfcUserTest/Controller/RedirectCallbackTest.php diff --git a/Module.php b/Module.php index 3c7afd77..024ef76a 100644 --- a/Module.php +++ b/Module.php @@ -7,6 +7,7 @@ use Zend\ModuleManager\Feature\ConfigProviderInterface; use Zend\ModuleManager\Feature\ServiceProviderInterface; use Zend\Stdlib\Hydrator\ClassMethods; +use ZfcUser\Controller\RedirectCallback; class Module implements AutoloaderProviderInterface, @@ -88,7 +89,18 @@ public function getServiceConfig() 'zfcuser_register_form_hydrator' => 'Zend\Stdlib\Hydrator\ClassMethods', ), 'factories' => array( + 'zfcuser_redirect_callback' => function ($sm) { + /* @var RouteInterface $router */ + $router = $sm->get('Router'); + /* @var Application $application */ + $application = $sm->get('Application'); + + /* @var ModuleOptions $options */ + $options = $sm->get('zfcuser_module_options'); + + return new RedirectCallback($application, $router, $options); + }, 'zfcuser_module_options' => function ($sm) { $config = $sm->get('Config'); return new Options\ModuleOptions(isset($config['zfcuser']) ? $config['zfcuser'] : array()); diff --git a/config/module.config.php b/config/module.config.php index dc8e572e..c74c4be2 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -1,4 +1,6 @@ array( 'template_path_stack' => array( @@ -6,8 +8,20 @@ ), ), 'controllers' => array( - 'invokables' => array( - 'zfcuser' => 'ZfcUser\Controller\UserController', + + 'factories' => array( + 'zfcuser' => function($controllerManager){ + /* @var ControllerManager $controllerManager*/ + $serviceManager = $controllerManager->getServiceLocator(); + + /* @var RedirectCallback $redirectCallback */ + $redirectCallback = $serviceManager->get('zfcuser_redirect_callback'); + + /* @var UserController $controller */ + $controller = new UserController($redirectCallback); + + return $controller; + }, ), ), 'service_manager' => array( diff --git a/src/ZfcUser/Controller/RedirectCallback.php b/src/ZfcUser/Controller/RedirectCallback.php new file mode 100644 index 00000000..a57449d9 --- /dev/null +++ b/src/ZfcUser/Controller/RedirectCallback.php @@ -0,0 +1,116 @@ +router = $router; + $this->application = $application; + $this->options = $options; + } + + /** + * @return Response + */ + public function __invoke() + { + $routeMatch = $this->application->getMvcEvent()->getRouteMatch(); + $redirect = $this->getRedirect($routeMatch->getMatchedRouteName(), $this->getRedirectRouteFromRequest()); + + $response = $this->application->getResponse(); + $response->getHeaders()->addHeaderLine('Location', $redirect); + $response->setStatusCode(302); + return $response; + } + + /** + * Return the redirect from param. + * First checks GET then POST + * @return string + */ + protected function getRedirectRouteFromRequest() + { + $request = $this->application->getRequest(); + $redirect = $request->getQuery('redirect'); + if ($redirect && $this->routeExists($redirect)) { + return $redirect; + } + + $redirect = $request->getPost('redirect'); + if ($redirect && $this->routeExists($redirect)) { + return $redirect; + } + + return false; + } + + /** + * @param $route + * @return bool + */ + protected function routeExists($route) + { + try { + $this->router->assemble([], ['name' => $route]); + } catch (Exception\RuntimeException $e) { + return false; + } + return true; + } + + /** + * Returns the url to redirect to based on current route. + * If $redirect is set and the option to use redirect is set to true, it will return the $redirect url. + * + * @param string $currentRoute + * @param bool $redirect + * @return mixed + */ + protected function getRedirect($currentRoute, $redirect = false) + { + $useRedirect = $this->options->getUseRedirectParameterIfPresent(); + $routeExists = ($redirect && $this->routeExists($redirect)); + if (!$useRedirect || !$routeExists) { + $redirect = false; + } + + switch ($currentRoute) { + case 'zfcuser/login': + $route = ($redirect) ?: $this->options->getLoginRedirectRoute(); + return $this->router->assemble([], ['name' => $route]); + break; + case 'zfcuser/logout': + $route = ($redirect) ?: $this->options->getLogoutRedirectRoute(); + return $this->router->assemble([], ['name' => $route]); + break; + default: + return $this->router->assemble([], ['name' => 'zfcuser']); + } + } +} diff --git a/src/ZfcUser/Controller/UserController.php b/src/ZfcUser/Controller/UserController.php index 6229d24b..3b2cc883 100644 --- a/src/ZfcUser/Controller/UserController.php +++ b/src/ZfcUser/Controller/UserController.php @@ -55,6 +55,22 @@ class UserController extends AbstractActionController */ protected $options; + /** + * @var callable $redirectCallback + */ + protected $redirectCallback; + + /** + * @param callable $redirectCallback + */ + public function __construct($redirectCallback) + { + if (!is_callable($redirectCallback)) { + throw new \InvalidArgumentException('You must supply a callable redirectCallback'); + } + $this->redirectCallback = $redirectCallback; + } + /** * User page */ @@ -115,13 +131,9 @@ public function logoutAction() $this->zfcUserAuthentication()->getAuthAdapter()->logoutAdapters(); $this->zfcUserAuthentication()->getAuthService()->clearIdentity(); - $redirect = $this->params()->fromPost('redirect', $this->params()->fromQuery('redirect', false)); - - if ($this->getOptions()->getUseRedirectParameterIfPresent() && $redirect) { - return $this->redirect()->toRoute($redirect); - } + $redirect = $this->redirectCallback; - return $this->redirect()->toRoute($this->getOptions()->getLogoutRedirectRoute()); + return $redirect(); } /** @@ -154,11 +166,9 @@ public function authenticateAction() ); } - if ($this->getOptions()->getUseRedirectParameterIfPresent() && $redirect) { - return $this->redirect()->toRoute($redirect); - } + $redirect = $this->redirectCallback; - return $this->redirect()->toRoute($this->getOptions()->getLoginRedirectRoute()); + return $redirect(); } /** diff --git a/tests/ZfcUserTest/Controller/RedirectCallbackTest.php b/tests/ZfcUserTest/Controller/RedirectCallbackTest.php new file mode 100644 index 00000000..236352c1 --- /dev/null +++ b/tests/ZfcUserTest/Controller/RedirectCallbackTest.php @@ -0,0 +1,329 @@ +router = $this->getMockBuilder('Zend\Mvc\Router\RouteInterface') + ->disableOriginalConstructor() + ->getMock(); + + $this->moduleOptions = $this->getMockBuilder('ZfcUser\Options\ModuleOptions') + ->disableOriginalConstructor() + ->getMock(); + + $this->application = $this->getMockBuilder('Zend\Mvc\Application') + ->disableOriginalConstructor() + ->getMock(); + $this->setUpApplication(); + + $this->redirectCallback = new RedirectCallback( + $this->application, + $this->router, + $this->moduleOptions + ); + } + + public function testInvoke() + { + $url = 'someUrl'; + + $this->routeMatch->expects($this->once()) + ->method('getMatchedRouteName') + ->will($this->returnValue('someRoute')); + + $headers = $this->getMock('Zend\Http\Headers'); + $headers->expects($this->once()) + ->method('addHeaderLine') + ->with('Location', $url); + + $this->router->expects($this->any()) + ->method('assemble') + ->with(array(), array('name' => 'zfcuser')) + ->will($this->returnValue($url)); + + $this->response->expects($this->once()) + ->method('getHeaders') + ->will($this->returnValue($headers)); + + $this->response->expects($this->once()) + ->method('setStatusCode') + ->with(302); + + $result = $this->redirectCallback->__invoke(); + + $this->assertSame($this->response, $result); + } + + /** + * @dataProvider providerGetRedirectRouteFromRequest + */ + public function testGetRedirectRouteFromRequest($get, $post, $getRouteExists, $postRouteExists) + { + $expectedResult = false; + + $this->request->expects($this->once()) + ->method('getQuery') + ->will($this->returnValue($get)); + + if ($get) { + $this->router->expects($this->any()) + ->method('assemble') + ->with(array(), array('name' => $get)) + ->will($getRouteExists); + + if ($getRouteExists == $this->returnValue(true)) { + $expectedResult = $get; + } + } + + if (!$get || !$getRouteExists) { + $this->request->expects($this->once()) + ->method('getPost') + ->will($this->returnValue($post)); + + if ($post) { + $this->router->expects($this->any()) + ->method('assemble') + ->with(array(), array('name' => $post)) + ->will($postRouteExists); + + if ($postRouteExists == $this->returnValue(true)) { + $expectedResult = $post; + } + } + } + + $method = new \ReflectionMethod( + 'ZfcUser\Controller\RedirectCallback', + 'getRedirectRouteFromRequest' + ); + $method->setAccessible(true); + $result = $method->invoke($this->redirectCallback); + + $this->assertSame($expectedResult, $result); + } + + public function providerGetRedirectRouteFromRequest() + { + return array( + array('user', false, $this->returnValue('route'), false), + array('user', false, $this->returnValue('route'), $this->returnValue(true)), + array('user', 'user', $this->returnValue('route'), $this->returnValue(true)), + array('user', 'user', $this->throwException(new \Zend\Mvc\Router\Exception\RuntimeException), $this->returnValue(true)), + array('user', 'user', $this->throwException(new \Zend\Mvc\Router\Exception\RuntimeException), $this->throwException(new \Zend\Mvc\Router\Exception\RuntimeException)), + array(false, 'user', false, $this->returnValue(true)), + array(false, 'user', false, $this->throwException(new \Zend\Mvc\Router\Exception\RuntimeException)), + array(false, 'user', false, $this->throwException(new \Zend\Mvc\Router\Exception\RuntimeException)), + ); + } + + public function testRouteExistsRouteExists() + { + $route = 'existingRoute'; + + $this->router->expects($this->once()) + ->method('assemble') + ->with(array(), array('name' => $route)); + + $method = new \ReflectionMethod( + 'ZfcUser\Controller\RedirectCallback', + 'routeExists' + ); + $method->setAccessible(true); + $result = $method->invoke($this->redirectCallback, $route); + + $this->assertTrue($result); + } + + public function testRouteExistsRouteDoesntExists() + { + $route = 'existingRoute'; + + $this->router->expects($this->once()) + ->method('assemble') + ->with(array(), array('name' => $route)) + ->will($this->throwException(new \Zend\Mvc\Router\Exception\RuntimeException)); + + $method = new \ReflectionMethod( + 'ZfcUser\Controller\RedirectCallback', + 'routeExists' + ); + $method->setAccessible(true); + $result = $method->invoke($this->redirectCallback, $route); + + $this->assertFalse($result); + } + + /** + * @dataProvider providerGetRedirectNoRedirectParam + */ + public function testGetRedirectNoRedirectParam($currentRoute, $optionsReturn, $expectedResult, $optionsMethod) + { + $this->moduleOptions->expects($this->once()) + ->method('getUseRedirectParameterIfPresent') + ->will($this->returnValue(true)); + + $this->router->expects($this->at(0)) + ->method('assemble'); + $this->router->expects($this->at(1)) + ->method('assemble') + ->with(array(), array('name' => $optionsReturn)) + ->will($this->returnValue($expectedResult)); + + if ($optionsMethod) { + $this->moduleOptions->expects($this->never()) + ->method($optionsMethod) + ->will($this->returnValue($optionsReturn)); + } + $method = new \ReflectionMethod( + 'ZfcUser\Controller\RedirectCallback', + 'getRedirect' + ); + $method->setAccessible(true); + $result = $method->invoke($this->redirectCallback, $currentRoute, $optionsReturn); + + $this->assertSame($expectedResult, $result); + } + + public function providerGetRedirectNoRedirectParam() + { + return array( + array('zfcuser/login', 'zfcuser', '/user', 'getLoginRedirectRoute'), + array('zfcuser/logout', 'zfcuser/login', '/user/login', 'getLogoutRedirectRoute'), + array('testDefault', 'zfcuser', '/home', false), + ); + } + + public function testGetRedirectWithOptionOnButNoRedirect() + { + $route = 'zfcuser/login'; + $redirect = false; + $expectedResult = '/user/login'; + + $this->moduleOptions->expects($this->once()) + ->method('getUseRedirectParameterIfPresent') + ->will($this->returnValue(true)); + + $this->moduleOptions->expects($this->once()) + ->method('getLoginRedirectRoute') + ->will($this->returnValue($route)); + + $this->router->expects($this->once()) + ->method('assemble') + ->with(array(), array('name' => $route)) + ->will($this->returnValue($expectedResult)); + + $method = new \ReflectionMethod( + 'ZfcUser\Controller\RedirectCallback', + 'getRedirect' + ); + $method->setAccessible(true); + $result = $method->invoke($this->redirectCallback, $route, $redirect); + + $this->assertSame($expectedResult, $result); + } + + public function testGetRedirectWithOptionOnRedirectDoesntExists() + { + $route = 'zfcuser/login'; + $redirect = 'doesntExists'; + $expectedResult = '/user/login'; + + $this->moduleOptions->expects($this->once()) + ->method('getUseRedirectParameterIfPresent') + ->will($this->returnValue(true)); + + $this->router->expects($this->at(0)) + ->method('assemble') + ->with(array(), array('name' => $redirect)) + ->will($this->throwException(new \Zend\Mvc\Router\Exception\RuntimeException)); + + $this->router->expects($this->at(1)) + ->method('assemble') + ->with(array(), array('name' => $route)) + ->will($this->returnValue($expectedResult)); + + $this->moduleOptions->expects($this->once()) + ->method('getLoginRedirectRoute') + ->will($this->returnValue($route)); + + $method = new \ReflectionMethod( + 'ZfcUser\Controller\RedirectCallback', + 'getRedirect' + ); + $method->setAccessible(true); + $result = $method->invoke($this->redirectCallback, $route, $redirect); + + $this->assertSame($expectedResult, $result); + } + + private function setUpApplication() + { + $this->request = $this->getMockBuilder('Zend\Http\PhpEnvironment\Request') + ->disableOriginalConstructor() + ->getMock(); + + $this->response = $this->getMockBuilder('Zend\Http\PhpEnvironment\Response') + ->disableOriginalConstructor() + ->getMock(); + + $this->routeMatch = $this->getMockBuilder('Zend\Mvc\Router\RouteMatch') + ->disableOriginalConstructor() + ->getMock(); + + $this->mvcEvent = $this->getMockBuilder('Zend\Mvc\MvcEvent') + ->disableOriginalConstructor() + ->getMock(); + $this->mvcEvent->expects($this->any()) + ->method('getRouteMatch') + ->will($this->returnValue($this->routeMatch)); + + + $this->application->expects($this->any()) + ->method('getMvcEvent') + ->will($this->returnValue($this->mvcEvent)); + $this->application->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($this->request)); + $this->application->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue($this->response)); + } +} diff --git a/tests/ZfcUserTest/Controller/UserControllerTest.php b/tests/ZfcUserTest/Controller/UserControllerTest.php index 95aab0a3..06c20582 100644 --- a/tests/ZfcUserTest/Controller/UserControllerTest.php +++ b/tests/ZfcUserTest/Controller/UserControllerTest.php @@ -2,6 +2,7 @@ namespace ZfcUserTest\Controller; +use ZfcUser\Controller\RedirectCallback; use ZfcUser\Controller\UserController as Controller; use Zend\Http\Response; use Zend\Stdlib\Parameters; @@ -14,7 +15,7 @@ class UserControllerTest extends \PHPUnit_Framework_TestCase { /** - * @var \ZfcUser\Controller\UserController $controller + * @var Controller $controller */ protected $controller; @@ -26,9 +27,18 @@ class UserControllerTest extends \PHPUnit_Framework_TestCase protected $options; + /** + * @var \PHPUnit_Framework_MockObject_MockObject|RedirectCallback + */ + protected $redirectCallback; + public function setUp() { - $controller = new Controller; + $this->redirectCallback = $this->getMockBuilder('ZfcUser\Controller\RedirectCallback') + ->disableOriginalConstructor() + ->getMock(); + + $controller = new Controller($this->redirectCallback); $this->controller = $controller; $this->zfcUserAuthenticationPlugin = $this->getMock('ZfcUser\Controller\Plugin\ZfcUserAuthentication'); @@ -36,8 +46,8 @@ public function setUp() $pluginManager = $this->getMock('Zend\Mvc\Controller\PluginManager', array('get')); $pluginManager->expects($this->any()) - ->method('get') - ->will($this->returnCallback(array($this, 'helperMockCallbackPluginManagerGet'))); + ->method('get') + ->will($this->returnCallback(array($this, 'helperMockCallbackPluginManagerGet'))); $this->pluginManager = $pluginManager; @@ -55,8 +65,8 @@ public function setUpZfcUserAuthenticationPlugin($option) ? $this->returnCallback($option['hasIdentity']) : $this->returnValue($option['hasIdentity']); $this->zfcUserAuthenticationPlugin->expects($this->any()) - ->method('hasIdentity') - ->will($return); + ->method('hasIdentity') + ->will($return); } if (array_key_exists('getAuthAdapter', $option)) { @@ -65,8 +75,8 @@ public function setUpZfcUserAuthenticationPlugin($option) : $this->returnValue($option['getAuthAdapter']); $this->zfcUserAuthenticationPlugin->expects($this->any()) - ->method('getAuthAdapter') - ->will($return); + ->method('getAuthAdapter') + ->will($return); } if (array_key_exists('getAuthService', $option)) { @@ -75,8 +85,8 @@ public function setUpZfcUserAuthenticationPlugin($option) : $this->returnValue($option['getAuthService']); $this->zfcUserAuthenticationPlugin->expects($this->any()) - ->method('getAuthService') - ->will($return); + ->method('getAuthService') + ->will($return); } $this->pluginManagerPlugins['zfcUserAuthentication'] = $this->zfcUserAuthenticationPlugin; @@ -100,21 +110,21 @@ public function testActionControllHasIdentity($methodeName, $hasIdentity, $redir if ($optionGetter) { $this->options->expects($this->once()) - ->method($optionGetter) - ->will($this->returnValue($redirectRoute)); + ->method($optionGetter) + ->will($this->returnValue($redirectRoute)); } $redirect = $this->getMock('Zend\Mvc\Controller\Plugin\Redirect'); $redirect->expects($this->once()) - ->method('toRoute') - ->with($redirectRoute) - ->will($this->returnValue($response)); + ->method('toRoute') + ->with($redirectRoute) + ->will($this->returnValue($response)); $this->pluginManagerPlugins['redirect']= $redirect; $result = call_user_func(array($controller, $methodeName)); - $this->assertInstanceOf('\Zend\Http\Response', $result); + $this->assertInstanceOf('Zend\Http\Response', $result); $this->assertSame($response, $result); } @@ -141,7 +151,7 @@ public function testIndexActionLoggedIn() public function testLoginActionValidFormRedirectFalse($isValid, $wantRedirect) { $controller = $this->controller; - $redirectUrl = 'http://localhost/redirect1'; + $redirectUrl = 'localhost/redirect1'; $plugin = $this->setUpZfcUserAuthenticationPlugin(array( 'hasIdentity'=>false @@ -153,58 +163,58 @@ public function testLoginActionValidFormRedirectFalse($isValid, $wantRedirect) $this->pluginManagerPlugins['flashMessenger']= $flashMessenger; $flashMessenger->expects($this->any()) - ->method('setNamespace') - ->with('zfcuser-login-form') - ->will($this->returnSelf()); + ->method('setNamespace') + ->with('zfcuser-login-form') + ->will($this->returnSelf()); $flashMessenger->expects($this->once()) - ->method('getMessages') - ->will($this->returnValue(array())); + ->method('getMessages') + ->will($this->returnValue(array())); $flashMessenger->expects($this->any()) - ->method('addMessage') - ->will($this->returnSelf()); + ->method('addMessage') + ->will($this->returnSelf()); $postArray = array('some', 'data'); $request = $this->getMock('Zend\Http\Request'); $request->expects($this->any()) - ->method('isPost') - ->will($this->returnValue(true)); + ->method('isPost') + ->will($this->returnValue(true)); $request->expects($this->any()) - ->method('getPost') - ->will($this->returnValue($postArray)); + ->method('getPost') + ->will($this->returnValue($postArray)); $this->helperMakePropertyAccessable($controller, 'request', $request); $form = $this->getMockBuilder('ZfcUser\Form\Login') - ->disableOriginalConstructor() - ->getMock(); + ->disableOriginalConstructor() + ->getMock(); $form->expects($this->any()) - ->method('isValid') - ->will($this->returnValue((bool) $isValid)); + ->method('isValid') + ->will($this->returnValue((bool) $isValid)); $this->options->expects($this->any()) - ->method('getUseRedirectParameterIfPresent') - ->will($this->returnValue((bool) $wantRedirect)); + ->method('getUseRedirectParameterIfPresent') + ->will($this->returnValue((bool) $wantRedirect)); if ($wantRedirect) { $params = new Parameters(); $params->set('redirect', $redirectUrl); $request->expects($this->any()) - ->method('getQuery') - ->will($this->returnValue($params)); + ->method('getQuery') + ->will($this->returnValue($params)); } if ($isValid) { $adapter = $this->getMock('ZfcUser\Authentication\Adapter\AdapterChain'); $adapter->expects($this->once()) - ->method('resetAdapters'); + ->method('resetAdapters'); $service = $this->getMock('Zend\Authentication\AuthenticationService'); $service->expects($this->once()) - ->method('clearIdentity'); + ->method('clearIdentity'); $plugin = $this->setUpZfcUserAuthenticationPlugin(array( 'getAuthAdapter'=>$adapter, @@ -212,18 +222,18 @@ public function testLoginActionValidFormRedirectFalse($isValid, $wantRedirect) )); $form->expects($this->once()) - ->method('setData') - ->with($postArray); + ->method('setData') + ->with($postArray); $expectedResult = new \stdClass(); $forwardPlugin = $this->getMockBuilder('Zend\Mvc\Controller\Plugin\Forward') - ->disableOriginalConstructor() - ->getMock(); + ->disableOriginalConstructor() + ->getMock(); $forwardPlugin->expects($this->once()) - ->method('dispatch') - ->with($controller::CONTROLLER_NAME, array('action' => 'authenticate')) - ->will($this->returnValue($expectedResult)); + ->method('dispatch') + ->with($controller::CONTROLLER_NAME, array('action' => 'authenticate')) + ->will($this->returnValue($expectedResult)); $this->pluginManagerPlugins['forward']= $forwardPlugin; @@ -236,14 +246,14 @@ public function testLoginActionValidFormRedirectFalse($isValid, $wantRedirect) $redirect = $this->getMock('Zend\Mvc\Controller\Plugin\Redirect', array('toUrl')); $redirect->expects($this->any()) - ->method('toUrl') - ->with($route_url . $redirectQuery) - ->will($this->returnCallback(function ($url) use (&$response) { - $response->getHeaders()->addHeaderLine('Location', $url); - $response->setStatusCode(302); + ->method('toUrl') + ->with($route_url . $redirectQuery) + ->will($this->returnCallback(function ($url) use (&$response) { + $response->getHeaders()->addHeaderLine('Location', $url); + $response->setStatusCode(302); - return $response; - })); + return $response; + })); $this->pluginManagerPlugins['redirect']= $redirect; @@ -251,9 +261,9 @@ public function testLoginActionValidFormRedirectFalse($isValid, $wantRedirect) $response = new Response(); $url = $this->getMock('Zend\Mvc\Controller\Plugin\Url', array('fromRoute')); $url->expects($this->once()) - ->method('fromRoute') - ->with($controller::ROUTE_LOGIN) - ->will($this->returnValue($route_url)); + ->method('fromRoute') + ->with($controller::ROUTE_LOGIN) + ->will($this->returnValue($route_url)); $this->pluginManagerPlugins['url']= $url; $TEST = true; @@ -266,7 +276,7 @@ public function testLoginActionValidFormRedirectFalse($isValid, $wantRedirect) if ($isValid) { $this->assertSame($expectedResult, $result); } else { - $this->assertInstanceOf('\Zend\Http\Response', $result); + $this->assertInstanceOf('Zend\Http\Response', $result); $this->assertEquals($response, $result); $this->assertEquals($route_url . $redirectQuery, $result->getHeaders()->get('Location')->getFieldValue()); } @@ -284,35 +294,35 @@ public function testLoginActionIsNotPost($redirect) $flashMessenger = $this->getMock('Zend\Mvc\Controller\Plugin\FlashMessenger'); $flashMessenger->expects($this->once()) - ->method('setNamespace') - ->with('zfcuser-login-form') - ->will($this->returnSelf()); + ->method('setNamespace') + ->with('zfcuser-login-form') + ->will($this->returnSelf()); $this->pluginManagerPlugins['flashMessenger']= $flashMessenger; $request = $this->getMock('Zend\Http\Request'); $request->expects($this->once()) - ->method('isPost') - ->will($this->returnValue(false)); + ->method('isPost') + ->will($this->returnValue(false)); $form = $this->getMockBuilder('ZfcUser\Form\Login') - ->disableOriginalConstructor() - ->getMock(); + ->disableOriginalConstructor() + ->getMock(); $form->expects($this->never()) - ->method('isValid'); + ->method('isValid'); $this->options->expects($this->any()) - ->method('getUseRedirectParameterIfPresent') - ->will($this->returnValue((bool) $redirect)); + ->method('getUseRedirectParameterIfPresent') + ->will($this->returnValue((bool) $redirect)); if ($redirect) { $params = new Parameters(); $params->set('redirect', 'http://localhost/'); $request->expects($this->any()) - ->method('getQuery') - ->will($this->returnValue($params)); + ->method('getQuery') + ->will($this->returnValue($params)); } $this->helperMakePropertyAccessable($this->controller, 'request', $request); @@ -324,7 +334,7 @@ public function testLoginActionIsNotPost($redirect) $this->assertArrayHasKey('redirect', $result); $this->assertArrayHasKey('enableRegistration', $result); - $this->assertInstanceOf('\ZfcUser\Form\Login', $result['loginForm']); + $this->assertInstanceOf('ZfcUser\Form\Login', $result['loginForm']); $this->assertSame($form, $result['loginForm']); if ($redirect) { @@ -347,14 +357,14 @@ public function testLogoutAction($withRedirect, $post, $query) $adapter = $this->getMock('ZfcUser\Authentication\Adapter\AdapterChain'); $adapter->expects($this->once()) - ->method('resetAdapters'); + ->method('resetAdapters'); $adapter->expects($this->once()) - ->method('logoutAdapters'); + ->method('logoutAdapters'); $service = $this->getMock('Zend\Authentication\AuthenticationService'); $service->expects($this->once()) - ->method('clearIdentity'); + ->method('clearIdentity'); $this->setUpZfcUserAuthenticationPlugin(array( 'getAuthAdapter'=>$adapter, @@ -362,57 +372,23 @@ public function testLogoutAction($withRedirect, $post, $query) )); - $params = $this->getMock('\Zend\Mvc\Controller\Plugin\Params'); - $params->expects($this->any()) - ->method('__invoke') - ->will($this->returnSelf()); - $params->expects($this->once()) - ->method('fromPost') - ->will($this->returnCallback(function ($key, $default) use ($post) { - return $post ?: $default; - })); - $params->expects($this->once()) - ->method('fromQuery') - ->will($this->returnCallback(function ($key, $default) use ($query) { - return $query ?: $default; - })); - $this->pluginManagerPlugins['params'] = $params; - $response = new Response(); - $redirect = $this->getMock('Zend\Mvc\Controller\Plugin\Redirect'); - $redirect->expects($this->any()) - ->method('toRoute') - ->will($this->returnValue($response)); - - if ($withRedirect) { - $expectedLocation = $post ?: $query ?: false; - $this->options->expects($this->once()) - ->method('getUseRedirectParameterIfPresent') - ->will($this->returnValue((bool) $withRedirect)); - $redirect->expects($this->any()) - ->method('toRoute') - ->with($expectedLocation) - ->will($this->returnValue($response)); - } else { - $expectedLocation = "/user/logout"; - $this->options->expects($this->once()) - ->method('getLogoutRedirectRoute') - ->will($this->returnValue($expectedLocation)); - $redirect->expects($this->any()) - ->method('toRoute') - ->with($expectedLocation) - ->will($this->returnValue($response)); - } - - $this->pluginManagerPlugins['redirect']= $redirect; + $this->redirectCallback->expects($this->once()) + ->method('__invoke') + ->will($this->returnValue($response)); $result = $controller->logoutAction(); - $this->assertInstanceOf('\Zend\Http\Response', $result); + $this->assertInstanceOf('Zend\Http\Response', $result); $this->assertSame($response, $result); } + public function testLoginRedirectFailsWithUrl() + { + + } + /** * @dataProvider providerTestAuthenticateAction * @depend testActionControllHasIdentity @@ -423,20 +399,20 @@ public function testAuthenticateAction($wantRedirect, $post, $query, $prepareRes $response = new Response(); $hasRedirect = !(is_null($query) && is_null($post)); - $params = $this->getMock('\Zend\Mvc\Controller\Plugin\Params'); + $params = $this->getMock('Zend\Mvc\Controller\Plugin\Params'); $params->expects($this->any()) - ->method('__invoke') - ->will($this->returnSelf()); + ->method('__invoke') + ->will($this->returnSelf()); $params->expects($this->once()) - ->method('fromPost') - ->will($this->returnCallback(function ($key, $default) use ($post) { - return $post ?: $default; - })); + ->method('fromPost') + ->will($this->returnCallback(function ($key, $default) use ($post) { + return $post ?: $default; + })); $params->expects($this->once()) - ->method('fromQuery') - ->will($this->returnCallback(function ($key, $default) use ($query) { - return $query ?: $default; - })); + ->method('fromQuery') + ->will($this->returnCallback(function ($key, $default) use ($query) { + return $query ?: $default; + })); $this->pluginManagerPlugins['params'] = $params; @@ -446,9 +422,9 @@ public function testAuthenticateAction($wantRedirect, $post, $query, $prepareRes $adapter = $this->getMock('ZfcUser\Authentication\Adapter\AdapterChain'); $adapter->expects($this->once()) - ->method('prepareForAuthentication') - ->with($request) - ->will($this->returnValue($prepareResult)); + ->method('prepareForAuthentication') + ->with($request) + ->will($this->returnValue($prepareResult)); $service = $this->getMock('Zend\Authentication\AuthenticationService'); @@ -461,17 +437,17 @@ public function testAuthenticateAction($wantRedirect, $post, $query, $prepareRes if (is_bool($prepareResult)) { - $authResult = $this->getMockBuilder('\Zend\Authentication\Result') - ->disableOriginalConstructor() - ->getMock(); + $authResult = $this->getMockBuilder('Zend\Authentication\Result') + ->disableOriginalConstructor() + ->getMock(); $authResult->expects($this->once()) - ->method('isValid') - ->will($this->returnValue($authValid)); + ->method('isValid') + ->will($this->returnValue($authValid)); $service->expects($this->once()) - ->method('authenticate') - ->with($adapter) - ->will($this->returnValue($authResult)); + ->method('authenticate') + ->with($adapter) + ->will($this->returnValue($authResult)); $redirect = $this->getMock('Zend\Mvc\Controller\Plugin\Redirect'); $this->pluginManagerPlugins['redirect'] = $redirect; @@ -483,23 +459,23 @@ public function testAuthenticateAction($wantRedirect, $post, $query, $prepareRes $this->pluginManagerPlugins['flashMessenger']= $flashMessenger; $flashMessenger->expects($this->once()) - ->method('setNamespace') - ->with('zfcuser-login-form') - ->will($this->returnSelf()); + ->method('setNamespace') + ->with('zfcuser-login-form') + ->will($this->returnSelf()); $flashMessenger->expects($this->once()) - ->method('addMessage'); + ->method('addMessage'); $adapter->expects($this->once()) - ->method('resetAdapters'); + ->method('resetAdapters'); $redirectQuery = ($post ?: $query ?: false); $redirectQuery = $redirectQuery ? '?redirect=' . rawurlencode($redirectQuery) : ''; $redirect->expects($this->once()) - ->method('toUrl') - ->with('user/login' . $redirectQuery) - ->will($this->returnValue($response)); + ->method('toUrl') + ->with('user/login' . $redirectQuery) + ->will($this->returnValue($response)); $url = $this->getMock('Zend\Mvc\Controller\Plugin\Url'); $url->expects($this->once()) @@ -508,26 +484,14 @@ public function testAuthenticateAction($wantRedirect, $post, $query, $prepareRes ->will($this->returnValue('user/login')); $this->pluginManagerPlugins['url'] = $url; - } elseif ($wantRedirect && $hasRedirect) { - $redirect->expects($this->once()) - ->method('toRoute') - ->with(($post ?: $query ?: false)) - ->will($this->returnValue($response)); } else { - - $redirect->expects($this->once()) - ->method('toRoute') - ->with('zfcuser') - ->will($this->returnValue($response)); - - $this->options->expects($this->once()) - ->method('getLoginRedirectRoute') - ->will($this->returnValue('zfcuser')); + $this->redirectCallback->expects($this->once()) + ->method('__invoke'); } $this->options->expects($this->any()) - ->method('getUseRedirectParameterIfPresent') - ->will($this->returnValue((bool) $wantRedirect)); + ->method('getUseRedirectParameterIfPresent') + ->will($this->returnValue((bool) $wantRedirect)); } @@ -549,8 +513,8 @@ public function testRegisterActionIsNotAllowed() )); $this->options->expects($this->once()) - ->method('getEnableRegistration') - ->will($this->returnValue(false)); + ->method('getEnableRegistration') + ->will($this->returnValue(false)); $result = $controller->registerAction(); @@ -568,7 +532,7 @@ public function testRegisterActionIsNotAllowed() public function testRegisterAction($wantRedirect, $postRedirectGetReturn, $registerSuccess, $loginAfterSuccessWith) { $controller = $this->controller; - $redirectUrl = 'http://localhost/redirect1'; + $redirectUrl = 'localhost/redirect1'; $route_url = '/user/register'; $expectedResult = null; @@ -577,32 +541,32 @@ public function testRegisterAction($wantRedirect, $postRedirectGetReturn, $regis )); $this->options->expects($this->any()) - ->method('getEnableRegistration') - ->will($this->returnValue(true)); + ->method('getEnableRegistration') + ->will($this->returnValue(true)); $request = $this->getMock('Zend\Http\Request'); $this->helperMakePropertyAccessable($controller, 'request', $request); - $userService = $this->getMock('\ZfcUser\Service\User'); + $userService = $this->getMock('ZfcUser\Service\User'); $controller->setUserService($userService); - $form = $this->getMockBuilder('\Zend\Form\Form') - ->disableOriginalConstructor() - ->getMock(); + $form = $this->getMockBuilder('Zend\Form\Form') + ->disableOriginalConstructor() + ->getMock(); $controller->setRegisterForm($form); $this->options->expects($this->any()) - ->method('getUseRedirectParameterIfPresent') - ->will($this->returnValue((bool) $wantRedirect)); + ->method('getUseRedirectParameterIfPresent') + ->will($this->returnValue((bool) $wantRedirect)); if ($wantRedirect) { $params = new Parameters(); $params->set('redirect', $redirectUrl); $request->expects($this->any()) - ->method('getQuery') - ->will($this->returnValue($params)); + ->method('getQuery') + ->will($this->returnValue($params)); } @@ -614,7 +578,7 @@ public function testRegisterAction($wantRedirect, $postRedirectGetReturn, $regis $this->pluginManagerPlugins['url']= $url; - $prg = $this->getMock('\Zend\Mvc\Controller\Plugin\PostRedirectGet'); + $prg = $this->getMock('Zend\Mvc\Controller\Plugin\PostRedirectGet'); $this->pluginManagerPlugins['prg'] = $prg; $redirectQuery = $wantRedirect ? '?redirect=' . rawurlencode($redirectUrl) : ''; @@ -629,32 +593,32 @@ public function testRegisterAction($wantRedirect, $postRedirectGetReturn, $regis $user->setUsername('zfc-user'); $userService->expects($this->once()) - ->method('register') - ->with($postRedirectGetReturn) - ->will($this->returnValue($user)); + ->method('register') + ->with($postRedirectGetReturn) + ->will($this->returnValue($user)); $userService->expects($this->any()) - ->method('getOptions') - ->will($this->returnValue($this->options)); + ->method('getOptions') + ->will($this->returnValue($this->options)); $this->options->expects($this->once()) - ->method('getLoginAfterRegistration') - ->will($this->returnValue(!empty($loginAfterSuccessWith))); + ->method('getLoginAfterRegistration') + ->will($this->returnValue(!empty($loginAfterSuccessWith))); if ($loginAfterSuccessWith) { $this->options->expects($this->once()) - ->method('getAuthIdentityFields') - ->will($this->returnValue(array($loginAfterSuccessWith))); + ->method('getAuthIdentityFields') + ->will($this->returnValue(array($loginAfterSuccessWith))); $expectedResult = new \stdClass(); $forwardPlugin = $this->getMockBuilder('Zend\Mvc\Controller\Plugin\Forward') - ->disableOriginalConstructor() - ->getMock(); + ->disableOriginalConstructor() + ->getMock(); $forwardPlugin->expects($this->once()) - ->method('dispatch') - ->with($controller::CONTROLLER_NAME, array('action' => 'authenticate')) - ->will($this->returnValue($expectedResult)); + ->method('dispatch') + ->with($controller::CONTROLLER_NAME, array('action' => 'authenticate')) + ->will($this->returnValue($expectedResult)); $this->pluginManagerPlugins['forward']= $forwardPlugin; } else { @@ -669,9 +633,9 @@ public function testRegisterAction($wantRedirect, $postRedirectGetReturn, $regis $redirect = $this->getMock('Zend\Mvc\Controller\Plugin\Redirect'); $redirect->expects($this->once()) - ->method('toUrl') - ->with($route_url . $redirectQuery) - ->will($this->returnValue($response)); + ->method('toUrl') + ->with($route_url . $redirectQuery) + ->will($this->returnValue($response)); $this->pluginManagerPlugins['redirect']= $redirect; @@ -725,7 +689,7 @@ public function testRegisterAction($wantRedirect, $postRedirectGetReturn, $regis $this->assertArrayHasKey('redirect', $result); $this->assertEquals($expectedResult, $result); } else { - $this->assertInstanceOf('\Zend\Http\Response', $result); + $this->assertInstanceOf('Zend\Http\Response', $result); $this->assertSame($response, $result); } } @@ -744,9 +708,9 @@ public function testChangepasswordAction($status, $postRedirectGetReturn, $isVal 'hasIdentity'=>true )); - $form = $this->getMockBuilder('\Zend\Form\Form') - ->disableOriginalConstructor() - ->getMock(); + $form = $this->getMockBuilder('Zend\Form\Form') + ->disableOriginalConstructor() + ->getMock(); $controller->setChangePasswordForm($form); @@ -758,16 +722,16 @@ public function testChangepasswordAction($status, $postRedirectGetReturn, $isVal $this->pluginManagerPlugins['flashMessenger']= $flashMessenger; $flashMessenger->expects($this->any()) - ->method('setNamespace') - ->with('change-password') - ->will($this->returnSelf()); + ->method('setNamespace') + ->with('change-password') + ->will($this->returnSelf()); $flashMessenger->expects($this->once()) - ->method('getMessages') - ->will($this->returnValue($status ? array('test') : array())); + ->method('getMessages') + ->will($this->returnValue($status ? array('test') : array())); - $prg = $this->getMock('\Zend\Mvc\Controller\Plugin\PostRedirectGet'); + $prg = $this->getMock('Zend\Mvc\Controller\Plugin\PostRedirectGet'); $this->pluginManagerPlugins['prg'] = $prg; @@ -779,39 +743,39 @@ public function testChangepasswordAction($status, $postRedirectGetReturn, $isVal if ($postRedirectGetReturn !== false && !($postRedirectGetReturn instanceof Response)) { $form->expects($this->once()) - ->method('setData') - ->with($postRedirectGetReturn); + ->method('setData') + ->with($postRedirectGetReturn); $form->expects($this->once()) - ->method('isValid') - ->will($this->returnValue((bool) $isValid)); + ->method('isValid') + ->will($this->returnValue((bool) $isValid)); if ($isValid) { - $userService = $this->getMock('\ZfcUser\Service\User'); + $userService = $this->getMock('ZfcUser\Service\User'); $controller->setUserService($userService); $form->expects($this->once()) - ->method('getData') - ->will($this->returnValue($postRedirectGetReturn)); + ->method('getData') + ->will($this->returnValue($postRedirectGetReturn)); $userService->expects($this->once()) - ->method('changePassword') - ->with($postRedirectGetReturn) - ->will($this->returnValue((bool) $changeSuccess)); + ->method('changePassword') + ->with($postRedirectGetReturn) + ->will($this->returnValue((bool) $changeSuccess)); if ($changeSuccess) { $flashMessenger->expects($this->once()) - ->method('addMessage') - ->with(true); + ->method('addMessage') + ->with(true); $redirect = $this->getMock('Zend\Mvc\Controller\Plugin\Redirect'); $redirect->expects($this->once()) - ->method('toRoute') - ->with($controller::ROUTE_CHANGEPASSWD) - ->will($this->returnValue($response)); + ->method('toRoute') + ->with($controller::ROUTE_CHANGEPASSWD) + ->will($this->returnValue($response)); $this->pluginManagerPlugins['redirect']= $redirect; } @@ -823,7 +787,7 @@ public function testChangepasswordAction($status, $postRedirectGetReturn, $isVal $exceptedReturn = null; if ($postRedirectGetReturn instanceof Response) { - $this->assertInstanceOf('\Zend\Http\Response', $result); + $this->assertInstanceOf('Zend\Http\Response', $result); $this->assertSame($postRedirectGetReturn, $result); } else { @@ -844,7 +808,7 @@ public function testChangepasswordAction($status, $postRedirectGetReturn, $isVal $this->assertArrayHasKey('changePasswordForm', $result); $this->assertEquals($exceptedReturn, $result); } else { - $this->assertInstanceOf('\Zend\Http\Response', $result); + $this->assertInstanceOf('Zend\Http\Response', $result); $this->assertSame($response, $result); } } @@ -859,8 +823,8 @@ public function testChangeEmailAction($status, $postRedirectGetReturn, $isValid, { $controller = $this->controller; $response = new Response(); - $userService = $this->getMock('\ZfcUser\Service\User'); - $authService = $this->getMock('\Zend\Authentication\AuthenticationService'); + $userService = $this->getMock('ZfcUser\Service\User'); + $authService = $this->getMock('Zend\Authentication\AuthenticationService'); $identity = new UserIdentity(); $controller->setUserService($userService); @@ -869,31 +833,31 @@ public function testChangeEmailAction($status, $postRedirectGetReturn, $isValid, 'hasIdentity'=>true )); - $form = $this->getMockBuilder('\Zend\Form\Form') - ->disableOriginalConstructor() - ->getMock(); + $form = $this->getMockBuilder('Zend\Form\Form') + ->disableOriginalConstructor() + ->getMock(); $controller->setChangeEmailForm($form); $userService->expects($this->once()) - ->method('getAuthService') - ->will($this->returnValue($authService)); + ->method('getAuthService') + ->will($this->returnValue($authService)); $authService->expects($this->once()) - ->method('getIdentity') - ->will($this->returnValue($identity)); + ->method('getIdentity') + ->will($this->returnValue($identity)); $identity->setEmail('user@example.com'); - $requestParams = $this->getMock('\Zend\Stdlib\Parameters'); + $requestParams = $this->getMock('Zend\Stdlib\Parameters'); $requestParams->expects($this->once()) - ->method('set') - ->with('identity', $identity->getEmail()); + ->method('set') + ->with('identity', $identity->getEmail()); - $request = $this->getMock('\Zend\Http\Request'); + $request = $this->getMock('Zend\Http\Request'); $request->expects($this->once()) - ->method('getPost') - ->will($this->returnValue($requestParams)); + ->method('getPost') + ->will($this->returnValue($requestParams)); $this->helperMakePropertyAccessable($controller, 'request', $request); @@ -904,16 +868,16 @@ public function testChangeEmailAction($status, $postRedirectGetReturn, $isValid, $this->pluginManagerPlugins['flashMessenger']= $flashMessenger; $flashMessenger->expects($this->any()) - ->method('setNamespace') - ->with('change-email') - ->will($this->returnSelf()); + ->method('setNamespace') + ->with('change-email') + ->will($this->returnSelf()); $flashMessenger->expects($this->once()) - ->method('getMessages') - ->will($this->returnValue($status ? array('test') : array())); + ->method('getMessages') + ->will($this->returnValue($status ? array('test') : array())); - $prg = $this->getMock('\Zend\Mvc\Controller\Plugin\PostRedirectGet'); + $prg = $this->getMock('Zend\Mvc\Controller\Plugin\PostRedirectGet'); $this->pluginManagerPlugins['prg'] = $prg; @@ -925,38 +889,38 @@ public function testChangeEmailAction($status, $postRedirectGetReturn, $isValid, if ($postRedirectGetReturn !== false && !($postRedirectGetReturn instanceof Response)) { $form->expects($this->once()) - ->method('setData') - ->with($postRedirectGetReturn); + ->method('setData') + ->with($postRedirectGetReturn); $form->expects($this->once()) - ->method('isValid') - ->will($this->returnValue((bool) $isValid)); + ->method('isValid') + ->will($this->returnValue((bool) $isValid)); if ($isValid) { $userService->expects($this->once()) - ->method('changeEmail') - ->with($postRedirectGetReturn) - ->will($this->returnValue((bool) $changeSuccess)); + ->method('changeEmail') + ->with($postRedirectGetReturn) + ->will($this->returnValue((bool) $changeSuccess)); if ($changeSuccess) { $flashMessenger->expects($this->once()) - ->method('addMessage') - ->with(true); + ->method('addMessage') + ->with(true); $redirect = $this->getMock('Zend\Mvc\Controller\Plugin\Redirect'); $redirect->expects($this->once()) - ->method('toRoute') - ->with($controller::ROUTE_CHANGEEMAIL) - ->will($this->returnValue($response)); + ->method('toRoute') + ->with($controller::ROUTE_CHANGEEMAIL) + ->will($this->returnValue($response)); $this->pluginManagerPlugins['redirect']= $redirect; } else { $flashMessenger->expects($this->once()) - ->method('addMessage') - ->with(false); + ->method('addMessage') + ->with(false); } } } @@ -966,7 +930,7 @@ public function testChangeEmailAction($status, $postRedirectGetReturn, $isValid, $exceptedReturn = null; if ($postRedirectGetReturn instanceof Response) { - $this->assertInstanceOf('\Zend\Http\Response', $result); + $this->assertInstanceOf('Zend\Http\Response', $result); $this->assertSame($postRedirectGetReturn, $result); } else { @@ -988,7 +952,7 @@ public function testChangeEmailAction($status, $postRedirectGetReturn, $isValid, $this->assertArrayHasKey('changeEmailForm', $result); $this->assertEquals($exceptedReturn, $result); } else { - $this->assertInstanceOf('\Zend\Http\Response', $result); + $this->assertInstanceOf('Zend\Http\Response', $result); $this->assertSame($response, $result); } } @@ -1005,7 +969,7 @@ public function testSetterGetterServices( $serviceName, $callback = null ) { - $controller = new Controller; + $controller = new Controller($this->redirectCallback); $controller->setPluginManager($this->pluginManager); @@ -1018,11 +982,11 @@ public function testSetterGetterServices( if ($useServiceLocator) { - $serviceLocator = $this->getMock('\Zend\ServiceManager\ServiceLocatorInterface'); + $serviceLocator = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface'); $serviceLocator->expects($this->once()) - ->method('get') - ->with($serviceName) - ->will($this->returnValue($servicePrototype)); + ->method('get') + ->with($serviceName) + ->will($this->returnValue($servicePrototype)); $controller->setServiceLocator($serviceLocator); } else { @@ -1103,13 +1067,13 @@ public function providerTestSetterGetterServices () $that->pluginManagerPlugins['flashMessenger']= $flashMessenger; $flashMessenger->expects($that->any()) - ->method('setNamespace') - ->with('zfcuser-login-form') - ->will($that->returnSelf()); + ->method('setNamespace') + ->with('zfcuser-login-form') + ->will($that->returnSelf()); $flashMessenger->expects($that->once()) - ->method('getMessages') - ->will($that->returnValue(array())); + ->method('getMessages') + ->will($that->returnValue(array())); }; $loginFormCallback[] = function ($that, $controller) { $flashMessenger = $that->getMock( @@ -1118,13 +1082,13 @@ public function providerTestSetterGetterServices () $that->pluginManagerPlugins['flashMessenger']= $flashMessenger; $flashMessenger->expects($that->any()) - ->method('setNamespace') - ->with('zfcuser-login-form') - ->will($that->returnSelf()); + ->method('setNamespace') + ->with('zfcuser-login-form') + ->will($that->returnSelf()); $flashMessenger->expects($that->once()) - ->method('getMessages') - ->will($that->returnValue(array("message1","message2"))); + ->method('getMessages') + ->will($that->returnValue(array("message1","message2"))); }; From d1b7b94da99f7fe692805adbb25b628320e7d75f Mon Sep 17 00:00:00 2001 From: Danielss89 Date: Thu, 3 Jul 2014 16:09:13 +0200 Subject: [PATCH 03/59] Convert short array to long array --- src/ZfcUser/Controller/RedirectCallback.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ZfcUser/Controller/RedirectCallback.php b/src/ZfcUser/Controller/RedirectCallback.php index a57449d9..c3ed6d71 100644 --- a/src/ZfcUser/Controller/RedirectCallback.php +++ b/src/ZfcUser/Controller/RedirectCallback.php @@ -77,7 +77,7 @@ protected function getRedirectRouteFromRequest() protected function routeExists($route) { try { - $this->router->assemble([], ['name' => $route]); + $this->router->assemble(array(), array('name' => $route)); } catch (Exception\RuntimeException $e) { return false; } @@ -103,14 +103,14 @@ protected function getRedirect($currentRoute, $redirect = false) switch ($currentRoute) { case 'zfcuser/login': $route = ($redirect) ?: $this->options->getLoginRedirectRoute(); - return $this->router->assemble([], ['name' => $route]); + return $this->router->assemble(array(), array('name' => $route)); break; case 'zfcuser/logout': $route = ($redirect) ?: $this->options->getLogoutRedirectRoute(); - return $this->router->assemble([], ['name' => $route]); + return $this->router->assemble(array(), array('name' => $route)); break; default: - return $this->router->assemble([], ['name' => 'zfcuser']); + return $this->router->assemble(array(), array('name' => 'zfcuser')); } } } From b59b674d83406342d42052209e1c7975fd9a1919 Mon Sep 17 00:00:00 2001 From: Danielss89 Date: Thu, 3 Jul 2014 16:33:55 +0200 Subject: [PATCH 04/59] Fix config alignment --- config/module.config.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/config/module.config.php b/config/module.config.php index c74c4be2..cac5fab9 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -10,18 +10,18 @@ 'controllers' => array( 'factories' => array( - 'zfcuser' => function($controllerManager){ - /* @var ControllerManager $controllerManager*/ - $serviceManager = $controllerManager->getServiceLocator(); + 'zfcuser' => function($controllerManager) { + /* @var ControllerManager $controllerManager*/ + $serviceManager = $controllerManager->getServiceLocator(); - /* @var RedirectCallback $redirectCallback */ - $redirectCallback = $serviceManager->get('zfcuser_redirect_callback'); + /* @var RedirectCallback $redirectCallback */ + $redirectCallback = $serviceManager->get('zfcuser_redirect_callback'); - /* @var UserController $controller */ - $controller = new UserController($redirectCallback); + /* @var UserController $controller */ + $controller = new UserController($redirectCallback); - return $controller; - }, + return $controller; + }, ), ), 'service_manager' => array( From 6d26b6b101d992d734ce7e7883f011ed14185f37 Mon Sep 17 00:00:00 2001 From: Danielss89 Date: Thu, 3 Jul 2014 16:42:37 +0200 Subject: [PATCH 05/59] Change methods visibility --- src/ZfcUser/Controller/RedirectCallback.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ZfcUser/Controller/RedirectCallback.php b/src/ZfcUser/Controller/RedirectCallback.php index c3ed6d71..5791892c 100644 --- a/src/ZfcUser/Controller/RedirectCallback.php +++ b/src/ZfcUser/Controller/RedirectCallback.php @@ -9,7 +9,7 @@ use ZfcUser\Options\ModuleOptions; /** - * Returns a redirect response based on the current routing and parameters + * Buils a redirect response based on the current routing and parameters */ class RedirectCallback { @@ -54,7 +54,7 @@ public function __invoke() * First checks GET then POST * @return string */ - protected function getRedirectRouteFromRequest() + private function getRedirectRouteFromRequest() { $request = $this->application->getRequest(); $redirect = $request->getQuery('redirect'); @@ -74,7 +74,7 @@ protected function getRedirectRouteFromRequest() * @param $route * @return bool */ - protected function routeExists($route) + private function routeExists($route) { try { $this->router->assemble(array(), array('name' => $route)); @@ -92,7 +92,7 @@ protected function routeExists($route) * @param bool $redirect * @return mixed */ - protected function getRedirect($currentRoute, $redirect = false) + private function getRedirect($currentRoute, $redirect = false) { $useRedirect = $this->options->getUseRedirectParameterIfPresent(); $routeExists = ($redirect && $this->routeExists($redirect)); From 69e8d572536eb24349fd69db1d7aab264fd9a8c3 Mon Sep 17 00:00:00 2001 From: Rob Shipley Date: Wed, 9 Jul 2014 10:47:56 +0100 Subject: [PATCH 06/59] Changing the getRedirect function to protected as I need to extend the class at this point. Use Case: I have a guest login system which uses a separate route to login (zfcuser/guest) and the redirect plug-in is looking explicitly for zfcuser/login to do a redirect. I want to extend the RedirectCallback class with my own which does a check for the login/guest route, set the $currentRoute variable to zfcuser/login then call the parent function. No code duplication. At the moment it requires the entire class to be coppied/pasted to achieve the same functionality. --- src/ZfcUser/Controller/RedirectCallback.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ZfcUser/Controller/RedirectCallback.php b/src/ZfcUser/Controller/RedirectCallback.php index 5791892c..f4e05474 100644 --- a/src/ZfcUser/Controller/RedirectCallback.php +++ b/src/ZfcUser/Controller/RedirectCallback.php @@ -92,7 +92,7 @@ private function routeExists($route) * @param bool $redirect * @return mixed */ - private function getRedirect($currentRoute, $redirect = false) + protected function getRedirect($currentRoute, $redirect = false) { $useRedirect = $this->options->getUseRedirectParameterIfPresent(); $routeExists = ($redirect && $this->routeExists($redirect)); From b14785a6aa23e2d3052e28d781d193394169700e Mon Sep 17 00:00:00 2001 From: Malte Gerth Date: Wed, 9 Jul 2014 12:32:08 +0200 Subject: [PATCH 07/59] pass changePassword and changeEmail data to event --- src/ZfcUser/Service/User.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ZfcUser/Service/User.php b/src/ZfcUser/Service/User.php index 295fec6c..d32a8d35 100644 --- a/src/ZfcUser/Service/User.php +++ b/src/ZfcUser/Service/User.php @@ -123,9 +123,9 @@ public function changePassword(array $data) $pass = $bcrypt->create($newPass); $currentUser->setPassword($pass); - $this->getEventManager()->trigger(__FUNCTION__, $this, array('user' => $currentUser)); + $this->getEventManager()->trigger(__FUNCTION__, $this, array('user' => $currentUser, 'data' => $data)); $this->getUserMapper()->update($currentUser); - $this->getEventManager()->trigger(__FUNCTION__.'.post', $this, array('user' => $currentUser)); + $this->getEventManager()->trigger(__FUNCTION__.'.post', $this, array('user' => $currentUser, 'data' => $data)); return true; } @@ -143,9 +143,9 @@ public function changeEmail(array $data) $currentUser->setEmail($data['newIdentity']); - $this->getEventManager()->trigger(__FUNCTION__, $this, array('user' => $currentUser)); + $this->getEventManager()->trigger(__FUNCTION__, $this, array('user' => $currentUser, 'data' => $data)); $this->getUserMapper()->update($currentUser); - $this->getEventManager()->trigger(__FUNCTION__.'.post', $this, array('user' => $currentUser)); + $this->getEventManager()->trigger(__FUNCTION__.'.post', $this, array('user' => $currentUser, 'data' => $data)); return true; } From 2a4659f3cfc3c5f2e06ccd1d3fbc99f2a8b9d9c5 Mon Sep 17 00:00:00 2001 From: Danielss89 Date: Mon, 14 Jul 2014 11:46:35 +0200 Subject: [PATCH 08/59] Fix caching closure --- Module.php | 23 +++++++++++++++++++++-- config/module.config.php | 18 ------------------ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Module.php b/Module.php index 024ef76a..d2d236f8 100644 --- a/Module.php +++ b/Module.php @@ -2,12 +2,11 @@ namespace ZfcUser; -use Zend\ModuleManager\ModuleManager; use Zend\ModuleManager\Feature\AutoloaderProviderInterface; use Zend\ModuleManager\Feature\ConfigProviderInterface; use Zend\ModuleManager\Feature\ServiceProviderInterface; -use Zend\Stdlib\Hydrator\ClassMethods; use ZfcUser\Controller\RedirectCallback; +use ZfcUser\Controller\UserController; class Module implements AutoloaderProviderInterface, @@ -50,6 +49,26 @@ public function getControllerPluginConfig() ); } + public function getControllerConfig() + { + return array( + 'factories' => array( + 'zfcuser' => function($controllerManager) { + /* @var ControllerManager $controllerManager*/ + $serviceManager = $controllerManager->getServiceLocator(); + + /* @var RedirectCallback $redirectCallback */ + $redirectCallback = $serviceManager->get('zfcuser_redirect_callback'); + + /* @var UserController $controller */ + $controller = new UserController($redirectCallback); + + return $controller; + }, + ), + ); + } + public function getViewHelperConfig() { return array( diff --git a/config/module.config.php b/config/module.config.php index cac5fab9..7fa725c5 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -1,5 +1,4 @@ array( @@ -7,23 +6,6 @@ 'zfcuser' => __DIR__ . '/../view', ), ), - 'controllers' => array( - - 'factories' => array( - 'zfcuser' => function($controllerManager) { - /* @var ControllerManager $controllerManager*/ - $serviceManager = $controllerManager->getServiceLocator(); - - /* @var RedirectCallback $redirectCallback */ - $redirectCallback = $serviceManager->get('zfcuser_redirect_callback'); - - /* @var UserController $controller */ - $controller = new UserController($redirectCallback); - - return $controller; - }, - ), - ), 'service_manager' => array( 'aliases' => array( 'zfcuser_zend_db_adapter' => 'Zend\Db\Adapter\Adapter', From 5b6b691623d787e63973fd2a6192705175792f05 Mon Sep 17 00:00:00 2001 From: nikolajpetersen Date: Fri, 8 Aug 2014 11:37:07 +0200 Subject: [PATCH 09/59] closes #511 --- src/ZfcUser/Authentication/Adapter/Db.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ZfcUser/Authentication/Adapter/Db.php b/src/ZfcUser/Authentication/Adapter/Db.php index c37824f8..c8a5b24e 100644 --- a/src/ZfcUser/Authentication/Adapter/Db.php +++ b/src/ZfcUser/Authentication/Adapter/Db.php @@ -40,8 +40,7 @@ class Db extends AbstractAdapter implements ServiceManagerAwareInterface */ public function logout(AuthEvent $e) { - $session = new SessionContainer($this->getStorage()->getNameSpace()); - $session->getManager()->destroy(); + $this->getStorage()->clear(); } public function authenticate(AuthEvent $e) From 53413474f5d5668ddd31b9aa9a6ec88b5111e1d1 Mon Sep 17 00:00:00 2001 From: BnitoBzh Date: Wed, 3 Sep 2014 17:05:41 +0200 Subject: [PATCH 10/59] Fix redirect after register https://github.com/ZF-Commons/ZfcUser/issues/520 If the option "login_after_registration" is set to "true", the redirection after register is invalid. Because in "RedirectCallback" file, in 'getRedirect" function --- src/ZfcUser/Controller/RedirectCallback.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ZfcUser/Controller/RedirectCallback.php b/src/ZfcUser/Controller/RedirectCallback.php index f4e05474..42ff7201 100644 --- a/src/ZfcUser/Controller/RedirectCallback.php +++ b/src/ZfcUser/Controller/RedirectCallback.php @@ -101,6 +101,7 @@ protected function getRedirect($currentRoute, $redirect = false) } switch ($currentRoute) { + case 'zfcuser/register': case 'zfcuser/login': $route = ($redirect) ?: $this->options->getLoginRedirectRoute(); return $this->router->assemble(array(), array('name' => $route)); From 36f962b1f05b373c8e878dd1146266af273ee0fe Mon Sep 17 00:00:00 2001 From: BnitoBzh Date: Wed, 3 Sep 2014 17:23:16 +0200 Subject: [PATCH 11/59] Update RedirectCallback.php --- src/ZfcUser/Controller/RedirectCallback.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ZfcUser/Controller/RedirectCallback.php b/src/ZfcUser/Controller/RedirectCallback.php index 42ff7201..925f6ec3 100644 --- a/src/ZfcUser/Controller/RedirectCallback.php +++ b/src/ZfcUser/Controller/RedirectCallback.php @@ -101,7 +101,7 @@ protected function getRedirect($currentRoute, $redirect = false) } switch ($currentRoute) { - case 'zfcuser/register': + case 'zfcuser/register': case 'zfcuser/login': $route = ($redirect) ?: $this->options->getLoginRedirectRoute(); return $this->router->assemble(array(), array('name' => $route)); From a8231bea45eaacfef84127a496063b1feef9f7e2 Mon Sep 17 00:00:00 2001 From: Adam Lundrigan Date: Wed, 29 Oct 2014 11:22:44 -0700 Subject: [PATCH 12/59] Fix test suite failure intoduced in #511 --- tests/ZfcUserTest/Authentication/Adapter/DbTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/ZfcUserTest/Authentication/Adapter/DbTest.php b/tests/ZfcUserTest/Authentication/Adapter/DbTest.php index 56014e82..623ad7ff 100644 --- a/tests/ZfcUserTest/Authentication/Adapter/DbTest.php +++ b/tests/ZfcUserTest/Authentication/Adapter/DbTest.php @@ -78,8 +78,7 @@ protected function setUp() public function testLogout() { $this->storage->expects($this->once()) - ->method('getNameSpace') - ->will($this->returnValue('test')); + ->method('clear'); $this->db->logout($this->authEvent); } From f57949ed13559e4a4c556ca5c4e991ea09e1085f Mon Sep 17 00:00:00 2001 From: Adam Lundrigan Date: Wed, 29 Oct 2014 11:42:59 -0700 Subject: [PATCH 13/59] Remove default user state value check during registration process Closes #523 --- src/ZfcUser/Service/User.php | 4 +- tests/ZfcUserTest/Service/UserTest.php | 144 ++++++++++++++++++++++++- 2 files changed, 144 insertions(+), 4 deletions(-) diff --git a/src/ZfcUser/Service/User.php b/src/ZfcUser/Service/User.php index d32a8d35..81349c80 100644 --- a/src/ZfcUser/Service/User.php +++ b/src/ZfcUser/Service/User.php @@ -90,9 +90,7 @@ public function register(array $data) // If user state is enabled, set the default state value if ($this->getOptions()->getEnableUserState()) { - if ($this->getOptions()->getDefaultUserState()) { - $user->setState($this->getOptions()->getDefaultUserState()); - } + $user->setState($this->getOptions()->getDefaultUserState()); } $this->getEventManager()->trigger(__FUNCTION__, $this, array('user' => $user, 'form' => $form)); $this->getUserMapper()->insert($user); diff --git a/tests/ZfcUserTest/Service/UserTest.php b/tests/ZfcUserTest/Service/UserTest.php index db92f3ca..23c25d7f 100644 --- a/tests/ZfcUserTest/Service/UserTest.php +++ b/tests/ZfcUserTest/Service/UserTest.php @@ -119,7 +119,7 @@ public function testRegisterWithUsernameAndDisplayNameUserStateDisabled() $this->options->expects($this->once()) ->method('getEnableUserState') ->will($this->returnValue(true)); - $this->options->expects($this->exactly(2)) + $this->options->expects($this->once()) ->method('getDefaultUserState') ->will($this->returnValue(1)); @@ -153,6 +153,148 @@ public function testRegisterWithUsernameAndDisplayNameUserStateDisabled() $this->assertSame($user, $result); } + /** + * @covers ZfcUser\Service\User::register + */ + public function testRegisterWithDefaultUserStateOfZero() + { + $expectArray = array('username' => 'ZfcUser', 'display_name' => 'Zfc User'); + + $user = $this->getMock('ZfcUser\Entity\User'); + $user->expects($this->once()) + ->method('setPassword'); + $user->expects($this->once()) + ->method('getPassword'); + $user->expects($this->once()) + ->method('setUsername') + ->with('ZfcUser'); + $user->expects($this->once()) + ->method('setDisplayName') + ->with('Zfc User'); + $user->expects($this->once()) + ->method('setState') + ->with(0); + + $this->options->expects($this->once()) + ->method('getUserEntityClass') + ->will($this->returnValue('ZfcUser\Entity\User')); + $this->options->expects($this->once()) + ->method('getPasswordCost') + ->will($this->returnValue(4)); + $this->options->expects($this->once()) + ->method('getEnableUsername') + ->will($this->returnValue(true)); + $this->options->expects($this->once()) + ->method('getEnableDisplayName') + ->will($this->returnValue(true)); + $this->options->expects($this->once()) + ->method('getEnableUserState') + ->will($this->returnValue(true)); + $this->options->expects($this->once()) + ->method('getDefaultUserState') + ->will($this->returnValue(0)); + + $registerForm = $this->getMockBuilder('ZfcUser\Form\Register')->disableOriginalConstructor()->getMock(); + $registerForm->expects($this->once()) + ->method('setHydrator'); + $registerForm->expects($this->once()) + ->method('bind'); + $registerForm->expects($this->once()) + ->method('setData') + ->with($expectArray); + $registerForm->expects($this->once()) + ->method('getData') + ->will($this->returnValue($user)); + $registerForm->expects($this->once()) + ->method('isValid') + ->will($this->returnValue(true)); + + $this->eventManager->expects($this->exactly(2)) + ->method('trigger'); + + $this->mapper->expects($this->once()) + ->method('insert') + ->with($user) + ->will($this->returnValue($user)); + + $this->service->setRegisterForm($registerForm); + + $result = $this->service->register($expectArray); + + $this->assertSame($user, $result); + $this->assertEquals(0, $user->getState()); + } + + /** + * @covers ZfcUser\Service\User::register + */ + public function testRegisterWithUserStateDisabled() + { + $expectArray = array('username' => 'ZfcUser', 'display_name' => 'Zfc User'); + + $user = $this->getMock('ZfcUser\Entity\User'); + $user->expects($this->once()) + ->method('setPassword'); + $user->expects($this->once()) + ->method('getPassword'); + $user->expects($this->once()) + ->method('setUsername') + ->with('ZfcUser'); + $user->expects($this->once()) + ->method('setDisplayName') + ->with('Zfc User'); + $user->expects($this->never()) + ->method('setState'); + + $this->options->expects($this->once()) + ->method('getUserEntityClass') + ->will($this->returnValue('ZfcUser\Entity\User')); + $this->options->expects($this->once()) + ->method('getPasswordCost') + ->will($this->returnValue(4)); + $this->options->expects($this->once()) + ->method('getEnableUsername') + ->will($this->returnValue(true)); + $this->options->expects($this->once()) + ->method('getEnableDisplayName') + ->will($this->returnValue(true)); + $this->options->expects($this->once()) + ->method('getEnableUserState') + ->will($this->returnValue(false)); + $this->options->expects($this->never()) + ->method('getDefaultUserState'); + + $registerForm = $this->getMockBuilder('ZfcUser\Form\Register')->disableOriginalConstructor()->getMock(); + $registerForm->expects($this->once()) + ->method('setHydrator'); + $registerForm->expects($this->once()) + ->method('bind'); + $registerForm->expects($this->once()) + ->method('setData') + ->with($expectArray); + $registerForm->expects($this->once()) + ->method('getData') + ->will($this->returnValue($user)); + $registerForm->expects($this->once()) + ->method('isValid') + ->will($this->returnValue(true)); + + $this->eventManager->expects($this->exactly(2)) + ->method('trigger'); + + $this->mapper->expects($this->once()) + ->method('insert') + ->with($user) + ->will($this->returnValue($user)); + + $this->service->setRegisterForm($registerForm); + + $result = $this->service->register($expectArray); + + $this->assertSame($user, $result); + $this->assertEquals(0, $user->getState()); + } + /** * @covers ZfcUser\Service\User::changePassword */ From baf0e460796ea92f6c902fa9b007190bccff2b8f Mon Sep 17 00:00:00 2001 From: Danielss89 Date: Thu, 8 Jan 2015 14:18:45 +0100 Subject: [PATCH 14/59] Fix XSS vulnerability --- view/zfc-user/user/login.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/zfc-user/user/login.phtml b/view/zfc-user/user/login.phtml index 3d1df3bd..66dbfd68 100644 --- a/view/zfc-user/user/login.phtml +++ b/view/zfc-user/user/login.phtml @@ -28,5 +28,5 @@ $form->setAttribute('method', 'post'); form()->closeTag() ?> enableRegistration) : ?> -translate('Not registered?'); ?> translate('Sign up!'); ?> +translate('Not registered?'); ?> translate('Sign up!'); ?> From 947929a30b84bc40be1c0bff6bcf35e66a4fe977 Mon Sep 17 00:00:00 2001 From: Clayton Daley Date: Wed, 28 Jan 2015 14:48:12 -0500 Subject: [PATCH 15/59] - add password type outside attributes to get correct Entity --- src/ZfcUser/Form/Base.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ZfcUser/Form/Base.php b/src/ZfcUser/Form/Base.php index c3db48a8..b209b7b4 100644 --- a/src/ZfcUser/Form/Base.php +++ b/src/ZfcUser/Form/Base.php @@ -44,6 +44,7 @@ public function __construct() $this->add(array( 'name' => 'password', + 'type' => 'password', 'options' => array( 'label' => 'Password', ), @@ -54,6 +55,7 @@ public function __construct() $this->add(array( 'name' => 'passwordVerify', + 'type' => 'password', 'options' => array( 'label' => 'Password Verify', ), From c36e8c87086fae2385418fb8cd6c970eeb1a545f Mon Sep 17 00:00:00 2001 From: Clayton Daley Date: Wed, 28 Jan 2015 14:58:28 -0500 Subject: [PATCH 16/59] - fixed password everywhere in case it ever affects an inheriting user --- src/ZfcUser/Form/ChangeEmail.php | 1 + src/ZfcUser/Form/ChangePassword.php | 2 ++ src/ZfcUser/Form/Login.php | 1 + 3 files changed, 4 insertions(+) diff --git a/src/ZfcUser/Form/ChangeEmail.php b/src/ZfcUser/Form/ChangeEmail.php index f855a5d4..6d10f3f4 100644 --- a/src/ZfcUser/Form/ChangeEmail.php +++ b/src/ZfcUser/Form/ChangeEmail.php @@ -45,6 +45,7 @@ public function __construct($name, AuthenticationOptionsInterface $options) $this->add(array( 'name' => 'credential', + 'type' => 'password', 'options' => array( 'label' => 'Password', ), diff --git a/src/ZfcUser/Form/ChangePassword.php b/src/ZfcUser/Form/ChangePassword.php index 43745e5d..1f1c7b1d 100644 --- a/src/ZfcUser/Form/ChangePassword.php +++ b/src/ZfcUser/Form/ChangePassword.php @@ -32,6 +32,7 @@ public function __construct($name, AuthenticationOptionsInterface $options) $this->add(array( 'name' => 'credential', + 'type' => 'password', 'options' => array( 'label' => 'Current Password', ), @@ -52,6 +53,7 @@ public function __construct($name, AuthenticationOptionsInterface $options) $this->add(array( 'name' => 'newCredentialVerify', + 'type' => 'password', 'options' => array( 'label' => 'Verify New Password', ), diff --git a/src/ZfcUser/Form/Login.php b/src/ZfcUser/Form/Login.php index 2112c8fd..b6c5c460 100644 --- a/src/ZfcUser/Form/Login.php +++ b/src/ZfcUser/Form/Login.php @@ -40,6 +40,7 @@ public function __construct($name, AuthenticationOptionsInterface $options) // $this->add(array( 'name' => 'credential', + 'type' => 'password', 'options' => array( 'label' => 'Password', ), From d9b27aabf27335ced1f15c1d9f85fd13bece4d47 Mon Sep 17 00:00:00 2001 From: Clayton Daley Date: Wed, 28 Jan 2015 16:22:54 -0500 Subject: [PATCH 17/59] - move registration dependencies from Base constructor to Registration constructor --- src/ZfcUser/Form/Base.php | 11 ----------- src/ZfcUser/Form/Register.php | 11 +++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ZfcUser/Form/Base.php b/src/ZfcUser/Form/Base.php index c3db48a8..0bf1c453 100644 --- a/src/ZfcUser/Form/Base.php +++ b/src/ZfcUser/Form/Base.php @@ -62,17 +62,6 @@ public function __construct() ), )); - if ($this->getRegistrationOptions()->getUseRegistrationFormCaptcha()) { - $this->add(array( - 'name' => 'captcha', - 'type' => 'Zend\Form\Element\Captcha', - 'options' => array( - 'label' => 'Please type the following text', - 'captcha' => $this->getRegistrationOptions()->getFormCaptchaOptions(), - ), - )); - } - $submitElement = new Element\Button('submit'); $submitElement ->setLabel('Submit') diff --git a/src/ZfcUser/Form/Register.php b/src/ZfcUser/Form/Register.php index aaa56f1f..a1c396a5 100644 --- a/src/ZfcUser/Form/Register.php +++ b/src/ZfcUser/Form/Register.php @@ -23,6 +23,17 @@ public function __construct($name, RegistrationOptionsInterface $options) $this->setRegistrationOptions($options); parent::__construct($name); + if ($this->getRegistrationOptions()->getUseRegistrationFormCaptcha()) { + $this->add(array( + 'name' => 'captcha', + 'type' => 'Zend\Form\Element\Captcha', + 'options' => array( + 'label' => 'Please type the following text', + 'captcha' => $this->getRegistrationOptions()->getFormCaptchaOptions(), + ), + )); + } + $this->remove('userId'); if (!$this->getRegistrationOptions()->getEnableUsername()) { $this->remove('username'); From 8c22795e88a099b6c12dabb577e96bb6fc4aca53 Mon Sep 17 00:00:00 2001 From: Clayton Daley Date: Sun, 1 Feb 2015 16:20:43 -0500 Subject: [PATCH 18/59] - try fixing tests --- tests/ZfcUserTest/Form/BaseTest.php | 23 +--------- tests/ZfcUserTest/Form/RegisterTest.php | 18 +++++++- .../Form/TestAsset/BaseExtension.php | 42 ------------------- 3 files changed, 19 insertions(+), 64 deletions(-) delete mode 100644 tests/ZfcUserTest/Form/TestAsset/BaseExtension.php diff --git a/tests/ZfcUserTest/Form/BaseTest.php b/tests/ZfcUserTest/Form/BaseTest.php index ea6932d3..2978ea16 100644 --- a/tests/ZfcUserTest/Form/BaseTest.php +++ b/tests/ZfcUserTest/Form/BaseTest.php @@ -9,21 +9,9 @@ class BaseTest extends \PHPUnit_Framework_TestCase /** * @dataProvider providerTestConstruct */ - public function testConstruct($useCaptcha = false) + public function testConstruct() { - $options = $this->getMock('ZfcUser\Options\RegistrationOptionsInterface'); - $options->expects($this->once()) - ->method('getUseRegistrationFormCaptcha') - ->will($this->returnValue($useCaptcha)); - if ($useCaptcha && class_exists('\Zend\Captcha\AbstractAdapter')) { - $captcha = $this->getMockForAbstractClass('\Zend\Captcha\AbstractAdapter'); - - $options->expects($this->once()) - ->method('getFormCaptchaOptions') - ->will($this->returnValue($captcha)); - } - - $form = new Form($options); + $form = new Form(); $elements = $form->getElements(); @@ -36,11 +24,4 @@ public function testConstruct($useCaptcha = false) $this->assertArrayHasKey('userId', $elements); } - public function providerTestConstruct() - { - return array( - array(true), - array(false) - ); - } } diff --git a/tests/ZfcUserTest/Form/RegisterTest.php b/tests/ZfcUserTest/Form/RegisterTest.php index 8bb8c679..1da7103d 100644 --- a/tests/ZfcUserTest/Form/RegisterTest.php +++ b/tests/ZfcUserTest/Form/RegisterTest.php @@ -6,7 +6,7 @@ class RegisterTest extends \PHPUnit_Framework_TestCase { - public function testConstruct() + public function testConstruct($useCaptcha = false) { $options = $this->getMock('ZfcUser\Options\RegistrationOptionsInterface'); $options->expects($this->once()) @@ -18,6 +18,14 @@ public function testConstruct() $options->expects($this->any()) ->method('getUseRegistrationFormCaptcha') ->will($this->returnValue(false)); + if ($useCaptcha && class_exists('\Zend\Captcha\AbstractAdapter')) { + $captcha = $this->getMockForAbstractClass('\Zend\Captcha\AbstractAdapter'); + + $options->expects($this->once()) + ->method('getFormCaptchaOptions') + ->will($this->returnValue($captcha)); + } + $form = new Form(null, $options); $elements = $form->getElements(); @@ -30,6 +38,14 @@ public function testConstruct() $this->assertArrayHasKey('passwordVerify', $elements); } + public function providerTestConstruct() + { + return array( + array(true), + array(false) + ); + } + public function testSetGetRegistrationOptions() { $options = $this->getMock('ZfcUser\Options\RegistrationOptionsInterface'); diff --git a/tests/ZfcUserTest/Form/TestAsset/BaseExtension.php b/tests/ZfcUserTest/Form/TestAsset/BaseExtension.php deleted file mode 100644 index ff8753ed..00000000 --- a/tests/ZfcUserTest/Form/TestAsset/BaseExtension.php +++ /dev/null @@ -1,42 +0,0 @@ -setRegistrationOptions($options); - parent::__construct(null); - } - - /** - * Set Regsitration Options - * - * @param RegistrationOptionsInterface $registrationOptions - * @return Register - */ - public function setRegistrationOptions(RegistrationOptionsInterface $registrationOptions) - { - $this->registrationOptions = $registrationOptions; - return $this; - } - - /** - * Get Regsitration Options - * - * @return RegistrationOptionsInterface - */ - public function getRegistrationOptions() - { - return $this->registrationOptions; - } -} From da66b76bc189ee20023fd17e508531cb0868c54f Mon Sep 17 00:00:00 2001 From: Clayton Daley Date: Sun, 1 Feb 2015 16:24:21 -0500 Subject: [PATCH 19/59] - move provider annotation --- tests/ZfcUserTest/Form/BaseTest.php | 3 --- tests/ZfcUserTest/Form/RegisterTest.php | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ZfcUserTest/Form/BaseTest.php b/tests/ZfcUserTest/Form/BaseTest.php index 2978ea16..eeaedb83 100644 --- a/tests/ZfcUserTest/Form/BaseTest.php +++ b/tests/ZfcUserTest/Form/BaseTest.php @@ -6,9 +6,6 @@ class BaseTest extends \PHPUnit_Framework_TestCase { - /** - * @dataProvider providerTestConstruct - */ public function testConstruct() { $form = new Form(); diff --git a/tests/ZfcUserTest/Form/RegisterTest.php b/tests/ZfcUserTest/Form/RegisterTest.php index 1da7103d..4c2e0511 100644 --- a/tests/ZfcUserTest/Form/RegisterTest.php +++ b/tests/ZfcUserTest/Form/RegisterTest.php @@ -6,6 +6,9 @@ class RegisterTest extends \PHPUnit_Framework_TestCase { + /** + * @dataProvider providerTestConstruct + */ public function testConstruct($useCaptcha = false) { $options = $this->getMock('ZfcUser\Options\RegistrationOptionsInterface'); From b7d533517675fc9540d5f144f7c11f059aaaf876 Mon Sep 17 00:00:00 2001 From: Clayton Daley Date: Sun, 1 Feb 2015 16:28:08 -0500 Subject: [PATCH 20/59] - fixed class use --- tests/ZfcUserTest/Form/BaseTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ZfcUserTest/Form/BaseTest.php b/tests/ZfcUserTest/Form/BaseTest.php index eeaedb83..fd2f2c2a 100644 --- a/tests/ZfcUserTest/Form/BaseTest.php +++ b/tests/ZfcUserTest/Form/BaseTest.php @@ -2,7 +2,7 @@ namespace ZfcUserTest\Form; -use ZfcUserTest\Form\TestAsset\BaseExtension as Form; +use ZfcUser\Form\Base as Form; class BaseTest extends \PHPUnit_Framework_TestCase { From 28b4ae26d54695dea5f48837c2984c9f868c9a7f Mon Sep 17 00:00:00 2001 From: Clayton Daley Date: Sun, 1 Feb 2015 16:32:41 -0500 Subject: [PATCH 21/59] - actually set $useCaptcha in settings --- tests/ZfcUserTest/Form/RegisterTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ZfcUserTest/Form/RegisterTest.php b/tests/ZfcUserTest/Form/RegisterTest.php index 4c2e0511..f6dab831 100644 --- a/tests/ZfcUserTest/Form/RegisterTest.php +++ b/tests/ZfcUserTest/Form/RegisterTest.php @@ -20,7 +20,7 @@ public function testConstruct($useCaptcha = false) ->will($this->returnValue(false)); $options->expects($this->any()) ->method('getUseRegistrationFormCaptcha') - ->will($this->returnValue(false)); + ->will($this->returnValue($useCaptcha)); if ($useCaptcha && class_exists('\Zend\Captcha\AbstractAdapter')) { $captcha = $this->getMockForAbstractClass('\Zend\Captcha\AbstractAdapter'); From 5afcf6e5ac6b231ea64f27c72d7577a3ba29095d Mon Sep 17 00:00:00 2001 From: Clayton Daley Date: Sun, 1 Feb 2015 16:39:39 -0500 Subject: [PATCH 22/59] - "The closing brace for the class must go on the next line after the body" --- tests/ZfcUserTest/Form/BaseTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/ZfcUserTest/Form/BaseTest.php b/tests/ZfcUserTest/Form/BaseTest.php index fd2f2c2a..e333717f 100644 --- a/tests/ZfcUserTest/Form/BaseTest.php +++ b/tests/ZfcUserTest/Form/BaseTest.php @@ -20,5 +20,4 @@ public function testConstruct() $this->assertArrayHasKey('submit', $elements); $this->assertArrayHasKey('userId', $elements); } - } From e91ea22131686a53367b4b80fd1edc9c662bc01f Mon Sep 17 00:00:00 2001 From: Martin Vagovszky Date: Mon, 9 Feb 2015 11:19:04 +0100 Subject: [PATCH 23/59] Add translation for Czech language --- src/ZfcUser/language/cs_CZ.mo | Bin 0 -> 2340 bytes src/ZfcUser/language/cs_CZ.po | 126 ++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 src/ZfcUser/language/cs_CZ.mo create mode 100644 src/ZfcUser/language/cs_CZ.po diff --git a/src/ZfcUser/language/cs_CZ.mo b/src/ZfcUser/language/cs_CZ.mo new file mode 100644 index 0000000000000000000000000000000000000000..2ee45a79ce7cf5dfbb26f5db25e64c3e6a2b077d GIT binary patch literal 2340 zcma)+&yN&E6vqoifk8!4{Dm<^2*gCYcLsyNfc#p1Ms{|>{)pKNsqLD`{HrmB0^ z>3_h3G4Wyy*%+CV;jsUJ39Cu(T)n6_!oiCN4~C2Jz`^h9?%7$A#aNl1PuH(k?|tj_ zd$@n+*9`5Q@_7s%!Si4T{?MXlivDfzJ@mf;Uj=^xUk85$Uk3jKUjQG2&w+cMW$ZAx z52XHw;2!W4Nb4rSqhJ%<2d;p-!OzS7SKzzo-!1uLIsXvch4DYi{$C~k0iVbCj-8Bs z1nvfF;5m@&-Ui9f6eRz@0DnP@-+>>XZ?V|{?}9Y{bIIR9+V^+a--W{|o`c{~@DNx5 zuYr5PnUc4_)95dQq|^5x?OO-Q-UfIO{0%$|J_5Y)*;A5H>VVB45Ok_jO{p%w;X**iQcKw?(D$+wQQ^ zC=$E~kdJlTGB8qsHH}`9UhG`=9ZXx~LY*(Pyg3-DG^b~sNh9+NaW28s!5qIj`btj77 zcyb1*;z@jo*-wxb`F6%hr6cl&yK$ z8c&6v4OF&9g@EcnDm=-p3_Bte$SR|4w$|n8a)J+tk~USkm$+=9yRoVS??~JrkBp{j zu-zCu-uO~jmEFtNYPO&kjYxG*(9lvhyQlQliU8jRs0t_wf@eS2Xk&FaP#dc}rSs@W zb_oWMAHGzqfz|hmPbYsLozak^sE6y>z*kuGwD5iMqnnInXvigsv?v*d+))$a97>Tz zDVpxVpF0wA6_FRiPdJ)HM)ai8E`3qCb~*}%1DI6Vz@oM$rSOzyW!W&$oHd7cf=-wX zh6A$Cru{9Q1yTBwEWwbKhcHdb$0&*9Oji%rNzYs*B;C9i4uV1$-P1`SXyWpP&1=M! z6&G7v=aXjg7)mp;xVP>0MmqI3R+j>o%?;Os9_m79m&dodMJybW-RtPWqhza$qnSLB F*uN@kvy}h< literal 0 HcmV?d00001 diff --git a/src/ZfcUser/language/cs_CZ.po b/src/ZfcUser/language/cs_CZ.po new file mode 100644 index 00000000..7768df57 --- /dev/null +++ b/src/ZfcUser/language/cs_CZ.po @@ -0,0 +1,126 @@ +msgid "" +msgstr "" +"Project-Id-Version: ZfcUser\n" +"POT-Creation-Date: 2015-02-09 11:17+0100\n" +"PO-Revision-Date: 2015-02-09 11:17+0100\n" +"Last-Translator: Martin Vagovszký \n" +"Language-Team: ZF Contibutors \n" +"Language: cs_CZ\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.5.7\n" +"X-Poedit-KeywordsList: translate\n" +"X-Poedit-Basepath: ../../../\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-SearchPath-0: .\n" + +#: src/ZfcUser/language/msgIds.php:6 +msgid "Username" +msgstr "Uživatelské jméno" + +#: src/ZfcUser/language/msgIds.php:7 +msgid "Email" +msgstr "Email" + +#: src/ZfcUser/language/msgIds.php:8 +msgid "New Email" +msgstr "Nový email" + +#: src/ZfcUser/language/msgIds.php:9 +msgid "Verify New Email" +msgstr "Ověření nového emailu" + +#: src/ZfcUser/language/msgIds.php:10 +msgid "Display Name" +msgstr "Zobrazované jméno" + +#: src/ZfcUser/language/msgIds.php:11 +msgid "Password" +msgstr "Heslo" + +#: src/ZfcUser/language/msgIds.php:12 +msgid "Password Verify" +msgstr "Ověření hesla" + +#: src/ZfcUser/language/msgIds.php:13 +msgid "Current Password" +msgstr "Současné heslo" + +#: src/ZfcUser/language/msgIds.php:14 +msgid "Verify New Password" +msgstr "Ověření nového hesla" + +#: src/ZfcUser/language/msgIds.php:15 +msgid "New Password" +msgstr "Nové heslo" + +#: src/ZfcUser/language/msgIds.php:16 +msgid "Please type the following text" +msgstr "Prosím opište následující text" + +#: src/ZfcUser/language/msgIds.php:17 +msgid "Submit" +msgstr "Odeslat" + +#: src/ZfcUser/language/msgIds.php:18 view/zfc-user/user/login.phtml:1 +msgid "Sign In" +msgstr "Přihlášení" + +#: src/ZfcUser/language/msgIds.php:19 view/zfc-user/user/register.phtml:1 +msgid "Register" +msgstr "Registrace" + +#: src/ZfcUser/language/msgIds.php:20 +msgid "No record matching the input was found" +msgstr "Nenalezen žádný záznam odpovídající danému zadání" + +#: src/ZfcUser/language/msgIds.php:21 +msgid "A record matching the input was found" +msgstr "Byl nalezen záznam odpovídající zadání" + +#: src/ZfcUser/language/msgIds.php:22 +msgid "Authentication failed. Please try again." +msgstr "Autentizace selhala. Prosím zkuste to znovu." + +#: view/zfc-user/user/changeemail.phtml:1 +#, php-format +msgid "Change Email for %s" +msgstr "Změna hesla pro %s" + +#: view/zfc-user/user/changeemail.phtml:3 +msgid "Email address changed successfully." +msgstr "Emailová adresa úspěšně změněna" + +#: view/zfc-user/user/changeemail.phtml:5 +msgid "Unable to update your email address. Please try again." +msgstr "Není možné změnit Vaši emailovou adresu. Zkuste to prosím znovu." + +#: view/zfc-user/user/changepassword.phtml:1 +#, php-format +msgid "Change Password for %s" +msgstr "Změna hesla pro %s" + +#: view/zfc-user/user/changepassword.phtml:3 +msgid "Password changed successfully." +msgstr "Heslo úspěšně upraveno." + +#: view/zfc-user/user/changepassword.phtml:5 +msgid "Unable to update your password. Please try again." +msgstr "Není možné upravit Vaše heslo. Zkuste to prosím později." + +#: view/zfc-user/user/index.phtml:2 +msgid "Hello" +msgstr "Dobrý den" + +#: view/zfc-user/user/index.phtml:3 +msgid "Sign Out" +msgstr "Odhlášení" + +#: view/zfc-user/user/login.phtml:31 +msgid "Not registered?" +msgstr "Nejste registrován/a?" + +#: view/zfc-user/user/login.phtml:31 +msgid "Sign up!" +msgstr "Zaregistrujte se!" From 5dc80d9c729ffdba6df1a80dae75d3549441e388 Mon Sep 17 00:00:00 2001 From: Martin Vagovszky Date: Mon, 9 Feb 2015 15:38:24 +0100 Subject: [PATCH 24/59] Translation typo --- src/ZfcUser/language/cs_CZ.mo | Bin 2340 -> 2341 bytes src/ZfcUser/language/cs_CZ.po | 6 +++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ZfcUser/language/cs_CZ.mo b/src/ZfcUser/language/cs_CZ.mo index 2ee45a79ce7cf5dfbb26f5db25e64c3e6a2b077d..f49a7ef631af01d93307d05a2f39034d6c9b57bb 100644 GIT binary patch delta 242 zcmXZWtqQ_$6vp8*-R96CevF}L@dL9UGbkDdS}cN9gF%?l>_ym33PxcUV6tix6ts8; zD^`DhSbE+U&N-Yz;aE63+SU<~n<-MnFXr$UcPk}g(5u+OI;L@i8Jxz>u}=@s#S^N% z3#xlptl$G17@@l3TH;HVP_smAY-1h=$c#+T#~BWBkLuw!mNCK-+Tl~vlDgOHc)O3@ VRG}N1#$7X)>%}VAgfDZP_yar39K!$r delta 241 zcmXZUzY76z9LDj_aldjB=ZJ10vg#&i zeY{}}Kd5#JwuF))RBVwnHZg}?\n" "Language-Team: ZF Contibutors \n" "Language: cs_CZ\n" @@ -86,7 +86,7 @@ msgstr "Autentizace selhala. Prosím zkuste to znovu." #: view/zfc-user/user/changeemail.phtml:1 #, php-format msgid "Change Email for %s" -msgstr "Změna hesla pro %s" +msgstr "Změna emailu pro %s" #: view/zfc-user/user/changeemail.phtml:3 msgid "Email address changed successfully." From 0d1c7bab8b582aaeeb85fe1bb18b4ad2389dbc2c Mon Sep 17 00:00:00 2001 From: Clayton Daley Date: Sat, 7 Feb 2015 12:36:29 -0500 Subject: [PATCH 25/59] Upgrade Forms: - Move Form construction from closure to Factory - Change most Form hints to FormInterface - Use FormElementManager to build Forms - Tweak forms to use `init()` - Add submit button to ChangeEmail form - Implement generic form renderer - Set Register hydrator in Factory Fix tests: - Identify cases where FormElementManager is used - Mock FormElementManager - Add Factory tests - Need to init() in Form tests to initialize elements - Method checks have also been moved to `init()` - PEP fixes - One of the mock calls is required for a temporary fix and should be made optional (`any`) rather then required (`once`) --- Module.php | 70 ++++--------------- config/module.config.php | 12 ++-- src/ZfcUser/Controller/UserController.php | 30 ++++---- src/ZfcUser/Form/Base.php | 6 +- src/ZfcUser/Form/ChangeEmail.php | 12 +++- src/ZfcUser/Form/ChangePassword.php | 8 ++- src/ZfcUser/Form/Login.php | 5 +- src/ZfcUser/Form/Register.php | 6 +- .../Form/ChangeEmail.php | 36 ++++++++++ .../Form/ChangePassword.php | 29 ++++++++ .../FormElementManagerFactory/Form/Login.php | 29 ++++++++ .../Form/Register.php | 41 +++++++++++ .../Controller/UserControllerTest.php | 60 ++++++++++------ tests/ZfcUserTest/Form/BaseTest.php | 1 + tests/ZfcUserTest/Form/ChangeEmailTest.php | 1 + tests/ZfcUserTest/Form/ChangePasswordTest.php | 1 + tests/ZfcUserTest/Form/LoginTest.php | 2 + tests/ZfcUserTest/Form/RegisterTest.php | 3 + .../Form/ChangeEmailFormFactoryTest.php | 26 +++++++ .../Form/ChangePasswordFormFactoryTest.php | 26 +++++++ .../Form/LoginFormFactoryTest.php | 24 +++++++ .../Form/RegisterFormFactoryTest.php | 28 ++++++++ view/zfc-user/user/_form.phtml | 13 ++++ view/zfc-user/user/changeemail.phtml | 23 +----- view/zfc-user/user/changepassword.phtml | 30 +------- view/zfc-user/user/login.phtml | 22 +----- view/zfc-user/user/register.phtml | 20 +----- 27 files changed, 371 insertions(+), 193 deletions(-) create mode 100644 src/ZfcUser/FormElementManagerFactory/Form/ChangeEmail.php create mode 100644 src/ZfcUser/FormElementManagerFactory/Form/ChangePassword.php create mode 100644 src/ZfcUser/FormElementManagerFactory/Form/Login.php create mode 100644 src/ZfcUser/FormElementManagerFactory/Form/Register.php create mode 100644 tests/ZfcUserTest/FormElementManagerFactory/Form/ChangeEmailFormFactoryTest.php create mode 100644 tests/ZfcUserTest/FormElementManagerFactory/Form/ChangePasswordFormFactoryTest.php create mode 100644 tests/ZfcUserTest/FormElementManagerFactory/Form/LoginFormFactoryTest.php create mode 100644 tests/ZfcUserTest/FormElementManagerFactory/Form/RegisterFormFactoryTest.php create mode 100644 view/zfc-user/user/_form.phtml diff --git a/Module.php b/Module.php index d2d236f8..253c4e11 100644 --- a/Module.php +++ b/Module.php @@ -100,30 +100,35 @@ public function getViewHelperConfig() public function getServiceConfig() { return array( + 'aliases' => array( + 'zfcuser_zend_db_adapter' => 'Zend\Db\Adapter\Adapter', + ), 'invokables' => array( 'ZfcUser\Authentication\Adapter\Db' => 'ZfcUser\Authentication\Adapter\Db', 'ZfcUser\Authentication\Storage\Db' => 'ZfcUser\Authentication\Storage\Db', - 'ZfcUser\Form\Login' => 'ZfcUser\Form\Login', 'zfcuser_user_service' => 'ZfcUser\Service\User', 'zfcuser_register_form_hydrator' => 'Zend\Stdlib\Hydrator\ClassMethods', ), 'factories' => array( + 'ZfcUser\Authentication\Adapter\AdapterChain' => 'ZfcUser\Authentication\Adapter\AdapterChainServiceFactory', 'zfcuser_redirect_callback' => function ($sm) { - /* @var RouteInterface $router */ - $router = $sm->get('Router'); + /* @var RouteInterface $router */ + $router = $sm->get('Router'); + + /* @var Application $application */ + $application = $sm->get('Application'); - /* @var Application $application */ - $application = $sm->get('Application'); + /* @var ModuleOptions $options */ + $options = $sm->get('zfcuser_module_options'); - /* @var ModuleOptions $options */ - $options = $sm->get('zfcuser_module_options'); + return new RedirectCallback($application, $router, $options); + }, - return new RedirectCallback($application, $router, $options); - }, 'zfcuser_module_options' => function ($sm) { $config = $sm->get('Config'); return new Options\ModuleOptions(isset($config['zfcuser']) ? $config['zfcuser'] : array()); }, + // We alias this one because it's ZfcUser's instance of // Zend\Authentication\AuthenticationService. We don't want to // hog the FQCN service alias for a Zend\* class. @@ -134,53 +139,6 @@ public function getServiceConfig() ); }, - 'ZfcUser\Authentication\Adapter\AdapterChain' => 'ZfcUser\Authentication\Adapter\AdapterChainServiceFactory', - - 'zfcuser_login_form' => function ($sm) { - $options = $sm->get('zfcuser_module_options'); - $form = new Form\Login(null, $options); - $form->setInputFilter(new Form\LoginFilter($options)); - return $form; - }, - - 'zfcuser_register_form' => function ($sm) { - $options = $sm->get('zfcuser_module_options'); - $form = new Form\Register(null, $options); - //$form->setCaptchaElement($sm->get('zfcuser_captcha_element')); - $form->setInputFilter(new Form\RegisterFilter( - new Validator\NoRecordExists(array( - 'mapper' => $sm->get('zfcuser_user_mapper'), - 'key' => 'email' - )), - new Validator\NoRecordExists(array( - 'mapper' => $sm->get('zfcuser_user_mapper'), - 'key' => 'username' - )), - $options - )); - return $form; - }, - - 'zfcuser_change_password_form' => function ($sm) { - $options = $sm->get('zfcuser_module_options'); - $form = new Form\ChangePassword(null, $sm->get('zfcuser_module_options')); - $form->setInputFilter(new Form\ChangePasswordFilter($options)); - return $form; - }, - - 'zfcuser_change_email_form' => function ($sm) { - $options = $sm->get('zfcuser_module_options'); - $form = new Form\ChangeEmail(null, $options); - $form->setInputFilter(new Form\ChangeEmailFilter( - $options, - new Validator\NoRecordExists(array( - 'mapper' => $sm->get('zfcuser_user_mapper'), - 'key' => 'email' - )) - )); - return $form; - }, - 'zfcuser_user_hydrator' => function ($sm) { $hydrator = new \Zend\Stdlib\Hydrator\ClassMethods(); return $hydrator; diff --git a/config/module.config.php b/config/module.config.php index 7fa725c5..71c03e9f 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -6,11 +6,15 @@ 'zfcuser' => __DIR__ . '/../view', ), ), - 'service_manager' => array( - 'aliases' => array( - 'zfcuser_zend_db_adapter' => 'Zend\Db\Adapter\Adapter', - ), + 'form_elements' => array( + 'factories' => array( + 'zfcuser_login_form' => 'ZfcUser\FormElementManagerFactory\Form\Login', + 'zfcuser_register_form' => 'ZfcUser\FormElementManagerFactory\Form\Register', + 'zfcuser_change_password_form' => 'ZfcUser\FormElementManagerFactory\Form\ChangePassword', + 'zfcuser_change_email_form' => 'ZfcUser\FormElementManagerFactory\Form\ChangeEmail', + ) ), + 'router' => array( 'routes' => array( 'zfcuser' => array( diff --git a/src/ZfcUser/Controller/UserController.php b/src/ZfcUser/Controller/UserController.php index 3b2cc883..06dc9fed 100644 --- a/src/ZfcUser/Controller/UserController.php +++ b/src/ZfcUser/Controller/UserController.php @@ -2,7 +2,7 @@ namespace ZfcUser\Controller; -use Zend\Form\Form; +use Zend\Form\FormInterface; use Zend\Mvc\Controller\AbstractActionController; use Zend\Stdlib\ResponseInterface as Response; use Zend\Stdlib\Parameters; @@ -25,22 +25,22 @@ class UserController extends AbstractActionController protected $userService; /** - * @var Form + * @var FormInterface */ protected $loginForm; /** - * @var Form + * @var FormInterface */ protected $registerForm; /** - * @var Form + * @var FormInterface */ protected $changePasswordForm; /** - * @var Form + * @var FormInterface */ protected $changeEmailForm; @@ -362,12 +362,12 @@ public function setUserService(UserService $userService) public function getRegisterForm() { if (!$this->registerForm) { - $this->setRegisterForm($this->getServiceLocator()->get('zfcuser_register_form')); + $this->setRegisterForm($this->getServiceLocator()->get('FormElementManager')->get('zfcuser_register_form')); } return $this->registerForm; } - public function setRegisterForm(Form $registerForm) + public function setRegisterForm(FormInterface$registerForm) { $this->registerForm = $registerForm; } @@ -375,12 +375,12 @@ public function setRegisterForm(Form $registerForm) public function getLoginForm() { if (!$this->loginForm) { - $this->setLoginForm($this->getServiceLocator()->get('zfcuser_login_form')); + $this->setLoginForm($this->getServiceLocator()->get('FormElementManager')->get('zfcuser_login_form')); } return $this->loginForm; } - public function setLoginForm(Form $loginForm) + public function setLoginForm(FormInterface $loginForm) { $this->loginForm = $loginForm; $fm = $this->flashMessenger()->setNamespace('zfcuser-login-form')->getMessages(); @@ -395,12 +395,12 @@ public function setLoginForm(Form $loginForm) public function getChangePasswordForm() { if (!$this->changePasswordForm) { - $this->setChangePasswordForm($this->getServiceLocator()->get('zfcuser_change_password_form')); + $this->setChangePasswordForm($this->getServiceLocator()->get('FormElementManager')->get('zfcuser_change_password_form')); } return $this->changePasswordForm; } - public function setChangePasswordForm(Form $changePasswordForm) + public function setChangePasswordForm(FormInterface $changePasswordForm) { $this->changePasswordForm = $changePasswordForm; return $this; @@ -433,13 +433,12 @@ public function getOptions() /** * Get changeEmailForm. - * - * @return changeEmailForm. + * @return ChangeEmailForm */ public function getChangeEmailForm() { if (!$this->changeEmailForm) { - $this->setChangeEmailForm($this->getServiceLocator()->get('zfcuser_change_email_form')); + $this->setChangeEmailForm($this->getServiceLocator()->get('FormElementManager')->get('zfcuser_change_email_form')); } return $this->changeEmailForm; } @@ -447,7 +446,8 @@ public function getChangeEmailForm() /** * Set changeEmailForm. * - * @param changeEmailForm the value to set. + * @param $changeEmailForm - the value to set. + * @return $this */ public function setChangeEmailForm($changeEmailForm) { diff --git a/src/ZfcUser/Form/Base.php b/src/ZfcUser/Form/Base.php index 3f427d6b..8879e589 100644 --- a/src/ZfcUser/Form/Base.php +++ b/src/ZfcUser/Form/Base.php @@ -2,7 +2,6 @@ namespace ZfcUser\Form; -use Zend\Form\Form; use Zend\Form\Element; use ZfcBase\Form\ProvidesEventsForm; @@ -11,7 +10,10 @@ class Base extends ProvidesEventsForm public function __construct() { parent::__construct(); + } + public function init() + { $this->add(array( 'name' => 'username', 'options' => array( @@ -87,5 +89,7 @@ public function __construct() //$csrf = new Element\Csrf('csrf'); //$csrf->getValidator()->setTimeout($this->getRegistrationOptions()->getUserFormTimeout()); //$this->add($csrf); + + $this->getEventManager()->trigger('init', $this); } } diff --git a/src/ZfcUser/Form/ChangeEmail.php b/src/ZfcUser/Form/ChangeEmail.php index 6d10f3f4..95a24393 100644 --- a/src/ZfcUser/Form/ChangeEmail.php +++ b/src/ZfcUser/Form/ChangeEmail.php @@ -3,7 +3,6 @@ namespace ZfcUser\Form; use ZfcBase\Form\ProvidesEventsForm; -use ZfcUser\Options\RegistrationOptionsInterface; use ZfcUser\Options\AuthenticationOptionsInterface; class ChangeEmail extends ProvidesEventsForm @@ -12,7 +11,10 @@ public function __construct($name, AuthenticationOptionsInterface $options) { $this->setAuthenticationOptions($options); parent::__construct($name); + } + public function init() + { $this->add(array( 'name' => 'identity', 'options' => array( @@ -54,6 +56,14 @@ public function __construct($name, AuthenticationOptionsInterface $options) ), )); + $this->add(array( + 'name' => 'submit', + 'attributes' => array( + 'value' => 'Submit', + 'type' => 'submit' + ), + )); + $this->getEventManager()->trigger('init', $this); } diff --git a/src/ZfcUser/Form/ChangePassword.php b/src/ZfcUser/Form/ChangePassword.php index 1f1c7b1d..d697c081 100644 --- a/src/ZfcUser/Form/ChangePassword.php +++ b/src/ZfcUser/Form/ChangePassword.php @@ -2,11 +2,8 @@ namespace ZfcUser\Form; -use Zend\Form\Form; -use Zend\Form\Element\Csrf; use ZfcBase\Form\ProvidesEventsForm; use ZfcUser\Options\AuthenticationOptionsInterface; -use ZfcUser\Module as ZfcUser; class ChangePassword extends ProvidesEventsForm { @@ -19,6 +16,11 @@ public function __construct($name, AuthenticationOptionsInterface $options) { $this->setAuthenticationOptions($options); parent::__construct($name); + } + + public function init() + { + parent::init(); $this->add(array( 'name' => 'identity', diff --git a/src/ZfcUser/Form/Login.php b/src/ZfcUser/Form/Login.php index b6c5c460..fa84e0a3 100644 --- a/src/ZfcUser/Form/Login.php +++ b/src/ZfcUser/Form/Login.php @@ -2,11 +2,9 @@ namespace ZfcUser\Form; -use Zend\Form\Form; use Zend\Form\Element; use ZfcBase\Form\ProvidesEventsForm; use ZfcUser\Options\AuthenticationOptionsInterface; -use ZfcUser\Module as ZfcUser; class Login extends ProvidesEventsForm { @@ -19,7 +17,10 @@ public function __construct($name, AuthenticationOptionsInterface $options) { $this->setAuthenticationOptions($options); parent::__construct($name); + } + public function init() + { $this->add(array( 'name' => 'identity', 'options' => array( diff --git a/src/ZfcUser/Form/Register.php b/src/ZfcUser/Form/Register.php index a1c396a5..ff50ab79 100644 --- a/src/ZfcUser/Form/Register.php +++ b/src/ZfcUser/Form/Register.php @@ -22,6 +22,11 @@ public function __construct($name, RegistrationOptionsInterface $options) { $this->setRegistrationOptions($options); parent::__construct($name); + } + + public function init() + { + parent::init(); if ($this->getRegistrationOptions()->getUseRegistrationFormCaptcha()) { $this->add(array( @@ -45,7 +50,6 @@ public function __construct($name, RegistrationOptionsInterface $options) $this->add($this->captchaElement, array('name'=>'captcha')); } $this->get('submit')->setLabel('Register'); - $this->getEventManager()->trigger('init', $this); } public function setCaptchaElement(Captcha $captchaElement) diff --git a/src/ZfcUser/FormElementManagerFactory/Form/ChangeEmail.php b/src/ZfcUser/FormElementManagerFactory/Form/ChangeEmail.php new file mode 100644 index 00000000..790f6b3a --- /dev/null +++ b/src/ZfcUser/FormElementManagerFactory/Form/ChangeEmail.php @@ -0,0 +1,36 @@ +getServiceLocator(); + $options = $sm->get('zfcuser_module_options'); + $form = new Form\ChangeEmail(null, $options); + // Inject the FormElementManager to support custom FormElements + $formElementManager = $sm->get('FormElementManager'); + $form->getFormFactory()->setFormElementManager($formElementManager); + + $form->setInputFilter(new Form\ChangeEmailFilter( + $options, + new Validator\NoRecordExists(array( + 'mapper' => $sm->get('zfcuser_user_mapper'), + 'key' => 'email' + )) + )); + return $form; + } +} diff --git a/src/ZfcUser/FormElementManagerFactory/Form/ChangePassword.php b/src/ZfcUser/FormElementManagerFactory/Form/ChangePassword.php new file mode 100644 index 00000000..6aa2c1c5 --- /dev/null +++ b/src/ZfcUser/FormElementManagerFactory/Form/ChangePassword.php @@ -0,0 +1,29 @@ +getServiceLocator(); + $options = $sm->get('zfcuser_module_options'); + $form = new Form\ChangePassword(null, $options); + // Inject the FormElementManager to support custom FormElements + $formElementManager = $sm->get('FormElementManager'); + $form->getFormFactory()->setFormElementManager($formElementManager); + + $form->setInputFilter(new Form\ChangePasswordFilter($options)); + return $form; + } +} diff --git a/src/ZfcUser/FormElementManagerFactory/Form/Login.php b/src/ZfcUser/FormElementManagerFactory/Form/Login.php new file mode 100644 index 00000000..34f9e4ea --- /dev/null +++ b/src/ZfcUser/FormElementManagerFactory/Form/Login.php @@ -0,0 +1,29 @@ +getServiceLocator()->get('zfcuser_module_options'); + $form = new Form\Login(null, $options); + // Inject the FormElementManager to support custom FormElements + $form->getFormFactory()->setFormElementManager($formElementManager); + + $form->setInputFilter(new Form\LoginFilter($options)); + return $form; + } +} diff --git a/src/ZfcUser/FormElementManagerFactory/Form/Register.php b/src/ZfcUser/FormElementManagerFactory/Form/Register.php new file mode 100644 index 00000000..00944bec --- /dev/null +++ b/src/ZfcUser/FormElementManagerFactory/Form/Register.php @@ -0,0 +1,41 @@ +getServiceLocator(); + $options = $sm->get('zfcuser_module_options'); + $form = new Form\Register(null, $options); + // Inject the FormElementManager to support custom FormElements + $form->getFormFactory()->setFormElementManager($formElementManager); + + //$form->setCaptchaElement($sm->get('zfcuser_captcha_element')); + $form->setHydrator($sm->get('zfcuser_register_form_hydrator')); + $form->setInputFilter(new Form\RegisterFilter( + new Validator\NoRecordExists(array( + 'mapper' => $sm->get('zfcuser_user_mapper'), + 'key' => 'email' + )), + new Validator\NoRecordExists(array( + 'mapper' => $sm->get('zfcuser_user_mapper'), + 'key' => 'username' + )), + $options + )); + return $form; + } +} diff --git a/tests/ZfcUserTest/Controller/UserControllerTest.php b/tests/ZfcUserTest/Controller/UserControllerTest.php index 06c20582..06deb825 100644 --- a/tests/ZfcUserTest/Controller/UserControllerTest.php +++ b/tests/ZfcUserTest/Controller/UserControllerTest.php @@ -2,6 +2,7 @@ namespace ZfcUserTest\Controller; +use Zend\Form\FormElementManager; use ZfcUser\Controller\RedirectCallback; use ZfcUser\Controller\UserController as Controller; use Zend\Http\Response; @@ -964,7 +965,8 @@ public function testChangeEmailAction($status, $postRedirectGetReturn, $isValid, */ public function testSetterGetterServices( $methode, - $useServiceLocator, + $serviceLocator, + $usesFormElementManager, $servicePrototype, $serviceName, $callback = null @@ -981,12 +983,29 @@ public function testSetterGetterServices( } - if ($useServiceLocator) { + if ($serviceLocator) { $serviceLocator = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface'); - $serviceLocator->expects($this->once()) - ->method('get') - ->with($serviceName) - ->will($this->returnValue($servicePrototype)); + + if ($usesFormElementManager) { + $formElementManager = $this->getMock('Zend\Form\FormElementManager'); + + // This call is part of a temporary fix. Have to Mock the response, but don't want to require it. + $serviceLocator->expects($this->any()) + ->method('get') + ->with('FormElementManager') + ->will($this->returnValue($formElementManager)); + + $formElementManager->expects($this->once()) + ->method('get') + ->with($serviceName) + ->will($this->returnValue($servicePrototype)); + + } else { + $serviceLocator->expects($this->once()) + ->method('get') + ->with($serviceName) + ->will($this->returnValue($servicePrototype)); + } $controller->setServiceLocator($serviceLocator); } else { @@ -1092,23 +1111,22 @@ public function providerTestSetterGetterServices () }; - return array( // $methode, $useServiceLocator, $servicePrototype, $serviceName, $loginFormCallback - array('UserService', true, new UserService(), 'zfcuser_user_service' ), - array('UserService', false, new UserService(), null ), - array('RegisterForm', true, new Form(), 'zfcuser_register_form' ), - array('RegisterForm', false, new Form(), null ), - array('ChangePasswordForm', true, new Form(), 'zfcuser_change_password_form' ), - array('ChangePasswordForm', false, new Form(), null ), - array('ChangeEmailForm', true, new Form(), 'zfcuser_change_email_form' ), - array('ChangeEmailForm', false, new Form(), null ), - array('LoginForm', true, new Form(), 'zfcuser_login_form', $loginFormCallback[0] ), - array('LoginForm', true, new Form(), 'zfcuser_login_form', $loginFormCallback[1] ), - array('LoginForm', false, new Form(), null, $loginFormCallback[0] ), - array('LoginForm', false, new Form(), null, $loginFormCallback[1] ), - array('Options', true, new ModuleOptions(), 'zfcuser_module_options' ), - array('Options', false, new ModuleOptions(), null ), + array('UserService', true, false, new UserService(), 'zfcuser_user_service' ), + array('UserService', false, false, new UserService(), null ), + array('RegisterForm', true, true, new Form(), 'zfcuser_register_form' ), + array('RegisterForm', false, true, new Form(), null ), + array('ChangePasswordForm', true, true, new Form(), 'zfcuser_change_password_form' ), + array('ChangePasswordForm', false, true, new Form(), null ), + array('ChangeEmailForm', true, true, new Form(), 'zfcuser_change_email_form' ), + array('ChangeEmailForm', false, true, new Form(), null ), + array('LoginForm', true, true, new Form(), 'zfcuser_login_form', $loginFormCallback[0] ), + array('LoginForm', true, true, new Form(), 'zfcuser_login_form', $loginFormCallback[1] ), + array('LoginForm', false, true, new Form(), null, $loginFormCallback[0] ), + array('LoginForm', false, true, new Form(), null, $loginFormCallback[1] ), + array('Options', true, false, new ModuleOptions(), 'zfcuser_module_options' ), + array('Options', false, false, new ModuleOptions(), null ), ); } diff --git a/tests/ZfcUserTest/Form/BaseTest.php b/tests/ZfcUserTest/Form/BaseTest.php index e333717f..aa0db6fd 100644 --- a/tests/ZfcUserTest/Form/BaseTest.php +++ b/tests/ZfcUserTest/Form/BaseTest.php @@ -9,6 +9,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase public function testConstruct() { $form = new Form(); + $form->init(); $elements = $form->getElements(); diff --git a/tests/ZfcUserTest/Form/ChangeEmailTest.php b/tests/ZfcUserTest/Form/ChangeEmailTest.php index 22e835e3..8e161f20 100644 --- a/tests/ZfcUserTest/Form/ChangeEmailTest.php +++ b/tests/ZfcUserTest/Form/ChangeEmailTest.php @@ -14,6 +14,7 @@ public function testConstruct() $options = $this->getMock('ZfcUser\Options\AuthenticationOptionsInterface'); $form = new Form(null, $options); + $form->init(); $elements = $form->getElements(); diff --git a/tests/ZfcUserTest/Form/ChangePasswordTest.php b/tests/ZfcUserTest/Form/ChangePasswordTest.php index 690e3b80..422b0143 100644 --- a/tests/ZfcUserTest/Form/ChangePasswordTest.php +++ b/tests/ZfcUserTest/Form/ChangePasswordTest.php @@ -14,6 +14,7 @@ public function testConstruct() $options = $this->getMock('ZfcUser\Options\AuthenticationOptionsInterface'); $form = new Form(null, $options); + $form->init(); $elements = $form->getElements(); diff --git a/tests/ZfcUserTest/Form/LoginTest.php b/tests/ZfcUserTest/Form/LoginTest.php index 398a9814..1f0d98d6 100644 --- a/tests/ZfcUserTest/Form/LoginTest.php +++ b/tests/ZfcUserTest/Form/LoginTest.php @@ -18,6 +18,7 @@ public function testConstruct($authIdentityFields = array()) ->will($this->returnValue($authIdentityFields)); $form = new Form(null, $options); + $form->init(); $elements = $form->getElements(); @@ -47,6 +48,7 @@ public function testSetGetAuthenticationOptions() ->method('getAuthIdentityFields') ->will($this->returnValue(array())); $form = new Form(null, $options); + $form->init(); $this->assertSame($options, $form->getAuthenticationOptions()); } diff --git a/tests/ZfcUserTest/Form/RegisterTest.php b/tests/ZfcUserTest/Form/RegisterTest.php index f6dab831..8b988040 100644 --- a/tests/ZfcUserTest/Form/RegisterTest.php +++ b/tests/ZfcUserTest/Form/RegisterTest.php @@ -30,6 +30,7 @@ public function testConstruct($useCaptcha = false) } $form = new Form(null, $options); + $form->init(); $elements = $form->getElements(); @@ -62,6 +63,7 @@ public function testSetGetRegistrationOptions() ->method('getUseRegistrationFormCaptcha') ->will($this->returnValue(false)); $form = new Form(null, $options); + $form->init(); $this->assertSame($options, $form->getRegistrationOptions()); @@ -85,6 +87,7 @@ public function testSetCaptchaElement() $captcha = $this->getMock('\Zend\Form\Element\Captcha'); $form = new Form(null, $options); + $form->init(); $form->setCaptchaElement($captcha); diff --git a/tests/ZfcUserTest/FormElementManagerFactory/Form/ChangeEmailFormFactoryTest.php b/tests/ZfcUserTest/FormElementManagerFactory/Form/ChangeEmailFormFactoryTest.php new file mode 100644 index 00000000..5a87b226 --- /dev/null +++ b/tests/ZfcUserTest/FormElementManagerFactory/Form/ChangeEmailFormFactoryTest.php @@ -0,0 +1,26 @@ +setService('zfcuser_module_options', new ModuleOptions); + $serviceManager->setService('zfcuser_user_mapper', new UserMapper); + + $formElementManager = new FormElementManager(); + $formElementManager->setServiceLocator($serviceManager); + $serviceManager->setService('FormElementManager', $formElementManager); + + $factory = new ChangeEmailFactory(); + + $this->assertInstanceOf('ZfcUser\Form\ChangeEmail', $factory->createService($formElementManager)); + } +} diff --git a/tests/ZfcUserTest/FormElementManagerFactory/Form/ChangePasswordFormFactoryTest.php b/tests/ZfcUserTest/FormElementManagerFactory/Form/ChangePasswordFormFactoryTest.php new file mode 100644 index 00000000..48114ab6 --- /dev/null +++ b/tests/ZfcUserTest/FormElementManagerFactory/Form/ChangePasswordFormFactoryTest.php @@ -0,0 +1,26 @@ +setService('zfcuser_module_options', new ModuleOptions); + $serviceManager->setService('zfcuser_user_mapper', new UserMapper); + + $formElementManager = new FormElementManager(); + $formElementManager->setServiceLocator($serviceManager); + $serviceManager->setService('FormElementManager', $formElementManager); + + $factory = new ChangePasswordFactory(); + + $this->assertInstanceOf('ZfcUser\Form\ChangePassword', $factory->createService($formElementManager)); + } +} diff --git a/tests/ZfcUserTest/FormElementManagerFactory/Form/LoginFormFactoryTest.php b/tests/ZfcUserTest/FormElementManagerFactory/Form/LoginFormFactoryTest.php new file mode 100644 index 00000000..55fb658c --- /dev/null +++ b/tests/ZfcUserTest/FormElementManagerFactory/Form/LoginFormFactoryTest.php @@ -0,0 +1,24 @@ +setService('zfcuser_module_options', new ModuleOptions); + + $formElementManager = new FormElementManager(); + $formElementManager->setServiceLocator($serviceManager); + $serviceManager->setService('FormElementManager', $formElementManager); + + $factory = new LoginFactory(); + + $this->assertInstanceOf('ZfcUser\Form\Login', $factory->createService($formElementManager)); + } +} diff --git a/tests/ZfcUserTest/FormElementManagerFactory/Form/RegisterFormFactoryTest.php b/tests/ZfcUserTest/FormElementManagerFactory/Form/RegisterFormFactoryTest.php new file mode 100644 index 00000000..f4de11de --- /dev/null +++ b/tests/ZfcUserTest/FormElementManagerFactory/Form/RegisterFormFactoryTest.php @@ -0,0 +1,28 @@ +setService('zfcuser_module_options', new ModuleOptions); + $serviceManager->setService('zfcuser_user_mapper', new UserMapper); + $serviceManager->setService('zfcuser_register_form_hydrator', new ClassMethods()); + + $formElementManager = new FormElementManager(); + $formElementManager->setServiceLocator($serviceManager); + $serviceManager->setService('FormElementManager', $formElementManager); + + $factory = new RegisterFactory(); + + $this->assertInstanceOf('ZfcUser\Form\Register', $factory->createService($formElementManager)); + } +} diff --git a/view/zfc-user/user/_form.phtml b/view/zfc-user/user/_form.phtml new file mode 100644 index 00000000..0f64c709 --- /dev/null +++ b/view/zfc-user/user/_form.phtml @@ -0,0 +1,13 @@ +form()->openTag($form) ?> +
+ + getLabel() != null && !$element instanceof Zend\Form\Element\Button): ?> +
formLabel($element) ?>
+ +
formElement($element) . $this->formElementErrors($element) ?>
+ +
+redirect): ?> + + +form()->closeTag() ?> \ No newline at end of file diff --git a/view/zfc-user/user/changeemail.phtml b/view/zfc-user/user/changeemail.phtml index cddec3c0..a30591f1 100644 --- a/view/zfc-user/user/changeemail.phtml +++ b/view/zfc-user/user/changeemail.phtml @@ -11,25 +11,6 @@ $form = $this->changeEmailForm; $form->prepare(); $form->setAttribute('action', $this->url('zfcuser/changeemail')); $form->setAttribute('method', 'post'); - ?> -form()->openTag($form) ?> -
- - getLabel() != null): ?> -
formLabel($element) ?>
- - -
formButton($element) ?>
- -
formCaptcha($element) . $this->formElementErrors($element) ?>
- -
formInput($element) . $this->formElementErrors($element) ?>
- - -
- redirect): ?> - - - -form()->closeTag() ?> + + \ No newline at end of file diff --git a/view/zfc-user/user/changepassword.phtml b/view/zfc-user/user/changepassword.phtml index 7512dd09..62f3e890 100644 --- a/view/zfc-user/user/changepassword.phtml +++ b/view/zfc-user/user/changepassword.phtml @@ -14,34 +14,6 @@ $form->setAttribute('method', 'post'); $emailElement = $form->get('identity'); $emailElement->setValue($this->zfcUserIdentity()->getEmail()); - -echo $this->form()->openTag($form); - ?> -
-formElementErrors($form->get('identity')); ?> -
formInput($form->get('identity')); ?>
- -
formLabel($form->get('credential')); ?>
-
formInput($form->get('credential')) . $this->formElementErrors($form->get('credential')); -?>
- -
formLabel($form->get('newCredential')); ?>
-
formInput($form->get('newCredential')) . $this->formElementErrors($form->get('newCredential')); -?>
- -
formLabel($form->get('newCredentialVerify')); ?>
-
formInput($form->get('newCredentialVerify')) . $this->formElementErrors($form->get('newCredentialVerify')); -?>
- -
formInput($form->get('csrf')); -echo $this->formInput($form->get('submit')); -?>
- -
-form()->closeTag(); ?> + \ No newline at end of file diff --git a/view/zfc-user/user/login.phtml b/view/zfc-user/user/login.phtml index 66dbfd68..ca1fdfba 100644 --- a/view/zfc-user/user/login.phtml +++ b/view/zfc-user/user/login.phtml @@ -7,26 +7,8 @@ $form->setAttribute('action', $this->url('zfcuser/login')); $form->setAttribute('method', 'post'); ?> -form()->openTag($form) ?> - -
- formElementErrors($form->get('identity')) ?> - -
formLabel($form->get('identity')) ?>
-
formInput($form->get('identity')) ?>
- -
formLabel($form->get('credential')) ?>
-
formInput($form->get('credential')) ?>
- - redirect): ?> - - - -
formButton($form->get('submit')) ?>
-
- -form()->closeTag() ?> + enableRegistration) : ?> translate('Not registered?'); ?> translate('Sign up!'); ?> - + \ No newline at end of file diff --git a/view/zfc-user/user/register.phtml b/view/zfc-user/user/register.phtml index 102b7ef0..f34afcf3 100644 --- a/view/zfc-user/user/register.phtml +++ b/view/zfc-user/user/register.phtml @@ -11,22 +11,4 @@ $form->setAttribute('action', $this->url('zfcuser/register')); $form->setAttribute('method', 'post'); ?> -form()->openTag($form) ?> -
- - -
formLabel($element) ?>
- - -
formButton($element) ?>
- -
formCaptcha($element) . $this->formElementErrors($element) ?>
- -
formInput($element) . $this->formElementErrors($element) ?>
- - -
- redirect): ?> - - -form()->closeTag() ?> + \ No newline at end of file From 46bc132154f0f4aec33d453db3e92fae3ca38f3e Mon Sep 17 00:00:00 2001 From: Clayton Daley Date: Sun, 22 Mar 2015 17:28:16 -0400 Subject: [PATCH 26/59] - restore original tests - tweak travis.yml --- .travis.yml | 4 -- .../Controller/UserControllerTest.php | 60 +++++++------------ tests/ZfcUserTest/Form/BaseTest.php | 1 - tests/ZfcUserTest/Form/ChangeEmailTest.php | 1 - tests/ZfcUserTest/Form/ChangePasswordTest.php | 1 - tests/ZfcUserTest/Form/LoginTest.php | 2 - tests/ZfcUserTest/Form/RegisterTest.php | 3 - 7 files changed, 21 insertions(+), 51 deletions(-) diff --git a/.travis.yml b/.travis.yml index 920dc951..f5d82951 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,10 +21,6 @@ script: after_script: - php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml -notifications: - email: false - irc: "irc.freenode.org#zftalk.dev" - matrix: fast_finish: true allow_failures: diff --git a/tests/ZfcUserTest/Controller/UserControllerTest.php b/tests/ZfcUserTest/Controller/UserControllerTest.php index 06deb825..06c20582 100644 --- a/tests/ZfcUserTest/Controller/UserControllerTest.php +++ b/tests/ZfcUserTest/Controller/UserControllerTest.php @@ -2,7 +2,6 @@ namespace ZfcUserTest\Controller; -use Zend\Form\FormElementManager; use ZfcUser\Controller\RedirectCallback; use ZfcUser\Controller\UserController as Controller; use Zend\Http\Response; @@ -965,8 +964,7 @@ public function testChangeEmailAction($status, $postRedirectGetReturn, $isValid, */ public function testSetterGetterServices( $methode, - $serviceLocator, - $usesFormElementManager, + $useServiceLocator, $servicePrototype, $serviceName, $callback = null @@ -983,29 +981,12 @@ public function testSetterGetterServices( } - if ($serviceLocator) { + if ($useServiceLocator) { $serviceLocator = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface'); - - if ($usesFormElementManager) { - $formElementManager = $this->getMock('Zend\Form\FormElementManager'); - - // This call is part of a temporary fix. Have to Mock the response, but don't want to require it. - $serviceLocator->expects($this->any()) - ->method('get') - ->with('FormElementManager') - ->will($this->returnValue($formElementManager)); - - $formElementManager->expects($this->once()) - ->method('get') - ->with($serviceName) - ->will($this->returnValue($servicePrototype)); - - } else { - $serviceLocator->expects($this->once()) - ->method('get') - ->with($serviceName) - ->will($this->returnValue($servicePrototype)); - } + $serviceLocator->expects($this->once()) + ->method('get') + ->with($serviceName) + ->will($this->returnValue($servicePrototype)); $controller->setServiceLocator($serviceLocator); } else { @@ -1111,22 +1092,23 @@ public function providerTestSetterGetterServices () }; + return array( // $methode, $useServiceLocator, $servicePrototype, $serviceName, $loginFormCallback - array('UserService', true, false, new UserService(), 'zfcuser_user_service' ), - array('UserService', false, false, new UserService(), null ), - array('RegisterForm', true, true, new Form(), 'zfcuser_register_form' ), - array('RegisterForm', false, true, new Form(), null ), - array('ChangePasswordForm', true, true, new Form(), 'zfcuser_change_password_form' ), - array('ChangePasswordForm', false, true, new Form(), null ), - array('ChangeEmailForm', true, true, new Form(), 'zfcuser_change_email_form' ), - array('ChangeEmailForm', false, true, new Form(), null ), - array('LoginForm', true, true, new Form(), 'zfcuser_login_form', $loginFormCallback[0] ), - array('LoginForm', true, true, new Form(), 'zfcuser_login_form', $loginFormCallback[1] ), - array('LoginForm', false, true, new Form(), null, $loginFormCallback[0] ), - array('LoginForm', false, true, new Form(), null, $loginFormCallback[1] ), - array('Options', true, false, new ModuleOptions(), 'zfcuser_module_options' ), - array('Options', false, false, new ModuleOptions(), null ), + array('UserService', true, new UserService(), 'zfcuser_user_service' ), + array('UserService', false, new UserService(), null ), + array('RegisterForm', true, new Form(), 'zfcuser_register_form' ), + array('RegisterForm', false, new Form(), null ), + array('ChangePasswordForm', true, new Form(), 'zfcuser_change_password_form' ), + array('ChangePasswordForm', false, new Form(), null ), + array('ChangeEmailForm', true, new Form(), 'zfcuser_change_email_form' ), + array('ChangeEmailForm', false, new Form(), null ), + array('LoginForm', true, new Form(), 'zfcuser_login_form', $loginFormCallback[0] ), + array('LoginForm', true, new Form(), 'zfcuser_login_form', $loginFormCallback[1] ), + array('LoginForm', false, new Form(), null, $loginFormCallback[0] ), + array('LoginForm', false, new Form(), null, $loginFormCallback[1] ), + array('Options', true, new ModuleOptions(), 'zfcuser_module_options' ), + array('Options', false, new ModuleOptions(), null ), ); } diff --git a/tests/ZfcUserTest/Form/BaseTest.php b/tests/ZfcUserTest/Form/BaseTest.php index aa0db6fd..e333717f 100644 --- a/tests/ZfcUserTest/Form/BaseTest.php +++ b/tests/ZfcUserTest/Form/BaseTest.php @@ -9,7 +9,6 @@ class BaseTest extends \PHPUnit_Framework_TestCase public function testConstruct() { $form = new Form(); - $form->init(); $elements = $form->getElements(); diff --git a/tests/ZfcUserTest/Form/ChangeEmailTest.php b/tests/ZfcUserTest/Form/ChangeEmailTest.php index 8e161f20..22e835e3 100644 --- a/tests/ZfcUserTest/Form/ChangeEmailTest.php +++ b/tests/ZfcUserTest/Form/ChangeEmailTest.php @@ -14,7 +14,6 @@ public function testConstruct() $options = $this->getMock('ZfcUser\Options\AuthenticationOptionsInterface'); $form = new Form(null, $options); - $form->init(); $elements = $form->getElements(); diff --git a/tests/ZfcUserTest/Form/ChangePasswordTest.php b/tests/ZfcUserTest/Form/ChangePasswordTest.php index 422b0143..690e3b80 100644 --- a/tests/ZfcUserTest/Form/ChangePasswordTest.php +++ b/tests/ZfcUserTest/Form/ChangePasswordTest.php @@ -14,7 +14,6 @@ public function testConstruct() $options = $this->getMock('ZfcUser\Options\AuthenticationOptionsInterface'); $form = new Form(null, $options); - $form->init(); $elements = $form->getElements(); diff --git a/tests/ZfcUserTest/Form/LoginTest.php b/tests/ZfcUserTest/Form/LoginTest.php index 1f0d98d6..398a9814 100644 --- a/tests/ZfcUserTest/Form/LoginTest.php +++ b/tests/ZfcUserTest/Form/LoginTest.php @@ -18,7 +18,6 @@ public function testConstruct($authIdentityFields = array()) ->will($this->returnValue($authIdentityFields)); $form = new Form(null, $options); - $form->init(); $elements = $form->getElements(); @@ -48,7 +47,6 @@ public function testSetGetAuthenticationOptions() ->method('getAuthIdentityFields') ->will($this->returnValue(array())); $form = new Form(null, $options); - $form->init(); $this->assertSame($options, $form->getAuthenticationOptions()); } diff --git a/tests/ZfcUserTest/Form/RegisterTest.php b/tests/ZfcUserTest/Form/RegisterTest.php index 8b988040..f6dab831 100644 --- a/tests/ZfcUserTest/Form/RegisterTest.php +++ b/tests/ZfcUserTest/Form/RegisterTest.php @@ -30,7 +30,6 @@ public function testConstruct($useCaptcha = false) } $form = new Form(null, $options); - $form->init(); $elements = $form->getElements(); @@ -63,7 +62,6 @@ public function testSetGetRegistrationOptions() ->method('getUseRegistrationFormCaptcha') ->will($this->returnValue(false)); $form = new Form(null, $options); - $form->init(); $this->assertSame($options, $form->getRegistrationOptions()); @@ -87,7 +85,6 @@ public function testSetCaptchaElement() $captcha = $this->getMock('\Zend\Form\Element\Captcha'); $form = new Form(null, $options); - $form->init(); $form->setCaptchaElement($captcha); From 739ba8cd5acba959008c131cae88541afb06c35a Mon Sep 17 00:00:00 2001 From: Clayton Daley Date: Sun, 22 Mar 2015 17:49:18 -0400 Subject: [PATCH 27/59] - Prepared to restore backwards compatibility --- config/module.config.php | 8 ++++---- .../Form/ChangeEmail.php | 0 .../Form/ChangePassword.php | 0 .../{FormElementManagerFactory => Factory}/Form/Login.php | 0 .../Form/Register.php | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename src/ZfcUser/{FormElementManagerFactory => Factory}/Form/ChangeEmail.php (100%) rename src/ZfcUser/{FormElementManagerFactory => Factory}/Form/ChangePassword.php (100%) rename src/ZfcUser/{FormElementManagerFactory => Factory}/Form/Login.php (100%) rename src/ZfcUser/{FormElementManagerFactory => Factory}/Form/Register.php (100%) diff --git a/config/module.config.php b/config/module.config.php index 71c03e9f..a40176b9 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -8,10 +8,10 @@ ), 'form_elements' => array( 'factories' => array( - 'zfcuser_login_form' => 'ZfcUser\FormElementManagerFactory\Form\Login', - 'zfcuser_register_form' => 'ZfcUser\FormElementManagerFactory\Form\Register', - 'zfcuser_change_password_form' => 'ZfcUser\FormElementManagerFactory\Form\ChangePassword', - 'zfcuser_change_email_form' => 'ZfcUser\FormElementManagerFactory\Form\ChangeEmail', + 'zfcuser_login_form' => 'ZfcUser\Factory\Form\Login', + 'zfcuser_register_form' => 'ZfcUser\Factory\Form\Register', + 'zfcuser_change_password_form' => 'ZfcUser\Factory\Form\ChangePassword', + 'zfcuser_change_email_form' => 'ZfcUser\Factory\Form\ChangeEmail', ) ), diff --git a/src/ZfcUser/FormElementManagerFactory/Form/ChangeEmail.php b/src/ZfcUser/Factory/Form/ChangeEmail.php similarity index 100% rename from src/ZfcUser/FormElementManagerFactory/Form/ChangeEmail.php rename to src/ZfcUser/Factory/Form/ChangeEmail.php diff --git a/src/ZfcUser/FormElementManagerFactory/Form/ChangePassword.php b/src/ZfcUser/Factory/Form/ChangePassword.php similarity index 100% rename from src/ZfcUser/FormElementManagerFactory/Form/ChangePassword.php rename to src/ZfcUser/Factory/Form/ChangePassword.php diff --git a/src/ZfcUser/FormElementManagerFactory/Form/Login.php b/src/ZfcUser/Factory/Form/Login.php similarity index 100% rename from src/ZfcUser/FormElementManagerFactory/Form/Login.php rename to src/ZfcUser/Factory/Form/Login.php diff --git a/src/ZfcUser/FormElementManagerFactory/Form/Register.php b/src/ZfcUser/Factory/Form/Register.php similarity index 100% rename from src/ZfcUser/FormElementManagerFactory/Form/Register.php rename to src/ZfcUser/Factory/Form/Register.php From af4f040aff56ac5bacbaed5db6dc0ee309ee9b6a Mon Sep 17 00:00:00 2001 From: Ilko Kacharov Date: Wed, 29 Apr 2015 10:29:12 +0300 Subject: [PATCH 28/59] IsEmpty check in storage should not trigger additional read from the mapper. --- src/ZfcUser/Authentication/Storage/Db.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ZfcUser/Authentication/Storage/Db.php b/src/ZfcUser/Authentication/Storage/Db.php index 3a5b1d36..d218e87e 100644 --- a/src/ZfcUser/Authentication/Storage/Db.php +++ b/src/ZfcUser/Authentication/Storage/Db.php @@ -42,7 +42,7 @@ public function isEmpty() if ($this->getStorage()->isEmpty()) { return true; } - $identity = $this->read(); + $identity = $this->getStorage()->read(); if ($identity === null) { $this->clear(); return true; From 3035a2522b213e6e306fbf5d935f6deb6e8f5a26 Mon Sep 17 00:00:00 2001 From: Clayton Daley Date: Wed, 6 May 2015 16:54:03 -0400 Subject: [PATCH 29/59] - Dirty hack to pass in FormElementManager state --- src/ZfcUser/Factory/Form/ChangeEmail.php | 22 ++++++++++++++---- src/ZfcUser/Factory/Form/ChangePassword.php | 22 ++++++++++++++---- src/ZfcUser/Factory/Form/Login.php | 21 ++++++++++++++--- src/ZfcUser/Factory/Form/Register.php | 21 ++++++++++++++--- src/ZfcUser/Form/Base.php | 5 ++-- src/ZfcUser/Form/ChangeEmail.php | 4 ++++ src/ZfcUser/Form/ChangePassword.php | 4 ++++ src/ZfcUser/Form/Login.php | 4 ++++ src/ZfcUser/Form/Register.php | 4 ++++ .../Controller/UserControllerTest.php | 23 +++++++++++++++---- .../Form/ChangeEmailFormFactoryTest.php | 2 +- .../Form/ChangePasswordFormFactoryTest.php | 2 +- .../Form/LoginFormFactoryTest.php | 2 +- .../Form/RegisterFormFactoryTest.php | 2 +- 14 files changed, 112 insertions(+), 26 deletions(-) rename tests/ZfcUserTest/{FormElementManagerFactory => Factory}/Form/ChangeEmailFormFactoryTest.php (91%) rename tests/ZfcUserTest/{FormElementManagerFactory => Factory}/Form/ChangePasswordFormFactoryTest.php (91%) rename tests/ZfcUserTest/{FormElementManagerFactory => Factory}/Form/LoginFormFactoryTest.php (91%) rename tests/ZfcUserTest/{FormElementManagerFactory => Factory}/Form/RegisterFormFactoryTest.php (93%) diff --git a/src/ZfcUser/Factory/Form/ChangeEmail.php b/src/ZfcUser/Factory/Form/ChangeEmail.php index 790f6b3a..bcc2627c 100644 --- a/src/ZfcUser/Factory/Form/ChangeEmail.php +++ b/src/ZfcUser/Factory/Form/ChangeEmail.php @@ -6,8 +6,9 @@ * Time: 9:34 AM */ -namespace ZfcUser\FormElementManagerFactory\Form; +namespace ZfcUser\Factory\Form; +use Zend\Form\FormElementManager; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; use ZfcUser\Form; @@ -17,12 +18,21 @@ class ChangeEmail implements FactoryInterface { public function createService(ServiceLocatorInterface $formElementManager) { - $sm = $formElementManager->getServiceLocator(); + if ($formElementManager instanceof FormElementManager) { + $sm = $formElementManager->getServiceLocator(); + $fem = $formElementManager; + } else { + $sm = $formElementManager; + $fem = $sm->get('FormElementManager'); + } + $options = $sm->get('zfcuser_module_options'); + $options = clone($options); + $options->fem = true; + $form = new Form\ChangeEmail(null, $options); // Inject the FormElementManager to support custom FormElements - $formElementManager = $sm->get('FormElementManager'); - $form->getFormFactory()->setFormElementManager($formElementManager); + $form->getFormFactory()->setFormElementManager($fem); $form->setInputFilter(new Form\ChangeEmailFilter( $options, @@ -31,6 +41,10 @@ public function createService(ServiceLocatorInterface $formElementManager) 'key' => 'email' )) )); + + if (!$formElementManager instanceof FormElementManager) { + $form->init(); + } return $form; } } diff --git a/src/ZfcUser/Factory/Form/ChangePassword.php b/src/ZfcUser/Factory/Form/ChangePassword.php index 6aa2c1c5..853053c4 100644 --- a/src/ZfcUser/Factory/Form/ChangePassword.php +++ b/src/ZfcUser/Factory/Form/ChangePassword.php @@ -6,8 +6,9 @@ * Time: 9:34 AM */ -namespace ZfcUser\FormElementManagerFactory\Form; +namespace ZfcUser\Factory\Form; +use Zend\Form\FormElementManager; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; use ZfcUser\Form; @@ -16,14 +17,27 @@ class ChangePassword implements FactoryInterface { public function createService(ServiceLocatorInterface $formElementManager) { - $sm = $formElementManager->getServiceLocator(); + if ($formElementManager instanceof FormElementManager) { + $sm = $formElementManager->getServiceLocator(); + $fem = $formElementManager; + } else { + $sm = $formElementManager; + $fem = $sm->get('FormElementManager'); + } + $options = $sm->get('zfcuser_module_options'); + $options = clone($options); + $options->fem = true; + $form = new Form\ChangePassword(null, $options); // Inject the FormElementManager to support custom FormElements - $formElementManager = $sm->get('FormElementManager'); - $form->getFormFactory()->setFormElementManager($formElementManager); + $form->getFormFactory()->setFormElementManager($fem); $form->setInputFilter(new Form\ChangePasswordFilter($options)); + + if (!$formElementManager instanceof FormElementManager) { + $form->init(); + } return $form; } } diff --git a/src/ZfcUser/Factory/Form/Login.php b/src/ZfcUser/Factory/Form/Login.php index 34f9e4ea..4dc4c347 100644 --- a/src/ZfcUser/Factory/Form/Login.php +++ b/src/ZfcUser/Factory/Form/Login.php @@ -6,7 +6,7 @@ * Time: 9:34 AM */ -namespace ZfcUser\FormElementManagerFactory\Form; +namespace ZfcUser\Factory\Form; use Zend\Form\FormElementManager; use Zend\ServiceManager\FactoryInterface; @@ -17,13 +17,28 @@ class Login implements FactoryInterface { public function createService(ServiceLocatorInterface $formElementManager) { + if ($formElementManager instanceof FormElementManager) { + $sm = $formElementManager->getServiceLocator(); + $fem = $formElementManager; + } else { + $sm = $formElementManager; + $fem = $sm->get('FormElementManager'); + } + /** @var FormElementManager $formElementManager */ - $options = $formElementManager->getServiceLocator()->get('zfcuser_module_options'); + $options = $sm->get('zfcuser_module_options'); + $options = clone($options); + $options->fem = true; + $form = new Form\Login(null, $options); // Inject the FormElementManager to support custom FormElements - $form->getFormFactory()->setFormElementManager($formElementManager); + $form->getFormFactory()->setFormElementManager($fem); $form->setInputFilter(new Form\LoginFilter($options)); + + if (!$formElementManager instanceof FormElementManager) { + $form->init(); + } return $form; } } diff --git a/src/ZfcUser/Factory/Form/Register.php b/src/ZfcUser/Factory/Form/Register.php index 00944bec..5909ffed 100644 --- a/src/ZfcUser/Factory/Form/Register.php +++ b/src/ZfcUser/Factory/Form/Register.php @@ -6,8 +6,9 @@ * Time: 9:34 AM */ -namespace ZfcUser\FormElementManagerFactory\Form; +namespace ZfcUser\Factory\Form; +use Zend\Form\FormElementManager; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; use ZfcUser\Form; @@ -17,11 +18,21 @@ class Register implements FactoryInterface { public function createService(ServiceLocatorInterface $formElementManager) { - $sm = $formElementManager->getServiceLocator(); + if ($formElementManager instanceof FormElementManager) { + $sm = $formElementManager->getServiceLocator(); + $fem = $formElementManager; + } else { + $sm = $formElementManager; + $fem = $sm->get('FormElementManager'); + } + $options = $sm->get('zfcuser_module_options'); + $options = clone($options); + $options->fem = true; + $form = new Form\Register(null, $options); // Inject the FormElementManager to support custom FormElements - $form->getFormFactory()->setFormElementManager($formElementManager); + $form->getFormFactory()->setFormElementManager($fem); //$form->setCaptchaElement($sm->get('zfcuser_captcha_element')); $form->setHydrator($sm->get('zfcuser_register_form_hydrator')); @@ -36,6 +47,10 @@ public function createService(ServiceLocatorInterface $formElementManager) )), $options )); + + if (!$formElementManager instanceof FormElementManager) { + $form->init(); + } return $form; } } diff --git a/src/ZfcUser/Form/Base.php b/src/ZfcUser/Form/Base.php index 8879e589..e31a0196 100644 --- a/src/ZfcUser/Form/Base.php +++ b/src/ZfcUser/Form/Base.php @@ -10,10 +10,7 @@ class Base extends ProvidesEventsForm public function __construct() { parent::__construct(); - } - public function init() - { $this->add(array( 'name' => 'username', 'options' => array( @@ -92,4 +89,6 @@ public function init() $this->getEventManager()->trigger('init', $this); } + + public function init() {} } diff --git a/src/ZfcUser/Form/ChangeEmail.php b/src/ZfcUser/Form/ChangeEmail.php index 95a24393..f9d5c081 100644 --- a/src/ZfcUser/Form/ChangeEmail.php +++ b/src/ZfcUser/Form/ChangeEmail.php @@ -11,6 +11,10 @@ public function __construct($name, AuthenticationOptionsInterface $options) { $this->setAuthenticationOptions($options); parent::__construct($name); + + if (!property_exists($options, "fem")) { + $this->init(); + } } public function init() diff --git a/src/ZfcUser/Form/ChangePassword.php b/src/ZfcUser/Form/ChangePassword.php index d697c081..1b2d8a63 100644 --- a/src/ZfcUser/Form/ChangePassword.php +++ b/src/ZfcUser/Form/ChangePassword.php @@ -16,6 +16,10 @@ public function __construct($name, AuthenticationOptionsInterface $options) { $this->setAuthenticationOptions($options); parent::__construct($name); + + if (!property_exists($options, "fem")) { + $this->init(); + } } public function init() diff --git a/src/ZfcUser/Form/Login.php b/src/ZfcUser/Form/Login.php index fa84e0a3..3d0ae6d3 100644 --- a/src/ZfcUser/Form/Login.php +++ b/src/ZfcUser/Form/Login.php @@ -17,6 +17,10 @@ public function __construct($name, AuthenticationOptionsInterface $options) { $this->setAuthenticationOptions($options); parent::__construct($name); + + if (!property_exists($options, "fem")) { + $this->init(); + } } public function init() diff --git a/src/ZfcUser/Form/Register.php b/src/ZfcUser/Form/Register.php index ff50ab79..c3f2f76a 100644 --- a/src/ZfcUser/Form/Register.php +++ b/src/ZfcUser/Form/Register.php @@ -22,6 +22,10 @@ public function __construct($name, RegistrationOptionsInterface $options) { $this->setRegistrationOptions($options); parent::__construct($name); + + if (!property_exists($options, "fem")) { + $this->init(); + } } public function init() diff --git a/tests/ZfcUserTest/Controller/UserControllerTest.php b/tests/ZfcUserTest/Controller/UserControllerTest.php index 06c20582..bd71e344 100644 --- a/tests/ZfcUserTest/Controller/UserControllerTest.php +++ b/tests/ZfcUserTest/Controller/UserControllerTest.php @@ -2,6 +2,7 @@ namespace ZfcUserTest\Controller; +use Zend\Form\FormElementManager; use ZfcUser\Controller\RedirectCallback; use ZfcUser\Controller\UserController as Controller; use Zend\Http\Response; @@ -983,11 +984,23 @@ public function testSetterGetterServices( if ($useServiceLocator) { $serviceLocator = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface'); - $serviceLocator->expects($this->once()) - ->method('get') - ->with($serviceName) - ->will($this->returnValue($servicePrototype)); - + $formElementManager = $this->getMock('Zend\Form\FormElementManager'); + # Forms now use the FormElementManager so we need mock accordingly + if ($servicePrototype instanceof Form){ + $serviceLocator->expects($this->once()) + ->method('get') + ->with('FormElementManager') + ->will($this->returnValue($formElementManager)); + $formElementManager->expects($this->once()) + ->method('get') + ->with($serviceName) + ->will($this->returnValue($servicePrototype)); + } else { + $serviceLocator->expects($this->once()) + ->method('get') + ->with($serviceName) + ->will($this->returnValue($servicePrototype)); + } $controller->setServiceLocator($serviceLocator); } else { call_user_func(array($controller, 'set' . $methode), $servicePrototype); diff --git a/tests/ZfcUserTest/FormElementManagerFactory/Form/ChangeEmailFormFactoryTest.php b/tests/ZfcUserTest/Factory/Form/ChangeEmailFormFactoryTest.php similarity index 91% rename from tests/ZfcUserTest/FormElementManagerFactory/Form/ChangeEmailFormFactoryTest.php rename to tests/ZfcUserTest/Factory/Form/ChangeEmailFormFactoryTest.php index 5a87b226..c9bc3d0f 100644 --- a/tests/ZfcUserTest/FormElementManagerFactory/Form/ChangeEmailFormFactoryTest.php +++ b/tests/ZfcUserTest/Factory/Form/ChangeEmailFormFactoryTest.php @@ -3,7 +3,7 @@ use Zend\Form\FormElementManager; use Zend\ServiceManager\ServiceManager; -use ZfcUser\FormElementManagerFactory\Form\ChangeEmail as ChangeEmailFactory; +use ZfcUser\Factory\Form\ChangeEmail as ChangeEmailFactory; use ZfcUser\Options\ModuleOptions; use ZfcUser\Mapper\User as UserMapper; diff --git a/tests/ZfcUserTest/FormElementManagerFactory/Form/ChangePasswordFormFactoryTest.php b/tests/ZfcUserTest/Factory/Form/ChangePasswordFormFactoryTest.php similarity index 91% rename from tests/ZfcUserTest/FormElementManagerFactory/Form/ChangePasswordFormFactoryTest.php rename to tests/ZfcUserTest/Factory/Form/ChangePasswordFormFactoryTest.php index 48114ab6..17f79fee 100644 --- a/tests/ZfcUserTest/FormElementManagerFactory/Form/ChangePasswordFormFactoryTest.php +++ b/tests/ZfcUserTest/Factory/Form/ChangePasswordFormFactoryTest.php @@ -3,7 +3,7 @@ use Zend\Form\FormElementManager; use Zend\ServiceManager\ServiceManager; -use ZfcUser\FormElementManagerFactory\Form\ChangePassword as ChangePasswordFactory; +use ZfcUser\Factory\Form\ChangePassword as ChangePasswordFactory; use ZfcUser\Options\ModuleOptions; use ZfcUser\Mapper\User as UserMapper; diff --git a/tests/ZfcUserTest/FormElementManagerFactory/Form/LoginFormFactoryTest.php b/tests/ZfcUserTest/Factory/Form/LoginFormFactoryTest.php similarity index 91% rename from tests/ZfcUserTest/FormElementManagerFactory/Form/LoginFormFactoryTest.php rename to tests/ZfcUserTest/Factory/Form/LoginFormFactoryTest.php index 55fb658c..8f07e0d8 100644 --- a/tests/ZfcUserTest/FormElementManagerFactory/Form/LoginFormFactoryTest.php +++ b/tests/ZfcUserTest/Factory/Form/LoginFormFactoryTest.php @@ -3,7 +3,7 @@ use Zend\Form\FormElementManager; use Zend\ServiceManager\ServiceManager; -use ZfcUser\FormElementManagerFactory\Form\Login as LoginFactory; +use ZfcUser\Factory\Form\Login as LoginFactory; use ZfcUser\Options\ModuleOptions; class LoginFormFactoryTest extends \PHPUnit_Framework_TestCase diff --git a/tests/ZfcUserTest/FormElementManagerFactory/Form/RegisterFormFactoryTest.php b/tests/ZfcUserTest/Factory/Form/RegisterFormFactoryTest.php similarity index 93% rename from tests/ZfcUserTest/FormElementManagerFactory/Form/RegisterFormFactoryTest.php rename to tests/ZfcUserTest/Factory/Form/RegisterFormFactoryTest.php index f4de11de..1d1a601a 100644 --- a/tests/ZfcUserTest/FormElementManagerFactory/Form/RegisterFormFactoryTest.php +++ b/tests/ZfcUserTest/Factory/Form/RegisterFormFactoryTest.php @@ -4,7 +4,7 @@ use Zend\Form\FormElementManager; use Zend\ServiceManager\ServiceManager; use Zend\Stdlib\Hydrator\ClassMethods; -use ZfcUser\FormElementManagerFactory\Form\Register as RegisterFactory; +use ZfcUser\Factory\Form\Register as RegisterFactory; use ZfcUser\Options\ModuleOptions; use ZfcUser\Mapper\User as UserMapper; From c3dccbdc6af59b96838a0b80a79e12f5969f0c00 Mon Sep 17 00:00:00 2001 From: Clayton Daley Date: Wed, 6 May 2015 17:16:44 -0400 Subject: [PATCH 30/59] - fix styling issues --- src/ZfcUser/Form/Base.php | 4 +++- tests/ZfcUserTest/Controller/UserControllerTest.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ZfcUser/Form/Base.php b/src/ZfcUser/Form/Base.php index e31a0196..f6b47faf 100644 --- a/src/ZfcUser/Form/Base.php +++ b/src/ZfcUser/Form/Base.php @@ -90,5 +90,7 @@ public function __construct() $this->getEventManager()->trigger('init', $this); } - public function init() {} + public function init() + { + } } diff --git a/tests/ZfcUserTest/Controller/UserControllerTest.php b/tests/ZfcUserTest/Controller/UserControllerTest.php index bd71e344..c08759f1 100644 --- a/tests/ZfcUserTest/Controller/UserControllerTest.php +++ b/tests/ZfcUserTest/Controller/UserControllerTest.php @@ -986,7 +986,7 @@ public function testSetterGetterServices( $serviceLocator = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface'); $formElementManager = $this->getMock('Zend\Form\FormElementManager'); # Forms now use the FormElementManager so we need mock accordingly - if ($servicePrototype instanceof Form){ + if ($servicePrototype instanceof Form) { $serviceLocator->expects($this->once()) ->method('get') ->with('FormElementManager') From b1b6835d05d6dce97a951732660a3c6db6f8203c Mon Sep 17 00:00:00 2001 From: Clayton Daley Date: Wed, 6 May 2015 18:36:23 -0400 Subject: [PATCH 31/59] - revert attempt to dynamically call `init()` in constructor based on the use of FEM --- src/ZfcUser/Factory/Form/ChangeEmail.php | 6 ------ src/ZfcUser/Factory/Form/ChangePassword.php | 6 ------ src/ZfcUser/Factory/Form/Login.php | 6 ------ src/ZfcUser/Factory/Form/Register.php | 6 ------ src/ZfcUser/Form/ChangeEmail.php | 7 ------- src/ZfcUser/Form/ChangePassword.php | 9 --------- src/ZfcUser/Form/Login.php | 7 ------- src/ZfcUser/Form/Register.php | 9 --------- 8 files changed, 56 deletions(-) diff --git a/src/ZfcUser/Factory/Form/ChangeEmail.php b/src/ZfcUser/Factory/Form/ChangeEmail.php index bcc2627c..fbb4d081 100644 --- a/src/ZfcUser/Factory/Form/ChangeEmail.php +++ b/src/ZfcUser/Factory/Form/ChangeEmail.php @@ -27,9 +27,6 @@ public function createService(ServiceLocatorInterface $formElementManager) } $options = $sm->get('zfcuser_module_options'); - $options = clone($options); - $options->fem = true; - $form = new Form\ChangeEmail(null, $options); // Inject the FormElementManager to support custom FormElements $form->getFormFactory()->setFormElementManager($fem); @@ -42,9 +39,6 @@ public function createService(ServiceLocatorInterface $formElementManager) )) )); - if (!$formElementManager instanceof FormElementManager) { - $form->init(); - } return $form; } } diff --git a/src/ZfcUser/Factory/Form/ChangePassword.php b/src/ZfcUser/Factory/Form/ChangePassword.php index 853053c4..42f7065a 100644 --- a/src/ZfcUser/Factory/Form/ChangePassword.php +++ b/src/ZfcUser/Factory/Form/ChangePassword.php @@ -26,18 +26,12 @@ public function createService(ServiceLocatorInterface $formElementManager) } $options = $sm->get('zfcuser_module_options'); - $options = clone($options); - $options->fem = true; - $form = new Form\ChangePassword(null, $options); // Inject the FormElementManager to support custom FormElements $form->getFormFactory()->setFormElementManager($fem); $form->setInputFilter(new Form\ChangePasswordFilter($options)); - if (!$formElementManager instanceof FormElementManager) { - $form->init(); - } return $form; } } diff --git a/src/ZfcUser/Factory/Form/Login.php b/src/ZfcUser/Factory/Form/Login.php index 4dc4c347..4690d0ba 100644 --- a/src/ZfcUser/Factory/Form/Login.php +++ b/src/ZfcUser/Factory/Form/Login.php @@ -27,18 +27,12 @@ public function createService(ServiceLocatorInterface $formElementManager) /** @var FormElementManager $formElementManager */ $options = $sm->get('zfcuser_module_options'); - $options = clone($options); - $options->fem = true; - $form = new Form\Login(null, $options); // Inject the FormElementManager to support custom FormElements $form->getFormFactory()->setFormElementManager($fem); $form->setInputFilter(new Form\LoginFilter($options)); - if (!$formElementManager instanceof FormElementManager) { - $form->init(); - } return $form; } } diff --git a/src/ZfcUser/Factory/Form/Register.php b/src/ZfcUser/Factory/Form/Register.php index 5909ffed..7bf24df1 100644 --- a/src/ZfcUser/Factory/Form/Register.php +++ b/src/ZfcUser/Factory/Form/Register.php @@ -27,9 +27,6 @@ public function createService(ServiceLocatorInterface $formElementManager) } $options = $sm->get('zfcuser_module_options'); - $options = clone($options); - $options->fem = true; - $form = new Form\Register(null, $options); // Inject the FormElementManager to support custom FormElements $form->getFormFactory()->setFormElementManager($fem); @@ -48,9 +45,6 @@ public function createService(ServiceLocatorInterface $formElementManager) $options )); - if (!$formElementManager instanceof FormElementManager) { - $form->init(); - } return $form; } } diff --git a/src/ZfcUser/Form/ChangeEmail.php b/src/ZfcUser/Form/ChangeEmail.php index f9d5c081..5385168b 100644 --- a/src/ZfcUser/Form/ChangeEmail.php +++ b/src/ZfcUser/Form/ChangeEmail.php @@ -12,13 +12,6 @@ public function __construct($name, AuthenticationOptionsInterface $options) $this->setAuthenticationOptions($options); parent::__construct($name); - if (!property_exists($options, "fem")) { - $this->init(); - } - } - - public function init() - { $this->add(array( 'name' => 'identity', 'options' => array( diff --git a/src/ZfcUser/Form/ChangePassword.php b/src/ZfcUser/Form/ChangePassword.php index 1b2d8a63..47b274fa 100644 --- a/src/ZfcUser/Form/ChangePassword.php +++ b/src/ZfcUser/Form/ChangePassword.php @@ -17,15 +17,6 @@ public function __construct($name, AuthenticationOptionsInterface $options) $this->setAuthenticationOptions($options); parent::__construct($name); - if (!property_exists($options, "fem")) { - $this->init(); - } - } - - public function init() - { - parent::init(); - $this->add(array( 'name' => 'identity', 'options' => array( diff --git a/src/ZfcUser/Form/Login.php b/src/ZfcUser/Form/Login.php index 3d0ae6d3..dcb01e5d 100644 --- a/src/ZfcUser/Form/Login.php +++ b/src/ZfcUser/Form/Login.php @@ -18,13 +18,6 @@ public function __construct($name, AuthenticationOptionsInterface $options) $this->setAuthenticationOptions($options); parent::__construct($name); - if (!property_exists($options, "fem")) { - $this->init(); - } - } - - public function init() - { $this->add(array( 'name' => 'identity', 'options' => array( diff --git a/src/ZfcUser/Form/Register.php b/src/ZfcUser/Form/Register.php index c3f2f76a..413b8e22 100644 --- a/src/ZfcUser/Form/Register.php +++ b/src/ZfcUser/Form/Register.php @@ -23,15 +23,6 @@ public function __construct($name, RegistrationOptionsInterface $options) $this->setRegistrationOptions($options); parent::__construct($name); - if (!property_exists($options, "fem")) { - $this->init(); - } - } - - public function init() - { - parent::init(); - if ($this->getRegistrationOptions()->getUseRegistrationFormCaptcha()) { $this->add(array( 'name' => 'captcha', From 1924ae6ccb520253667fae07036ca022e3d3032d Mon Sep 17 00:00:00 2001 From: Clayton Daley Date: Wed, 6 May 2015 18:58:35 -0400 Subject: [PATCH 32/59] - move remaining closures from Module to factory --- .gitignore | 78 ++++++++++++++++ Module.php | 90 +++---------------- src/ZfcUser/Factory/AuthenticationService.php | 29 ++++++ .../Plugin/ZfcUserAuthentication.php | 33 +++++++ .../Factory/Controller/RedirectCallback.php | 35 ++++++++ .../Factory/Controller/UserController.php | 36 ++++++++ src/ZfcUser/Factory/Mapper/User.php | 34 +++++++ src/ZfcUser/Factory/Options/ModuleOptions.php | 29 ++++++ src/ZfcUser/Factory/UserHydrator.php | 26 ++++++ .../View/Helper/ZfcUserDisplayName.php | 30 +++++++ .../Factory/View/Helper/ZfcUserIdentity.php | 30 +++++++ .../View/Helper/ZfcUserLoginWidget.php | 31 +++++++ 12 files changed, 401 insertions(+), 80 deletions(-) create mode 100644 .gitignore create mode 100644 src/ZfcUser/Factory/AuthenticationService.php create mode 100644 src/ZfcUser/Factory/Controller/Plugin/ZfcUserAuthentication.php create mode 100644 src/ZfcUser/Factory/Controller/RedirectCallback.php create mode 100644 src/ZfcUser/Factory/Controller/UserController.php create mode 100644 src/ZfcUser/Factory/Mapper/User.php create mode 100644 src/ZfcUser/Factory/Options/ModuleOptions.php create mode 100644 src/ZfcUser/Factory/UserHydrator.php create mode 100644 src/ZfcUser/Factory/View/Helper/ZfcUserDisplayName.php create mode 100644 src/ZfcUser/Factory/View/Helper/ZfcUserIdentity.php create mode 100644 src/ZfcUser/Factory/View/Helper/ZfcUserLoginWidget.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..44943b4e --- /dev/null +++ b/.gitignore @@ -0,0 +1,78 @@ +# Created by .ignore support plugin (hsz.mobi) +### TortoiseGit template +# Project-level settings +/.tgitconfig + + +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm + +*.iml + +## Directory-based project format: +.idea/ +# if you remove the above rule, at least ignore the following: + +# User-specific stuff: +# .idea/workspace.xml +# .idea/tasks.xml +# .idea/dictionaries + +# Sensitive or high-churn files: +# .idea/dataSources.ids +# .idea/dataSources.xml +# .idea/sqlDataSources.xml +# .idea/dynamic.xml +# .idea/uiDesigner.xml + +# Gradle: +# .idea/gradle.xml +# .idea/libraries + +# Mongo Explorer plugin: +# .idea/mongoSettings.xml + +## File-based project format: +*.ipr +*.iws + +## Plugin-specific files: + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties + + +### ZendFramework template +# Composer files +composer.phar +vendor/ + +# Local configs +config/autoload/*.local.php + +# Binary gettext files +*.mo + +# Data +data/logs/ +data/cache/ +data/sessions/ +data/tmp/ +temp/ + +# Legacy ZF1 +demos/ +extras/documentation + + diff --git a/Module.php b/Module.php index 253c4e11..bd032e7b 100644 --- a/Module.php +++ b/Module.php @@ -5,8 +5,6 @@ use Zend\ModuleManager\Feature\AutoloaderProviderInterface; use Zend\ModuleManager\Feature\ConfigProviderInterface; use Zend\ModuleManager\Feature\ServiceProviderInterface; -use ZfcUser\Controller\RedirectCallback; -use ZfcUser\Controller\UserController; class Module implements AutoloaderProviderInterface, @@ -36,15 +34,7 @@ public function getControllerPluginConfig() { return array( 'factories' => array( - 'zfcUserAuthentication' => function ($sm) { - $serviceLocator = $sm->getServiceLocator(); - $authService = $serviceLocator->get('zfcuser_auth_service'); - $authAdapter = $serviceLocator->get('ZfcUser\Authentication\Adapter\AdapterChain'); - $controllerPlugin = new Controller\Plugin\ZfcUserAuthentication; - $controllerPlugin->setAuthService($authService); - $controllerPlugin->setAuthAdapter($authAdapter); - return $controllerPlugin; - }, + 'zfcUserAuthentication' => 'ZfcUser\Factory\Controller\Plugin\ZfcUserAuthentication', ), ); } @@ -53,18 +43,7 @@ public function getControllerConfig() { return array( 'factories' => array( - 'zfcuser' => function($controllerManager) { - /* @var ControllerManager $controllerManager*/ - $serviceManager = $controllerManager->getServiceLocator(); - - /* @var RedirectCallback $redirectCallback */ - $redirectCallback = $serviceManager->get('zfcuser_redirect_callback'); - - /* @var UserController $controller */ - $controller = new UserController($redirectCallback); - - return $controller; - }, + 'zfcuser' => 'ZfcUser\Factory\Controller\UserController', ), ); } @@ -73,25 +52,9 @@ public function getViewHelperConfig() { return array( 'factories' => array( - 'zfcUserDisplayName' => function ($sm) { - $locator = $sm->getServiceLocator(); - $viewHelper = new View\Helper\ZfcUserDisplayName; - $viewHelper->setAuthService($locator->get('zfcuser_auth_service')); - return $viewHelper; - }, - 'zfcUserIdentity' => function ($sm) { - $locator = $sm->getServiceLocator(); - $viewHelper = new View\Helper\ZfcUserIdentity; - $viewHelper->setAuthService($locator->get('zfcuser_auth_service')); - return $viewHelper; - }, - 'zfcUserLoginWidget' => function ($sm) { - $locator = $sm->getServiceLocator(); - $viewHelper = new View\Helper\ZfcUserLoginWidget; - $viewHelper->setViewTemplate($locator->get('zfcuser_module_options')->getUserLoginWidgetViewTemplate()); - $viewHelper->setLoginForm($locator->get('zfcuser_login_form')); - return $viewHelper; - }, + 'zfcUserDisplayName' => 'ZfcUser\Factory\View\Helper\ZfcUserDisplayName', + 'zfcUserIdentity' => 'ZfcUser\Factory\View\Helper\ZfcUserIdentity', + 'zfcUserLoginWidget' => 'ZfcUser\Factory\View\Helper\ZfcUserLoginWidget', ), ); @@ -110,50 +73,17 @@ public function getServiceConfig() 'zfcuser_register_form_hydrator' => 'Zend\Stdlib\Hydrator\ClassMethods', ), 'factories' => array( + 'zfcuser_redirect_callback' => 'ZfcUser\Factory\Controller\RedirectCallback', + 'zfcuser_module_options' => 'ZfcUser\Factory\Options\ModuleOptions', 'ZfcUser\Authentication\Adapter\AdapterChain' => 'ZfcUser\Authentication\Adapter\AdapterChainServiceFactory', - 'zfcuser_redirect_callback' => function ($sm) { - /* @var RouteInterface $router */ - $router = $sm->get('Router'); - - /* @var Application $application */ - $application = $sm->get('Application'); - - /* @var ModuleOptions $options */ - $options = $sm->get('zfcuser_module_options'); - - return new RedirectCallback($application, $router, $options); - }, - - 'zfcuser_module_options' => function ($sm) { - $config = $sm->get('Config'); - return new Options\ModuleOptions(isset($config['zfcuser']) ? $config['zfcuser'] : array()); - }, // We alias this one because it's ZfcUser's instance of // Zend\Authentication\AuthenticationService. We don't want to // hog the FQCN service alias for a Zend\* class. - 'zfcuser_auth_service' => function ($sm) { - return new \Zend\Authentication\AuthenticationService( - $sm->get('ZfcUser\Authentication\Storage\Db'), - $sm->get('ZfcUser\Authentication\Adapter\AdapterChain') - ); - }, - - 'zfcuser_user_hydrator' => function ($sm) { - $hydrator = new \Zend\Stdlib\Hydrator\ClassMethods(); - return $hydrator; - }, + 'zfcuser_auth_service' => 'ZfcUser\Factory\AuthenticationService', - 'zfcuser_user_mapper' => function ($sm) { - $options = $sm->get('zfcuser_module_options'); - $mapper = new Mapper\User(); - $mapper->setDbAdapter($sm->get('zfcuser_zend_db_adapter')); - $entityClass = $options->getUserEntityClass(); - $mapper->setEntityPrototype(new $entityClass); - $mapper->setHydrator(new Mapper\UserHydrator()); - $mapper->setTableName($options->getTableName()); - return $mapper; - }, + 'zfcuser_user_hydrator' => 'ZfcUser\Factory\UserHydrator', + 'zfcuser_user_mapper' => 'ZfcUser\Factory\Mapper\User', ), ); } diff --git a/src/ZfcUser/Factory/AuthenticationService.php b/src/ZfcUser/Factory/AuthenticationService.php new file mode 100644 index 00000000..6fbd857e --- /dev/null +++ b/src/ZfcUser/Factory/AuthenticationService.php @@ -0,0 +1,29 @@ +get('ZfcUser\Authentication\Storage\Db'), + $serviceLocator->get('ZfcUser\Authentication\Adapter\AdapterChain') + ); + } +} \ No newline at end of file diff --git a/src/ZfcUser/Factory/Controller/Plugin/ZfcUserAuthentication.php b/src/ZfcUser/Factory/Controller/Plugin/ZfcUserAuthentication.php new file mode 100644 index 00000000..4764c134 --- /dev/null +++ b/src/ZfcUser/Factory/Controller/Plugin/ZfcUserAuthentication.php @@ -0,0 +1,33 @@ +getServiceLocator(); + $authService = $serviceLocator->get('zfcuser_auth_service'); + $authAdapter = $serviceLocator->get('ZfcUser\Authentication\Adapter\AdapterChain'); + $controllerPlugin = new Controller\Plugin\ZfcUserAuthentication; + $controllerPlugin->setAuthService($authService); + $controllerPlugin->setAuthAdapter($authAdapter); + return $controllerPlugin; + } +} \ No newline at end of file diff --git a/src/ZfcUser/Factory/Controller/RedirectCallback.php b/src/ZfcUser/Factory/Controller/RedirectCallback.php new file mode 100644 index 00000000..1f2a22e9 --- /dev/null +++ b/src/ZfcUser/Factory/Controller/RedirectCallback.php @@ -0,0 +1,35 @@ +get('Router'); + + /* @var Application $application */ + $application = $serviceLocator->get('Application'); + + /* @var ModuleOptions $options */ + $options = $serviceLocator->get('zfcuser_module_options'); + + return new RedirectCallback($application, $router, $options); + } +} \ No newline at end of file diff --git a/src/ZfcUser/Factory/Controller/UserController.php b/src/ZfcUser/Factory/Controller/UserController.php new file mode 100644 index 00000000..1a7c0fec --- /dev/null +++ b/src/ZfcUser/Factory/Controller/UserController.php @@ -0,0 +1,36 @@ +getServiceLocator(); + + /* @var RedirectCallback $redirectCallback */ + $redirectCallback = $serviceManager->get('zfcuser_redirect_callback'); + + /* @var UserController $controller */ + $controller = new UserController($redirectCallback); + + return $controller; + } +} \ No newline at end of file diff --git a/src/ZfcUser/Factory/Mapper/User.php b/src/ZfcUser/Factory/Mapper/User.php new file mode 100644 index 00000000..bcbb838d --- /dev/null +++ b/src/ZfcUser/Factory/Mapper/User.php @@ -0,0 +1,34 @@ +get('zfcuser_module_options'); + $mapper = new Mapper\User(); + $mapper->setDbAdapter($serviceLocator->get('zfcuser_zend_db_adapter')); + $entityClass = $options->getUserEntityClass(); + $mapper->setEntityPrototype(new $entityClass); + $mapper->setHydrator(new Mapper\UserHydrator()); + $mapper->setTableName($options->getTableName()); + return $mapper; + } +} \ No newline at end of file diff --git a/src/ZfcUser/Factory/Options/ModuleOptions.php b/src/ZfcUser/Factory/Options/ModuleOptions.php new file mode 100644 index 00000000..90e2e090 --- /dev/null +++ b/src/ZfcUser/Factory/Options/ModuleOptions.php @@ -0,0 +1,29 @@ +get('Config'); + return new Options\ModuleOptions(isset($config['zfcuser']) ? $config['zfcuser'] : array()); + } +} \ No newline at end of file diff --git a/src/ZfcUser/Factory/UserHydrator.php b/src/ZfcUser/Factory/UserHydrator.php new file mode 100644 index 00000000..c49a5e4d --- /dev/null +++ b/src/ZfcUser/Factory/UserHydrator.php @@ -0,0 +1,26 @@ +getServiceLocator(); + $viewHelper = new View\Helper\ZfcUserDisplayName; + $viewHelper->setAuthService($locator->get('zfcuser_auth_service')); + return $viewHelper; + } +} \ No newline at end of file diff --git a/src/ZfcUser/Factory/View/Helper/ZfcUserIdentity.php b/src/ZfcUser/Factory/View/Helper/ZfcUserIdentity.php new file mode 100644 index 00000000..0e01baf2 --- /dev/null +++ b/src/ZfcUser/Factory/View/Helper/ZfcUserIdentity.php @@ -0,0 +1,30 @@ +getServiceLocator(); + $viewHelper = new View\Helper\ZfcUserIdentity; + $viewHelper->setAuthService($locator->get('zfcuser_auth_service')); + return $viewHelper; + } +} \ No newline at end of file diff --git a/src/ZfcUser/Factory/View/Helper/ZfcUserLoginWidget.php b/src/ZfcUser/Factory/View/Helper/ZfcUserLoginWidget.php new file mode 100644 index 00000000..3925ab94 --- /dev/null +++ b/src/ZfcUser/Factory/View/Helper/ZfcUserLoginWidget.php @@ -0,0 +1,31 @@ +getServiceLocator(); + $viewHelper = new View\Helper\ZfcUserLoginWidget; + $viewHelper->setViewTemplate($locator->get('zfcuser_module_options')->getUserLoginWidgetViewTemplate()); + $viewHelper->setLoginForm($locator->get('zfcuser_login_form')); + return $viewHelper; + } +} \ No newline at end of file From d8eedbb7cef3a51f33d3314df0c0db6f77776cb5 Mon Sep 17 00:00:00 2001 From: Clayton Daley Date: Wed, 6 May 2015 20:48:51 -0400 Subject: [PATCH 33/59] - fix formatting --- src/ZfcUser/Factory/AuthenticationService.php | 5 +++-- .../Factory/Controller/Plugin/ZfcUserAuthentication.php | 5 +++-- src/ZfcUser/Factory/Controller/RedirectCallback.php | 5 +++-- src/ZfcUser/Factory/Controller/UserController.php | 5 +++-- src/ZfcUser/Factory/Mapper/User.php | 5 +++-- src/ZfcUser/Factory/UserHydrator.php | 5 +++-- src/ZfcUser/Factory/View/Helper/ZfcUserDisplayName.php | 5 +++-- src/ZfcUser/Factory/View/Helper/ZfcUserIdentity.php | 5 +++-- src/ZfcUser/Factory/View/Helper/ZfcUserLoginWidget.php | 5 +++-- 9 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/ZfcUser/Factory/AuthenticationService.php b/src/ZfcUser/Factory/AuthenticationService.php index 6fbd857e..40881610 100644 --- a/src/ZfcUser/Factory/AuthenticationService.php +++ b/src/ZfcUser/Factory/AuthenticationService.php @@ -11,7 +11,8 @@ use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; -class AuthenticationService implements FactoryInterface { +class AuthenticationService implements FactoryInterface +{ /** * Create service @@ -26,4 +27,4 @@ public function createService(ServiceLocatorInterface $serviceLocator) $serviceLocator->get('ZfcUser\Authentication\Adapter\AdapterChain') ); } -} \ No newline at end of file +} diff --git a/src/ZfcUser/Factory/Controller/Plugin/ZfcUserAuthentication.php b/src/ZfcUser/Factory/Controller/Plugin/ZfcUserAuthentication.php index 4764c134..d4729c12 100644 --- a/src/ZfcUser/Factory/Controller/Plugin/ZfcUserAuthentication.php +++ b/src/ZfcUser/Factory/Controller/Plugin/ZfcUserAuthentication.php @@ -12,7 +12,8 @@ use Zend\ServiceManager\ServiceLocatorInterface; use ZfcUser\Controller; -class ZfcUserAuthentication implements FactoryInterface { +class ZfcUserAuthentication implements FactoryInterface +{ /** * Create service @@ -30,4 +31,4 @@ public function createService(ServiceLocatorInterface $serviceManager) $controllerPlugin->setAuthAdapter($authAdapter); return $controllerPlugin; } -} \ No newline at end of file +} diff --git a/src/ZfcUser/Factory/Controller/RedirectCallback.php b/src/ZfcUser/Factory/Controller/RedirectCallback.php index 1f2a22e9..0eb1fbfc 100644 --- a/src/ZfcUser/Factory/Controller/RedirectCallback.php +++ b/src/ZfcUser/Factory/Controller/RedirectCallback.php @@ -12,7 +12,8 @@ use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; -class RedirectCallback implements FactoryInterface { +class RedirectCallback implements FactoryInterface +{ /** * Create service * @@ -32,4 +33,4 @@ public function createService(ServiceLocatorInterface $serviceLocator) return new RedirectCallback($application, $router, $options); } -} \ No newline at end of file +} diff --git a/src/ZfcUser/Factory/Controller/UserController.php b/src/ZfcUser/Factory/Controller/UserController.php index 1a7c0fec..82ced823 100644 --- a/src/ZfcUser/Factory/Controller/UserController.php +++ b/src/ZfcUser/Factory/Controller/UserController.php @@ -12,7 +12,8 @@ use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; -class UserController implements FactoryInterface { +class UserController implements FactoryInterface +{ /** * Create service @@ -33,4 +34,4 @@ public function createService(ServiceLocatorInterface $controllerManager) return $controller; } -} \ No newline at end of file +} diff --git a/src/ZfcUser/Factory/Mapper/User.php b/src/ZfcUser/Factory/Mapper/User.php index bcbb838d..ef4f7c50 100644 --- a/src/ZfcUser/Factory/Mapper/User.php +++ b/src/ZfcUser/Factory/Mapper/User.php @@ -12,7 +12,8 @@ use Zend\ServiceManager\ServiceLocatorInterface; use ZfcUser\Mapper; -class User implements FactoryInterface { +class User implements FactoryInterface +{ /** * Create service @@ -31,4 +32,4 @@ public function createService(ServiceLocatorInterface $serviceLocator) $mapper->setTableName($options->getTableName()); return $mapper; } -} \ No newline at end of file +} diff --git a/src/ZfcUser/Factory/UserHydrator.php b/src/ZfcUser/Factory/UserHydrator.php index c49a5e4d..12ad6a50 100644 --- a/src/ZfcUser/Factory/UserHydrator.php +++ b/src/ZfcUser/Factory/UserHydrator.php @@ -11,7 +11,8 @@ use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; -class UserHydrator implements FactoryInterface { +class UserHydrator implements FactoryInterface +{ /** * Create service @@ -23,4 +24,4 @@ public function createService(ServiceLocatorInterface $serviceLocator) { return new \Zend\Stdlib\Hydrator\ClassMethods(); } -} \ No newline at end of file +} diff --git a/src/ZfcUser/Factory/View/Helper/ZfcUserDisplayName.php b/src/ZfcUser/Factory/View/Helper/ZfcUserDisplayName.php index 59774410..faefd67b 100644 --- a/src/ZfcUser/Factory/View/Helper/ZfcUserDisplayName.php +++ b/src/ZfcUser/Factory/View/Helper/ZfcUserDisplayName.php @@ -12,7 +12,8 @@ use Zend\ServiceManager\ServiceLocatorInterface; use ZfcUser\View; -class ZfcUserDisplayName implements FactoryInterface { +class ZfcUserDisplayName implements FactoryInterface +{ /** * Create service @@ -27,4 +28,4 @@ public function createService(ServiceLocatorInterface $serviceManager) $viewHelper->setAuthService($locator->get('zfcuser_auth_service')); return $viewHelper; } -} \ No newline at end of file +} diff --git a/src/ZfcUser/Factory/View/Helper/ZfcUserIdentity.php b/src/ZfcUser/Factory/View/Helper/ZfcUserIdentity.php index 0e01baf2..31615927 100644 --- a/src/ZfcUser/Factory/View/Helper/ZfcUserIdentity.php +++ b/src/ZfcUser/Factory/View/Helper/ZfcUserIdentity.php @@ -12,7 +12,8 @@ use Zend\ServiceManager\ServiceLocatorInterface; use ZfcUser\View; -class ZfcUserIdentity implements FactoryInterface { +class ZfcUserIdentity implements FactoryInterface +{ /** * Create service @@ -27,4 +28,4 @@ public function createService(ServiceLocatorInterface $serviceManager) $viewHelper->setAuthService($locator->get('zfcuser_auth_service')); return $viewHelper; } -} \ No newline at end of file +} diff --git a/src/ZfcUser/Factory/View/Helper/ZfcUserLoginWidget.php b/src/ZfcUser/Factory/View/Helper/ZfcUserLoginWidget.php index 3925ab94..7d02db62 100644 --- a/src/ZfcUser/Factory/View/Helper/ZfcUserLoginWidget.php +++ b/src/ZfcUser/Factory/View/Helper/ZfcUserLoginWidget.php @@ -12,7 +12,8 @@ use Zend\ServiceManager\ServiceLocatorInterface; use ZfcUser\View; -class ZfcUserLoginWidget implements FactoryInterface { +class ZfcUserLoginWidget implements FactoryInterface +{ /** * Create service @@ -28,4 +29,4 @@ public function createService(ServiceLocatorInterface $serviceManager) $viewHelper->setLoginForm($locator->get('zfcuser_login_form')); return $viewHelper; } -} \ No newline at end of file +} From 325d235cea4c35a0cf0256ca4b6db0cd73e6df0a Mon Sep 17 00:00:00 2001 From: Clayton Daley Date: Wed, 6 May 2015 20:55:38 -0400 Subject: [PATCH 34/59] - final formatting issue --- src/ZfcUser/Factory/Options/ModuleOptions.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ZfcUser/Factory/Options/ModuleOptions.php b/src/ZfcUser/Factory/Options/ModuleOptions.php index 90e2e090..c4173fbc 100644 --- a/src/ZfcUser/Factory/Options/ModuleOptions.php +++ b/src/ZfcUser/Factory/Options/ModuleOptions.php @@ -13,7 +13,8 @@ use Zend\ServiceManager\ServiceLocatorInterface; use ZfcUser\Options; -class ModuleOptions implements FactoryInterface { +class ModuleOptions implements FactoryInterface +{ /** * Create service @@ -26,4 +27,4 @@ public function createService(ServiceLocatorInterface $serviceLocator) $config = $serviceLocator->get('Config'); return new Options\ModuleOptions(isset($config['zfcuser']) ? $config['zfcuser'] : array()); } -} \ No newline at end of file +} From c0a03dbd9b6b65d7fb58ed716b3dfceb7ef7f493 Mon Sep 17 00:00:00 2001 From: Johnny Peck Date: Fri, 8 May 2015 22:34:47 -0400 Subject: [PATCH 35/59] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 20eafc84..dec7cae4 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ ZfcUser is a user registration and authentication module for Zend Framework 2. Out of the box, ZfcUser works with Zend\Db, however alternative storage adapter modules are available (see below). ZfcUser provides the foundations for adding user authentication and registration to your ZF2 site. It is designed to be very -simple and easily to extend. +simple and easy to extend. More information and examples are available on the [ZfcUser Wiki](https://github.com/ZF-Commons/ZfcUser/wiki) From 58d92faaa72895954eaa69681f8482577bbb80ed Mon Sep 17 00:00:00 2001 From: Mihailov Vasilievic Filho Date: Thu, 21 May 2015 00:44:03 -0300 Subject: [PATCH 36/59] pt_BR translation --- src/ZfcUser/language/pt_BR.mo | Bin 0 -> 2251 bytes src/ZfcUser/language/pt_BR.po | 128 ++++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 src/ZfcUser/language/pt_BR.mo create mode 100644 src/ZfcUser/language/pt_BR.po diff --git a/src/ZfcUser/language/pt_BR.mo b/src/ZfcUser/language/pt_BR.mo new file mode 100644 index 0000000000000000000000000000000000000000..366513c4c6a7d0c10eb30021f16de8c3a77600a7 GIT binary patch literal 2251 zcmbW1%Wqpn6vn4eO6vlJ0_7<*0hNc~8oOz$U><3jrVxoZR_s)$LPC>!$JYbbGtNAm zI{!eC*pvlg2@#-5NNiyVk{7Iz5UZ*Z8(6Sl!3Lo&_|Co8Nf4nRMjHR_yw05S%{jh) zbpHno?a{K|0FR?z+lL>t!7asj9ef(&55arEZ@^>V_u$>&FW?>E4e&Pb(5;L;0UiNq zJPjTKUjS*}JoqHo0*`D)UY>9!6&0=^4A4t@%fKHq|*$9Evv{ShR+egbh7`weV^ ze}Hpf6Ty-FE8u?0xdO|u&@z5TM2QuZ2_D&kzM?O)bJLul~(J3Bk522F=rLOlH~k`N;>rAg$_-wio`vmx&;w0aSsGT?5}Xa#iIe&sNGSSX-r< zFY1EJ!51H4FvZ$ot*<;=)nYA!4a37A5nl3<36{%T)>4kW+DKpX>n;`M~iy3R+%^2Bd?>$DbIKF%${N z3e;&=42^vb?vf2{hDZr~;ZTN>5R=qPBo*{hNHF81?g?JZwDWJ_gUDFZ^d(KpOKMH! z7fp&89$GoRYVy^n$mQI8LQ(Xou2I(TbU7Pu!OqYW8Bd?0xDVB>d*S~?-=v6(8Yeks zS?+U@_S=fU?L4evk&D7R@mKG5$(5*7K`(<-X;35`y|*a~9lEhatzwm{o(**&K`8NS?{&+XFSt|N37Rtw5bz!_^ WmD$$IQj$#GC;zK}i23B?rTzp9^=qvF literal 0 HcmV?d00001 diff --git a/src/ZfcUser/language/pt_BR.po b/src/ZfcUser/language/pt_BR.po new file mode 100644 index 00000000..94e3e54b --- /dev/null +++ b/src/ZfcUser/language/pt_BR.po @@ -0,0 +1,128 @@ +# +# Mihailov Vasilievic Filho , 2015. +# +msgid "" +msgstr "" +"Project-Id-Version: ZfcUser\n" +"Report-Msgid-Bugs-To: zf-devteam@zend.com\n" +"POT-Creation-Date: 2013-11-08 00:38+0100\n" +"PO-Revision-Date: 2015-05-21 00:41-0300\n" +"Last-Translator: Mihailov Vasilievic Filho \n" +"Language-Team: Português brasileiro <>\n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"X-Generator: Poedit 1.6.10\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/ZfcUser/language/msgIds.php:6 +msgid "Username" +msgstr "Nome de Usuário" + +#: src/ZfcUser/language/msgIds.php:7 +msgid "Email" +msgstr "Email" + +#: src/ZfcUser/language/msgIds.php:8 +msgid "New Email" +msgstr "Novo email" + +#: src/ZfcUser/language/msgIds.php:9 +msgid "Verify New Email" +msgstr "Verificar novo email" + +#: src/ZfcUser/language/msgIds.php:10 +msgid "Display Name" +msgstr "Nome de exibição" + +#: src/ZfcUser/language/msgIds.php:11 +msgid "Password" +msgstr "Senha" + +#: src/ZfcUser/language/msgIds.php:12 +msgid "Password Verify" +msgstr "Verificação de senha" + +#: src/ZfcUser/language/msgIds.php:13 +msgid "Current Password" +msgstr "Senha atual" + +#: src/ZfcUser/language/msgIds.php:14 +msgid "Verify New Password" +msgstr "Verificar nova senha" + +#: src/ZfcUser/language/msgIds.php:15 +msgid "New Password" +msgstr "Nova senha" + +#: src/ZfcUser/language/msgIds.php:16 +msgid "Please type the following text" +msgstr "Por favor, digite o seguinte texto" + +#: src/ZfcUser/language/msgIds.php:17 +msgid "Submit" +msgstr "Enviar" + +#: src/ZfcUser/language/msgIds.php:18 view/zfc-user/user/login.phtml:1 +msgid "Sign In" +msgstr "Iniciar sessão" + +#: src/ZfcUser/language/msgIds.php:19 view/zfc-user/user/register.phtml:1 +msgid "Register" +msgstr "Registrar" + +#: src/ZfcUser/language/msgIds.php:20 +msgid "No record matching the input was found" +msgstr "Nenhum registro correspondente a entrada foi encontrado." + +#: src/ZfcUser/language/msgIds.php:21 +msgid "A record matching the input was found" +msgstr "Um registro correspondente a entrada foi encontrado." + +#: src/ZfcUser/language/msgIds.php:22 +msgid "Authentication failed. Please try again." +msgstr "A autenticação falhou. Por favor, tente novamente." + +#: view/zfc-user/user/login.phtml:31 +msgid "Not registered?" +msgstr "Não registrado?" + +#: view/zfc-user/user/login.phtml:31 +msgid "Sign up!" +msgstr "Inscreva-se!" + +#: view/zfc-user/user/changeemail.phtml:1 +#, php-format +msgid "Change Email for %s" +msgstr "Alterar email de %s" + +#: view/zfc-user/user/changeemail.phtml:3 +msgid "Email address changed successfully." +msgstr "Endereço de e-mail alterado com sucesso." + +#: view/zfc-user/user/changeemail.phtml:5 +msgid "Unable to update your email address. Please try again." +msgstr "" +"Não foi possível atualizar o seu endereço de e-mail. Por favor, tente " +"novamente." + +#: view/zfc-user/user/changepassword.phtml:1 +#, php-format +msgid "Change Password for %s" +msgstr "Mudar senha de %s" + +#: view/zfc-user/user/changepassword.phtml:3 +msgid "Password changed successfully." +msgstr "Senha alterada com sucesso." + +#: view/zfc-user/user/changepassword.phtml:5 +msgid "Unable to update your password. Please try again." +msgstr "Não foi possível atualizar a senha. Por favor, tente novamente." + +#: view/zfc-user/user/index.phtml:2 +msgid "Hello" +msgstr "Olá" + +#: view/zfc-user/user/index.phtml:3 +msgid "Sign Out" +msgstr "Sair" From da69d678d1d8e9d0d1b4f454ac657ee2f27c08d5 Mon Sep 17 00:00:00 2001 From: Mihailov Vasilievic Filho Date: Thu, 21 May 2015 00:53:29 -0300 Subject: [PATCH 37/59] update pt_BR translation --- src/ZfcUser/language/pt_BR.mo | Bin 2251 -> 2263 bytes src/ZfcUser/language/pt_BR.po | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ZfcUser/language/pt_BR.mo b/src/ZfcUser/language/pt_BR.mo index 366513c4c6a7d0c10eb30021f16de8c3a77600a7..47a3123acd1b2157655859fe6d853fadc0d11fdf 100644 GIT binary patch delta 267 zcmXZVJqtkr6vpx6<$5nJVz9`jD0wM^MambDlEGjQ3*{w~dVb->kd23(XiJaL<`#48rZFrgyjcN%_J)T delta 270 zcmcaEcv^76pZa!228Q`83=Ad=3=HaQ5IP1(3j_HRfwUlyUJ9hSf%JADEd-NHUIzs diff --git a/src/ZfcUser/language/pt_BR.po b/src/ZfcUser/language/pt_BR.po index 94e3e54b..a51235d1 100644 --- a/src/ZfcUser/language/pt_BR.po +++ b/src/ZfcUser/language/pt_BR.po @@ -6,9 +6,9 @@ msgstr "" "Project-Id-Version: ZfcUser\n" "Report-Msgid-Bugs-To: zf-devteam@zend.com\n" "POT-Creation-Date: 2013-11-08 00:38+0100\n" -"PO-Revision-Date: 2015-05-21 00:41-0300\n" +"PO-Revision-Date: 2015-05-21 00:52-0300\n" "Last-Translator: Mihailov Vasilievic Filho \n" -"Language-Team: Português brasileiro <>\n" +"Language-Team: ZF Contibutors \n" "Language: pt_BR\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" From d0d9c8145ba0c471a14151cce33e2496dbeb0afa Mon Sep 17 00:00:00 2001 From: Adelar Tiemann Junior Date: Wed, 17 Jun 2015 10:16:33 -0300 Subject: [PATCH 38/59] Add parameter autocomplete = off on forms with password. --- view/zfc-user/user/changepassword.phtml | 1 + view/zfc-user/user/login.phtml | 1 + view/zfc-user/user/register.phtml | 1 + 3 files changed, 3 insertions(+) diff --git a/view/zfc-user/user/changepassword.phtml b/view/zfc-user/user/changepassword.phtml index 7512dd09..7a3130fd 100644 --- a/view/zfc-user/user/changepassword.phtml +++ b/view/zfc-user/user/changepassword.phtml @@ -11,6 +11,7 @@ $form = $this->changePasswordForm; $form->prepare(); $form->setAttribute('action', $this->url('zfcuser/changepassword')); $form->setAttribute('method', 'post'); +$form->setAttribute('autocomplete', 'off'); $emailElement = $form->get('identity'); $emailElement->setValue($this->zfcUserIdentity()->getEmail()); diff --git a/view/zfc-user/user/login.phtml b/view/zfc-user/user/login.phtml index 66dbfd68..8e49c966 100644 --- a/view/zfc-user/user/login.phtml +++ b/view/zfc-user/user/login.phtml @@ -5,6 +5,7 @@ $form = $this->loginForm; $form->prepare(); $form->setAttribute('action', $this->url('zfcuser/login')); $form->setAttribute('method', 'post'); +$form->setAttribute('autocomplete', 'off'); ?> form()->openTag($form) ?> diff --git a/view/zfc-user/user/register.phtml b/view/zfc-user/user/register.phtml index 102b7ef0..1f4465af 100644 --- a/view/zfc-user/user/register.phtml +++ b/view/zfc-user/user/register.phtml @@ -9,6 +9,7 @@ $form = $this->registerForm; $form->prepare(); $form->setAttribute('action', $this->url('zfcuser/register')); $form->setAttribute('method', 'post'); +$form->setAttribute('autocomplete', 'off'); ?> form()->openTag($form) ?> From d5a8513075c498f9dde6adfb192cf7179dc5d804 Mon Sep 17 00:00:00 2001 From: Chuk Shirley Date: Fri, 26 Jun 2015 16:12:50 -0500 Subject: [PATCH 39/59] Fixed spelling of comment in zfcuser.global.php.dist --- config/zfcuser.global.php.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/zfcuser.global.php.dist b/config/zfcuser.global.php.dist index 05c13c54..c7b53f35 100644 --- a/config/zfcuser.global.php.dist +++ b/config/zfcuser.global.php.dist @@ -158,7 +158,7 @@ $settings = array( /** * Logout Redirect Route * - * Upon logging out the user will be redirected to the enterd route + * Upon logging out the user will be redirected to the entered route * * Default value: 'zfcuser/login' * Accepted values: A valid route name within your application From 2d93d2685c62ab9b3f4faa66a5e3ec3ab0d20594 Mon Sep 17 00:00:00 2001 From: Clayton Daley Date: Mon, 20 Jul 2015 17:09:13 -0400 Subject: [PATCH 40/59] - revert travis and .gitignore --- .gitignore | 78 ----------------------------------------------------- .travis.yml | 4 +++ 2 files changed, 4 insertions(+), 78 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 44943b4e..00000000 --- a/.gitignore +++ /dev/null @@ -1,78 +0,0 @@ -# Created by .ignore support plugin (hsz.mobi) -### TortoiseGit template -# Project-level settings -/.tgitconfig - - -### JetBrains template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm - -*.iml - -## Directory-based project format: -.idea/ -# if you remove the above rule, at least ignore the following: - -# User-specific stuff: -# .idea/workspace.xml -# .idea/tasks.xml -# .idea/dictionaries - -# Sensitive or high-churn files: -# .idea/dataSources.ids -# .idea/dataSources.xml -# .idea/sqlDataSources.xml -# .idea/dynamic.xml -# .idea/uiDesigner.xml - -# Gradle: -# .idea/gradle.xml -# .idea/libraries - -# Mongo Explorer plugin: -# .idea/mongoSettings.xml - -## File-based project format: -*.ipr -*.iws - -## Plugin-specific files: - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties - - -### ZendFramework template -# Composer files -composer.phar -vendor/ - -# Local configs -config/autoload/*.local.php - -# Binary gettext files -*.mo - -# Data -data/logs/ -data/cache/ -data/sessions/ -data/tmp/ -temp/ - -# Legacy ZF1 -demos/ -extras/documentation - - diff --git a/.travis.yml b/.travis.yml index f5d82951..920dc951 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,10 @@ script: after_script: - php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml +notifications: + email: false + irc: "irc.freenode.org#zftalk.dev" + matrix: fast_finish: true allow_failures: From a3ec479c5d5d6d87f5a2a20025501694500f587d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Str=C3=B8m?= Date: Mon, 17 Aug 2015 13:49:01 +0200 Subject: [PATCH 41/59] Add zfcuser/authenticate to redirectCallback check --- src/ZfcUser/Controller/RedirectCallback.php | 1 + tests/ZfcUserTest/Controller/RedirectCallbackTest.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/ZfcUser/Controller/RedirectCallback.php b/src/ZfcUser/Controller/RedirectCallback.php index 925f6ec3..273fea85 100644 --- a/src/ZfcUser/Controller/RedirectCallback.php +++ b/src/ZfcUser/Controller/RedirectCallback.php @@ -103,6 +103,7 @@ protected function getRedirect($currentRoute, $redirect = false) switch ($currentRoute) { case 'zfcuser/register': case 'zfcuser/login': + case 'zfcuser/authenticate': $route = ($redirect) ?: $this->options->getLoginRedirectRoute(); return $this->router->assemble(array(), array('name' => $route)); break; diff --git a/tests/ZfcUserTest/Controller/RedirectCallbackTest.php b/tests/ZfcUserTest/Controller/RedirectCallbackTest.php index 236352c1..86e9a14c 100644 --- a/tests/ZfcUserTest/Controller/RedirectCallbackTest.php +++ b/tests/ZfcUserTest/Controller/RedirectCallbackTest.php @@ -226,6 +226,7 @@ public function providerGetRedirectNoRedirectParam() { return array( array('zfcuser/login', 'zfcuser', '/user', 'getLoginRedirectRoute'), + array('zfcuser/authenticate', 'zfcuser', '/user', 'getLoginRedirectRoute'), array('zfcuser/logout', 'zfcuser/login', '/user/login', 'getLogoutRedirectRoute'), array('testDefault', 'zfcuser', '/home', false), ); From 7947c97016de9b808a2caf716315ca8d330bd65e Mon Sep 17 00:00:00 2001 From: Clayton Daley Date: Sat, 17 Oct 2015 18:07:04 -0500 Subject: [PATCH 42/59] - use partials --- view/zfc-user/user/changeemail.phtml | 2 +- view/zfc-user/user/changepassword.phtml | 2 +- view/zfc-user/user/login.phtml | 2 +- view/zfc-user/user/register.phtml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/view/zfc-user/user/changeemail.phtml b/view/zfc-user/user/changeemail.phtml index a30591f1..5fbbd0be 100644 --- a/view/zfc-user/user/changeemail.phtml +++ b/view/zfc-user/user/changeemail.phtml @@ -13,4 +13,4 @@ $form->setAttribute('action', $this->url('zfcuser/changeemail')); $form->setAttribute('method', 'post'); ?> - \ No newline at end of file +partial('_form.phtml'); ?> \ No newline at end of file diff --git a/view/zfc-user/user/changepassword.phtml b/view/zfc-user/user/changepassword.phtml index 62f3e890..7182898b 100644 --- a/view/zfc-user/user/changepassword.phtml +++ b/view/zfc-user/user/changepassword.phtml @@ -16,4 +16,4 @@ $emailElement = $form->get('identity'); $emailElement->setValue($this->zfcUserIdentity()->getEmail()); ?> - \ No newline at end of file +partial('_form.phtml'); ?> \ No newline at end of file diff --git a/view/zfc-user/user/login.phtml b/view/zfc-user/user/login.phtml index ca1fdfba..426aa4da 100644 --- a/view/zfc-user/user/login.phtml +++ b/view/zfc-user/user/login.phtml @@ -7,7 +7,7 @@ $form->setAttribute('action', $this->url('zfcuser/login')); $form->setAttribute('method', 'post'); ?> - +partial('_form.phtml'); ?> enableRegistration) : ?> translate('Not registered?'); ?> translate('Sign up!'); ?> diff --git a/view/zfc-user/user/register.phtml b/view/zfc-user/user/register.phtml index f34afcf3..a72f1273 100644 --- a/view/zfc-user/user/register.phtml +++ b/view/zfc-user/user/register.phtml @@ -11,4 +11,4 @@ $form->setAttribute('action', $this->url('zfcuser/register')); $form->setAttribute('method', 'post'); ?> - \ No newline at end of file +partial('_form.phtml'); ?> \ No newline at end of file From 9fc3a9349d1140d2a3fff153b639176a1966e854 Mon Sep 17 00:00:00 2001 From: Trent Petersen Date: Mon, 23 Nov 2015 14:50:16 -0800 Subject: [PATCH 43/59] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index dec7cae4..ae56404e 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,6 @@ Installation return array( 'modules' => array( // ... - 'ZfcBase', 'ZfcUser', ), // ... From 331162bd725495c71f2645fc167d432151587f92 Mon Sep 17 00:00:00 2001 From: Adam Lundrigan Date: Sat, 12 Dec 2015 09:35:01 -0330 Subject: [PATCH 44/59] Update PHP version constraint to allow PHP 7 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a2d0de32..4a97f21e 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ } }, "require": { - "php": ">=5.3.3", + "php": "^5.3.3|~7.0", "zendframework/zend-authentication": "~2.1", "zendframework/zend-crypt": "~2.1", "zendframework/zend-form": "~2.1", From 44cb298ede8087b6ba3f4043d8843dfdbd743b49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Str=C3=B8m?= Date: Sat, 12 Dec 2015 15:27:46 +0100 Subject: [PATCH 45/59] Fix factories returning themselves --- Module.php | 4 ++-- .../{RedirectCallback.php => RedirectCallbackFactory.php} | 6 +++++- .../{UserController.php => UserControllerFactory.php} | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-) rename src/ZfcUser/Factory/Controller/{RedirectCallback.php => RedirectCallbackFactory.php} (80%) rename src/ZfcUser/Factory/Controller/{UserController.php => UserControllerFactory.php} (86%) diff --git a/Module.php b/Module.php index bd032e7b..aba23da4 100644 --- a/Module.php +++ b/Module.php @@ -43,7 +43,7 @@ public function getControllerConfig() { return array( 'factories' => array( - 'zfcuser' => 'ZfcUser\Factory\Controller\UserController', + 'zfcuser' => 'ZfcUser\Factory\Controller\UserControllerFactory', ), ); } @@ -73,7 +73,7 @@ public function getServiceConfig() 'zfcuser_register_form_hydrator' => 'Zend\Stdlib\Hydrator\ClassMethods', ), 'factories' => array( - 'zfcuser_redirect_callback' => 'ZfcUser\Factory\Controller\RedirectCallback', + 'zfcuser_redirect_callback' => 'ZfcUser\Factory\Controller\RedirectCallbackFactory', 'zfcuser_module_options' => 'ZfcUser\Factory\Options\ModuleOptions', 'ZfcUser\Authentication\Adapter\AdapterChain' => 'ZfcUser\Authentication\Adapter\AdapterChainServiceFactory', diff --git a/src/ZfcUser/Factory/Controller/RedirectCallback.php b/src/ZfcUser/Factory/Controller/RedirectCallbackFactory.php similarity index 80% rename from src/ZfcUser/Factory/Controller/RedirectCallback.php rename to src/ZfcUser/Factory/Controller/RedirectCallbackFactory.php index 0eb1fbfc..d3ea60b7 100644 --- a/src/ZfcUser/Factory/Controller/RedirectCallback.php +++ b/src/ZfcUser/Factory/Controller/RedirectCallbackFactory.php @@ -9,10 +9,14 @@ namespace ZfcUser\Factory\Controller; +use Zend\Mvc\Application; +use Zend\Mvc\Router\RouteInterface; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; +use ZfcUser\Controller\RedirectCallback; +use ZfcUser\Options\ModuleOptions; -class RedirectCallback implements FactoryInterface +class RedirectCallbackFactory implements FactoryInterface { /** * Create service diff --git a/src/ZfcUser/Factory/Controller/UserController.php b/src/ZfcUser/Factory/Controller/UserControllerFactory.php similarity index 86% rename from src/ZfcUser/Factory/Controller/UserController.php rename to src/ZfcUser/Factory/Controller/UserControllerFactory.php index 82ced823..78ed0305 100644 --- a/src/ZfcUser/Factory/Controller/UserController.php +++ b/src/ZfcUser/Factory/Controller/UserControllerFactory.php @@ -11,8 +11,10 @@ use Zend\Mvc\Controller\ControllerManager; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; +use ZfcUser\Controller\RedirectCallback; +use ZfcUser\Controller\UserController; -class UserController implements FactoryInterface +class UserControllerFactory implements FactoryInterface { /** From b5689f5b9b5bf06054bf59c216ebe5ed53f17994 Mon Sep 17 00:00:00 2001 From: Nepomuk Fraedrich Date: Mon, 14 Dec 2015 11:27:25 +0100 Subject: [PATCH 46/59] Fixed zfcuser_login_form service in ZfcUserLoginWidget view helper --- src/ZfcUser/Factory/View/Helper/ZfcUserLoginWidget.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ZfcUser/Factory/View/Helper/ZfcUserLoginWidget.php b/src/ZfcUser/Factory/View/Helper/ZfcUserLoginWidget.php index 7d02db62..96f2cc87 100644 --- a/src/ZfcUser/Factory/View/Helper/ZfcUserLoginWidget.php +++ b/src/ZfcUser/Factory/View/Helper/ZfcUserLoginWidget.php @@ -26,7 +26,7 @@ public function createService(ServiceLocatorInterface $serviceManager) $locator = $serviceManager->getServiceLocator(); $viewHelper = new View\Helper\ZfcUserLoginWidget; $viewHelper->setViewTemplate($locator->get('zfcuser_module_options')->getUserLoginWidgetViewTemplate()); - $viewHelper->setLoginForm($locator->get('zfcuser_login_form')); + $viewHelper->setLoginForm($locator->get('FormElementManager')->get('zfcuser_login_form')); return $viewHelper; } } From c5242692792886328e7d00b5eb6340b2c4f82ebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Str=C3=B8m?= Date: Mon, 21 Dec 2015 21:53:30 +0100 Subject: [PATCH 47/59] Pass form object along to form partial --- view/zfc-user/user/changeemail.phtml | 2 +- view/zfc-user/user/changepassword.phtml | 2 +- view/zfc-user/user/login.phtml | 4 ++-- view/zfc-user/user/register.phtml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/view/zfc-user/user/changeemail.phtml b/view/zfc-user/user/changeemail.phtml index 5fbbd0be..77a093ba 100644 --- a/view/zfc-user/user/changeemail.phtml +++ b/view/zfc-user/user/changeemail.phtml @@ -13,4 +13,4 @@ $form->setAttribute('action', $this->url('zfcuser/changeemail')); $form->setAttribute('method', 'post'); ?> -partial('_form.phtml'); ?> \ No newline at end of file +partial('_form.phtml', ['form' => $form]); ?> diff --git a/view/zfc-user/user/changepassword.phtml b/view/zfc-user/user/changepassword.phtml index e9d1a82c..84036501 100644 --- a/view/zfc-user/user/changepassword.phtml +++ b/view/zfc-user/user/changepassword.phtml @@ -17,4 +17,4 @@ $emailElement = $form->get('identity'); $emailElement->setValue($this->zfcUserIdentity()->getEmail()); ?> -partial('_form.phtml'); ?> \ No newline at end of file +partial('_form.phtml', ['form' => $form]); ?> diff --git a/view/zfc-user/user/login.phtml b/view/zfc-user/user/login.phtml index 3dccb80f..3acee7aa 100644 --- a/view/zfc-user/user/login.phtml +++ b/view/zfc-user/user/login.phtml @@ -8,8 +8,8 @@ $form->setAttribute('method', 'post'); $form->setAttribute('autocomplete', 'off'); ?> -partial('_form.phtml'); ?> +partial('_form.phtml', ['form' => $form]); ?> enableRegistration) : ?> translate('Not registered?'); ?> translate('Sign up!'); ?> - \ No newline at end of file + diff --git a/view/zfc-user/user/register.phtml b/view/zfc-user/user/register.phtml index 551d97e4..1bdafa27 100644 --- a/view/zfc-user/user/register.phtml +++ b/view/zfc-user/user/register.phtml @@ -12,4 +12,4 @@ $form->setAttribute('method', 'post'); $form->setAttribute('autocomplete', 'off'); ?> -partial('_form.phtml'); ?> \ No newline at end of file +partial('_form.phtml', ['form' => $form]); ?> From 9f54582cc6875f07afb8090ad1928bf6973d3407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Str=C3=B8m?= Date: Mon, 21 Dec 2015 22:03:09 +0100 Subject: [PATCH 48/59] Revert usage of formElementManager(BC break) --- Module.php | 5 +++++ config/module.config.php | 8 -------- src/ZfcUser/Controller/UserController.php | 8 ++++---- src/ZfcUser/Factory/View/Helper/ZfcUserLoginWidget.php | 2 +- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Module.php b/Module.php index aba23da4..06cc21c5 100644 --- a/Module.php +++ b/Module.php @@ -71,6 +71,11 @@ public function getServiceConfig() 'ZfcUser\Authentication\Storage\Db' => 'ZfcUser\Authentication\Storage\Db', 'zfcuser_user_service' => 'ZfcUser\Service\User', 'zfcuser_register_form_hydrator' => 'Zend\Stdlib\Hydrator\ClassMethods', + + 'zfcuser_login_form' => 'ZfcUser\Factory\Form\Login', + 'zfcuser_register_form' => 'ZfcUser\Factory\Form\Register', + 'zfcuser_change_password_form' => 'ZfcUser\Factory\Form\ChangePassword', + 'zfcuser_change_email_form' => 'ZfcUser\Factory\Form\ChangeEmail', ), 'factories' => array( 'zfcuser_redirect_callback' => 'ZfcUser\Factory\Controller\RedirectCallbackFactory', diff --git a/config/module.config.php b/config/module.config.php index a40176b9..e8f022d1 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -6,14 +6,6 @@ 'zfcuser' => __DIR__ . '/../view', ), ), - 'form_elements' => array( - 'factories' => array( - 'zfcuser_login_form' => 'ZfcUser\Factory\Form\Login', - 'zfcuser_register_form' => 'ZfcUser\Factory\Form\Register', - 'zfcuser_change_password_form' => 'ZfcUser\Factory\Form\ChangePassword', - 'zfcuser_change_email_form' => 'ZfcUser\Factory\Form\ChangeEmail', - ) - ), 'router' => array( 'routes' => array( diff --git a/src/ZfcUser/Controller/UserController.php b/src/ZfcUser/Controller/UserController.php index 06dc9fed..e9bbd143 100644 --- a/src/ZfcUser/Controller/UserController.php +++ b/src/ZfcUser/Controller/UserController.php @@ -362,7 +362,7 @@ public function setUserService(UserService $userService) public function getRegisterForm() { if (!$this->registerForm) { - $this->setRegisterForm($this->getServiceLocator()->get('FormElementManager')->get('zfcuser_register_form')); + $this->setRegisterForm($this->getServiceLocator()->get('zfcuser_register_form')); } return $this->registerForm; } @@ -375,7 +375,7 @@ public function setRegisterForm(FormInterface$registerForm) public function getLoginForm() { if (!$this->loginForm) { - $this->setLoginForm($this->getServiceLocator()->get('FormElementManager')->get('zfcuser_login_form')); + $this->setLoginForm($this->getServiceLocator()->get('zfcuser_login_form')); } return $this->loginForm; } @@ -395,7 +395,7 @@ public function setLoginForm(FormInterface $loginForm) public function getChangePasswordForm() { if (!$this->changePasswordForm) { - $this->setChangePasswordForm($this->getServiceLocator()->get('FormElementManager')->get('zfcuser_change_password_form')); + $this->setChangePasswordForm($this->getServiceLocator()->get('zfcuser_change_password_form')); } return $this->changePasswordForm; } @@ -438,7 +438,7 @@ public function getOptions() public function getChangeEmailForm() { if (!$this->changeEmailForm) { - $this->setChangeEmailForm($this->getServiceLocator()->get('FormElementManager')->get('zfcuser_change_email_form')); + $this->setChangeEmailForm($this->getServiceLocator()->get('zfcuser_change_email_form')); } return $this->changeEmailForm; } diff --git a/src/ZfcUser/Factory/View/Helper/ZfcUserLoginWidget.php b/src/ZfcUser/Factory/View/Helper/ZfcUserLoginWidget.php index 96f2cc87..7d02db62 100644 --- a/src/ZfcUser/Factory/View/Helper/ZfcUserLoginWidget.php +++ b/src/ZfcUser/Factory/View/Helper/ZfcUserLoginWidget.php @@ -26,7 +26,7 @@ public function createService(ServiceLocatorInterface $serviceManager) $locator = $serviceManager->getServiceLocator(); $viewHelper = new View\Helper\ZfcUserLoginWidget; $viewHelper->setViewTemplate($locator->get('zfcuser_module_options')->getUserLoginWidgetViewTemplate()); - $viewHelper->setLoginForm($locator->get('FormElementManager')->get('zfcuser_login_form')); + $viewHelper->setLoginForm($locator->get('zfcuser_login_form')); return $viewHelper; } } From d8f83a33ee61516feb059f86ea2eb2c8a23c88d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Str=C3=B8m?= Date: Mon, 21 Dec 2015 22:09:54 +0100 Subject: [PATCH 49/59] Move form factories to factories key, instead of invokables key --- Module.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Module.php b/Module.php index 06cc21c5..eb7ad717 100644 --- a/Module.php +++ b/Module.php @@ -71,11 +71,6 @@ public function getServiceConfig() 'ZfcUser\Authentication\Storage\Db' => 'ZfcUser\Authentication\Storage\Db', 'zfcuser_user_service' => 'ZfcUser\Service\User', 'zfcuser_register_form_hydrator' => 'Zend\Stdlib\Hydrator\ClassMethods', - - 'zfcuser_login_form' => 'ZfcUser\Factory\Form\Login', - 'zfcuser_register_form' => 'ZfcUser\Factory\Form\Register', - 'zfcuser_change_password_form' => 'ZfcUser\Factory\Form\ChangePassword', - 'zfcuser_change_email_form' => 'ZfcUser\Factory\Form\ChangeEmail', ), 'factories' => array( 'zfcuser_redirect_callback' => 'ZfcUser\Factory\Controller\RedirectCallbackFactory', @@ -89,6 +84,11 @@ public function getServiceConfig() 'zfcuser_user_hydrator' => 'ZfcUser\Factory\UserHydrator', 'zfcuser_user_mapper' => 'ZfcUser\Factory\Mapper\User', + + 'zfcuser_login_form' => 'ZfcUser\Factory\Form\Login', + 'zfcuser_register_form' => 'ZfcUser\Factory\Form\Register', + 'zfcuser_change_password_form' => 'ZfcUser\Factory\Form\ChangePassword', + 'zfcuser_change_email_form' => 'ZfcUser\Factory\Form\ChangeEmail', ), ); } From c6a260c61317ebfb9dd0d5d8292967e90e476ec9 Mon Sep 17 00:00:00 2001 From: Vytautas Stankus Date: Fri, 4 Mar 2016 15:54:13 +0200 Subject: [PATCH 50/59] do not allow 5.6 failures and add php7 to test matrix --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 920dc951..f1ea2622 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ php: - 5.4 - 5.5 - 5.6 + - 7.0 - hhvm before_script: @@ -28,5 +29,4 @@ notifications: matrix: fast_finish: true allow_failures: - - php: 5.6 - php: hhvm From f93a182e51c6d02b8d068c0a1a83c75855e3c1e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Str=C3=B8m?= Date: Thu, 5 May 2016 20:34:04 +0200 Subject: [PATCH 51/59] Fix controller getServiceLocator deprecation notice --- src/ZfcUser/Controller/UserController.php | 18 ++++++++++++------ .../Controller/UserControllerFactory.php | 1 + 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/ZfcUser/Controller/UserController.php b/src/ZfcUser/Controller/UserController.php index e9bbd143..48c42df0 100644 --- a/src/ZfcUser/Controller/UserController.php +++ b/src/ZfcUser/Controller/UserController.php @@ -4,6 +4,7 @@ use Zend\Form\FormInterface; use Zend\Mvc\Controller\AbstractActionController; +use Zend\ServiceManager\ServiceLocatorInterface; use Zend\Stdlib\ResponseInterface as Response; use Zend\Stdlib\Parameters; use Zend\View\Model\ViewModel; @@ -60,6 +61,11 @@ class UserController extends AbstractActionController */ protected $redirectCallback; + /** + * @var ServiceLocatorInterface + */ + protected $serviceLocator; + /** * @param callable $redirectCallback */ @@ -348,7 +354,7 @@ public function changeEmailAction() public function getUserService() { if (!$this->userService) { - $this->userService = $this->getServiceLocator()->get('zfcuser_user_service'); + $this->userService = $this->serviceLocator->get('zfcuser_user_service'); } return $this->userService; } @@ -362,7 +368,7 @@ public function setUserService(UserService $userService) public function getRegisterForm() { if (!$this->registerForm) { - $this->setRegisterForm($this->getServiceLocator()->get('zfcuser_register_form')); + $this->setRegisterForm($this->serviceLocator->get('zfcuser_register_form')); } return $this->registerForm; } @@ -375,7 +381,7 @@ public function setRegisterForm(FormInterface$registerForm) public function getLoginForm() { if (!$this->loginForm) { - $this->setLoginForm($this->getServiceLocator()->get('zfcuser_login_form')); + $this->setLoginForm($this->serviceLocator->get('zfcuser_login_form')); } return $this->loginForm; } @@ -395,7 +401,7 @@ public function setLoginForm(FormInterface $loginForm) public function getChangePasswordForm() { if (!$this->changePasswordForm) { - $this->setChangePasswordForm($this->getServiceLocator()->get('zfcuser_change_password_form')); + $this->setChangePasswordForm($this->serviceLocator->get('zfcuser_change_password_form')); } return $this->changePasswordForm; } @@ -426,7 +432,7 @@ public function setOptions(UserControllerOptionsInterface $options) public function getOptions() { if (!$this->options instanceof UserControllerOptionsInterface) { - $this->setOptions($this->getServiceLocator()->get('zfcuser_module_options')); + $this->setOptions($this->serviceLocator->get('zfcuser_module_options')); } return $this->options; } @@ -438,7 +444,7 @@ public function getOptions() public function getChangeEmailForm() { if (!$this->changeEmailForm) { - $this->setChangeEmailForm($this->getServiceLocator()->get('zfcuser_change_email_form')); + $this->setChangeEmailForm($this->serviceLocator->get('zfcuser_change_email_form')); } return $this->changeEmailForm; } diff --git a/src/ZfcUser/Factory/Controller/UserControllerFactory.php b/src/ZfcUser/Factory/Controller/UserControllerFactory.php index 78ed0305..745ae1bb 100644 --- a/src/ZfcUser/Factory/Controller/UserControllerFactory.php +++ b/src/ZfcUser/Factory/Controller/UserControllerFactory.php @@ -33,6 +33,7 @@ public function createService(ServiceLocatorInterface $controllerManager) /* @var UserController $controller */ $controller = new UserController($redirectCallback); + $controller->setServiceLocator($serviceManager); return $controller; } From 9806b9cce9e6782ca89e434299942d6debb1cc74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Str=C3=B8m?= Date: Thu, 5 May 2016 20:41:21 +0200 Subject: [PATCH 52/59] Fix ServiceManagerAwareInitializer deprecation notices --- Module.php | 5 ++-- src/ZfcUser/Authentication/Adapter/Db.php | 2 +- src/ZfcUser/Authentication/Storage/Db.php | 2 +- .../Authentication/Adapter/DbFactory.php | 24 +++++++++++++++++++ .../Authentication/Storage/DbFactory.php | 24 +++++++++++++++++++ 5 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 src/ZfcUser/Factory/Authentication/Adapter/DbFactory.php create mode 100644 src/ZfcUser/Factory/Authentication/Storage/DbFactory.php diff --git a/Module.php b/Module.php index eb7ad717..0e0cfa4f 100644 --- a/Module.php +++ b/Module.php @@ -67,8 +67,6 @@ public function getServiceConfig() 'zfcuser_zend_db_adapter' => 'Zend\Db\Adapter\Adapter', ), 'invokables' => array( - 'ZfcUser\Authentication\Adapter\Db' => 'ZfcUser\Authentication\Adapter\Db', - 'ZfcUser\Authentication\Storage\Db' => 'ZfcUser\Authentication\Storage\Db', 'zfcuser_user_service' => 'ZfcUser\Service\User', 'zfcuser_register_form_hydrator' => 'Zend\Stdlib\Hydrator\ClassMethods', ), @@ -89,6 +87,9 @@ public function getServiceConfig() 'zfcuser_register_form' => 'ZfcUser\Factory\Form\Register', 'zfcuser_change_password_form' => 'ZfcUser\Factory\Form\ChangePassword', 'zfcuser_change_email_form' => 'ZfcUser\Factory\Form\ChangeEmail', + + 'ZfcUser\Authentication\Adapter\Db' => 'ZfcUser\Factory\Authentication\Adapter\DbFactory', + 'ZfcUser\Authentication\Storage\Db' => 'ZfcUser\Factory\Authentication\Storage\DbFactory', ), ); } diff --git a/src/ZfcUser/Authentication/Adapter/Db.php b/src/ZfcUser/Authentication/Adapter/Db.php index c8a5b24e..a4f0db06 100644 --- a/src/ZfcUser/Authentication/Adapter/Db.php +++ b/src/ZfcUser/Authentication/Adapter/Db.php @@ -12,7 +12,7 @@ use ZfcUser\Mapper\User as UserMapperInterface; use ZfcUser\Options\AuthenticationOptionsInterface; -class Db extends AbstractAdapter implements ServiceManagerAwareInterface +class Db extends AbstractAdapter { /** * @var UserMapperInterface diff --git a/src/ZfcUser/Authentication/Storage/Db.php b/src/ZfcUser/Authentication/Storage/Db.php index d218e87e..f396630e 100644 --- a/src/ZfcUser/Authentication/Storage/Db.php +++ b/src/ZfcUser/Authentication/Storage/Db.php @@ -8,7 +8,7 @@ use Zend\ServiceManager\ServiceManager; use ZfcUser\Mapper\UserInterface as UserMapper; -class Db implements Storage\StorageInterface, ServiceManagerAwareInterface +class Db implements Storage\StorageInterface { /** * @var StorageInterface diff --git a/src/ZfcUser/Factory/Authentication/Adapter/DbFactory.php b/src/ZfcUser/Factory/Authentication/Adapter/DbFactory.php new file mode 100644 index 00000000..9766089f --- /dev/null +++ b/src/ZfcUser/Factory/Authentication/Adapter/DbFactory.php @@ -0,0 +1,24 @@ +setServiceManager($serviceLocator); + return $db; + } +} diff --git a/src/ZfcUser/Factory/Authentication/Storage/DbFactory.php b/src/ZfcUser/Factory/Authentication/Storage/DbFactory.php new file mode 100644 index 00000000..fa8a274f --- /dev/null +++ b/src/ZfcUser/Factory/Authentication/Storage/DbFactory.php @@ -0,0 +1,24 @@ +setServiceManager($serviceLocator); + return $db; + } +} From a89e622af31b5546232bc2cd374bfe939a150f79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Str=C3=B8m?= Date: Thu, 5 May 2016 21:14:43 +0200 Subject: [PATCH 53/59] Actually inject controller dependencies --- src/ZfcUser/Factory/Controller/UserControllerFactory.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ZfcUser/Factory/Controller/UserControllerFactory.php b/src/ZfcUser/Factory/Controller/UserControllerFactory.php index 745ae1bb..782ebfb6 100644 --- a/src/ZfcUser/Factory/Controller/UserControllerFactory.php +++ b/src/ZfcUser/Factory/Controller/UserControllerFactory.php @@ -35,6 +35,13 @@ public function createService(ServiceLocatorInterface $controllerManager) $controller = new UserController($redirectCallback); $controller->setServiceLocator($serviceManager); + $controller->setChangeEmailForm($this->serviceLocator->get('zfcuser_change_email_form')); + $controller->setOptions($this->serviceLocator->get('zfcuser_module_options')); + $controller->setChangePasswordForm($this->serviceLocator->get('zfcuser_change_password_form')); + $controller->setLoginForm($this->serviceLocator->get('zfcuser_login_form')); + $controller->setRegisterForm($this->serviceLocator->get('zfcuser_register_form')); + $controller->setUserService($this->serviceLocator->get('zfcuser_user_service')); + return $controller; } } From c447f6eb8cd7753eee46f65dae1b320afecf2479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Str=C3=B8m?= Date: Thu, 5 May 2016 21:21:46 +0200 Subject: [PATCH 54/59] Fix controller tests --- .../Controller/UserControllerTest.php | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/tests/ZfcUserTest/Controller/UserControllerTest.php b/tests/ZfcUserTest/Controller/UserControllerTest.php index c08759f1..f4072312 100644 --- a/tests/ZfcUserTest/Controller/UserControllerTest.php +++ b/tests/ZfcUserTest/Controller/UserControllerTest.php @@ -964,7 +964,7 @@ public function testChangeEmailAction($status, $postRedirectGetReturn, $isValid, * @depend testActionControllHasIdentity */ public function testSetterGetterServices( - $methode, + $method, $useServiceLocator, $servicePrototype, $serviceName, @@ -984,34 +984,21 @@ public function testSetterGetterServices( if ($useServiceLocator) { $serviceLocator = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface'); - $formElementManager = $this->getMock('Zend\Form\FormElementManager'); - # Forms now use the FormElementManager so we need mock accordingly - if ($servicePrototype instanceof Form) { - $serviceLocator->expects($this->once()) - ->method('get') - ->with('FormElementManager') - ->will($this->returnValue($formElementManager)); - $formElementManager->expects($this->once()) - ->method('get') - ->with($serviceName) - ->will($this->returnValue($servicePrototype)); - } else { - $serviceLocator->expects($this->once()) - ->method('get') - ->with($serviceName) - ->will($this->returnValue($servicePrototype)); - } + $serviceLocator->expects($this->once()) + ->method('get') + ->with($serviceName) + ->will($this->returnValue($servicePrototype)); $controller->setServiceLocator($serviceLocator); } else { - call_user_func(array($controller, 'set' . $methode), $servicePrototype); + call_user_func(array($controller, 'set' . $method), $servicePrototype); } - $result = call_user_func(array($controller, 'get' . $methode)); + $result = call_user_func(array($controller, 'get' . $method)); $this->assertInstanceOf(get_class($servicePrototype), $result); $this->assertSame($servicePrototype, $result); // we need two check for every case - $result = call_user_func(array($controller, 'get' . $methode)); + $result = call_user_func(array($controller, 'get' . $method)); $this->assertInstanceOf(get_class($servicePrototype), $result); $this->assertSame($servicePrototype, $result); } @@ -1107,7 +1094,7 @@ public function providerTestSetterGetterServices () return array( - // $methode, $useServiceLocator, $servicePrototype, $serviceName, $loginFormCallback + // $method, $useServiceLocator, $servicePrototype, $serviceName, $loginFormCallback array('UserService', true, new UserService(), 'zfcuser_user_service' ), array('UserService', false, new UserService(), null ), array('RegisterForm', true, new Form(), 'zfcuser_register_form' ), From 65a57a4f0b32f91841f4b77aa9d246fe9246ce5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Str=C3=B8m?= Date: Sat, 7 May 2016 13:11:26 +0200 Subject: [PATCH 55/59] Remove old "use" statements for ServiceManagerAwareInterface --- src/ZfcUser/Authentication/Adapter/Db.php | 2 -- src/ZfcUser/Authentication/Storage/Db.php | 1 - src/ZfcUser/Factory/Service/UserFactory.php | 24 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 src/ZfcUser/Factory/Service/UserFactory.php diff --git a/src/ZfcUser/Authentication/Adapter/Db.php b/src/ZfcUser/Authentication/Adapter/Db.php index a4f0db06..b07744ca 100644 --- a/src/ZfcUser/Authentication/Adapter/Db.php +++ b/src/ZfcUser/Authentication/Adapter/Db.php @@ -2,9 +2,7 @@ namespace ZfcUser\Authentication\Adapter; -use DateTime; use Zend\Authentication\Result as AuthenticationResult; -use Zend\ServiceManager\ServiceManagerAwareInterface; use Zend\ServiceManager\ServiceManager; use Zend\Crypt\Password\Bcrypt; use Zend\Session\Container as SessionContainer; diff --git a/src/ZfcUser/Authentication/Storage/Db.php b/src/ZfcUser/Authentication/Storage/Db.php index f396630e..62bdef8f 100644 --- a/src/ZfcUser/Authentication/Storage/Db.php +++ b/src/ZfcUser/Authentication/Storage/Db.php @@ -4,7 +4,6 @@ use Zend\Authentication\Storage; use Zend\Authentication\Storage\StorageInterface; -use Zend\ServiceManager\ServiceManagerAwareInterface; use Zend\ServiceManager\ServiceManager; use ZfcUser\Mapper\UserInterface as UserMapper; diff --git a/src/ZfcUser/Factory/Service/UserFactory.php b/src/ZfcUser/Factory/Service/UserFactory.php new file mode 100644 index 00000000..1c22ee0e --- /dev/null +++ b/src/ZfcUser/Factory/Service/UserFactory.php @@ -0,0 +1,24 @@ +setServiceManager($serviceLocator); + return $service; + } +} From d26883598743e17914b713a536d0c61cb545f1fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Str=C3=B8m?= Date: Sat, 7 May 2016 13:11:43 +0200 Subject: [PATCH 56/59] Remove ServiceManagerAwareInterface from User service --- Module.php | 3 ++- src/ZfcUser/Service/User.php | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Module.php b/Module.php index 0e0cfa4f..e1ac80d6 100644 --- a/Module.php +++ b/Module.php @@ -67,7 +67,6 @@ public function getServiceConfig() 'zfcuser_zend_db_adapter' => 'Zend\Db\Adapter\Adapter', ), 'invokables' => array( - 'zfcuser_user_service' => 'ZfcUser\Service\User', 'zfcuser_register_form_hydrator' => 'Zend\Stdlib\Hydrator\ClassMethods', ), 'factories' => array( @@ -90,6 +89,8 @@ public function getServiceConfig() 'ZfcUser\Authentication\Adapter\Db' => 'ZfcUser\Factory\Authentication\Adapter\DbFactory', 'ZfcUser\Authentication\Storage\Db' => 'ZfcUser\Factory\Authentication\Storage\DbFactory', + + 'zfcuser_user_service' => 'ZfcUser\Factory\Service\UserFactory', ), ); } diff --git a/src/ZfcUser/Service/User.php b/src/ZfcUser/Service/User.php index 81349c80..b865823c 100644 --- a/src/ZfcUser/Service/User.php +++ b/src/ZfcUser/Service/User.php @@ -4,7 +4,6 @@ use Zend\Authentication\AuthenticationService; use Zend\Form\Form; -use Zend\ServiceManager\ServiceManagerAwareInterface; use Zend\ServiceManager\ServiceManager; use Zend\Crypt\Password\Bcrypt; use Zend\Stdlib\Hydrator; @@ -12,7 +11,7 @@ use ZfcUser\Mapper\UserInterface as UserMapperInterface; use ZfcUser\Options\UserServiceOptionsInterface; -class User extends EventProvider implements ServiceManagerAwareInterface +class User extends EventProvider { /** From 3150e67873cc1e53b4a6b2b854758a0cd8979b29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Str=C3=B8m?= Date: Sat, 7 May 2016 13:13:13 +0200 Subject: [PATCH 57/59] Fix usage of servicelocator in UserControllerFactory --- .../Factory/Controller/UserControllerFactory.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ZfcUser/Factory/Controller/UserControllerFactory.php b/src/ZfcUser/Factory/Controller/UserControllerFactory.php index 782ebfb6..88122b4d 100644 --- a/src/ZfcUser/Factory/Controller/UserControllerFactory.php +++ b/src/ZfcUser/Factory/Controller/UserControllerFactory.php @@ -35,12 +35,12 @@ public function createService(ServiceLocatorInterface $controllerManager) $controller = new UserController($redirectCallback); $controller->setServiceLocator($serviceManager); - $controller->setChangeEmailForm($this->serviceLocator->get('zfcuser_change_email_form')); - $controller->setOptions($this->serviceLocator->get('zfcuser_module_options')); - $controller->setChangePasswordForm($this->serviceLocator->get('zfcuser_change_password_form')); - $controller->setLoginForm($this->serviceLocator->get('zfcuser_login_form')); - $controller->setRegisterForm($this->serviceLocator->get('zfcuser_register_form')); - $controller->setUserService($this->serviceLocator->get('zfcuser_user_service')); + $controller->setChangeEmailForm($serviceManager->get('zfcuser_change_email_form')); + $controller->setOptions($serviceManager->get('zfcuser_module_options')); + $controller->setChangePasswordForm($serviceManager->get('zfcuser_change_password_form')); + $controller->setLoginForm($serviceManager->get('zfcuser_login_form')); + $controller->setRegisterForm($serviceManager->get('zfcuser_register_form')); + $controller->setUserService($serviceManager->get('zfcuser_user_service')); return $controller; } From 0d225b189364f8da485d11e64f172e5fd840824a Mon Sep 17 00:00:00 2001 From: Matias Iglesias Date: Wed, 25 May 2016 18:22:51 -0300 Subject: [PATCH 58/59] Spanish translation --- src/ZfcUser/language/es_ES.mo | Bin 0 -> 2464 bytes src/ZfcUser/language/es_ES.po | 129 ++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 src/ZfcUser/language/es_ES.mo create mode 100644 src/ZfcUser/language/es_ES.po diff --git a/src/ZfcUser/language/es_ES.mo b/src/ZfcUser/language/es_ES.mo new file mode 100644 index 0000000000000000000000000000000000000000..8f65fc53dded80e3b476a4f99b71810d936b038c GIT binary patch literal 2464 zcma)+J!~9B6vrnJNOF7_!uN;K3lJ0pd)%E#VlJ3`*bcE2+o$+~P#QGeojVWOow>}+ z+SnZuQVJ-bh$u-#mjZ2{0)2z{0n>-ybV489=KnKSHKC7 z`%~Zn@EwrtX2I9M4mbgBfcwEKRsT!yCG@XV{HdD13GT!ApH=@>#lOJ^F}`Q75XZp% zU=utEvfs-f$GHV^{GWrrBFAsQSJ59}F|WG{z6|~XJ`dgk4}vvp%IhaVUS9|2z%w9R zh%4Z8;1}TI;I|;_^+PrO2lx>B|A0?{`w$ezHwm)d%OKC^AnWld_$c@l$a-A^5sJ7D zUIM=ddH)HB%KLS}Nw5dL0DcDY5%OA&mt$u;$W*i^D>8ULK1*)A2j{~v*6`!Td2wv) zmmBNBu|3NjG^A8$^$3XLFB-xtY6@W#=g))B@ZV{2Dz+}6Oon((n?8j#McNGVKpWCi z&*ml(r*n*&pko=dHPn+jRY{#Xsghn%aGNCiQk%M%U6ZD-Xg-4l);c=uhhrV-{RZze z9L}ACPa2MkIqe6j+@vL$DN%SR|4Al^Q{GctI8Vsuag2U1Pt(o1IH%IoiY2vC?pl0} zd@k90%5TXA*!8s!%Bkd}7_A?E&;axMN_bg6KH=v5G^qkVKgFsD(CN>ctn~q;^3KtP9bi@9QKwllOhpwQbt!MTuGu zN@l0Flu7Eb&1#+HZZzvuQA^PrvTIYT(VU7J$D>w@nyq&0?Kc`zjRp*(3u;~SK4ZIM zQR8UTI!evyHm_m3^U{Z?>!k6i4A!-25x!Bp3;k4i{&*MF4eF|YD#K|eT4fwgUAp(+ z!Sr+4S5X&{VtqAF3thtTc!(eKDc-Z6HYxwn{7P+cVR3#eRkPlx%~}&s_E8r#(x!m2 zcnejp%?U0k=T(@w*gYFfkL@_Eo^sK=iEV-)+BChYL+!)pePxs@^X*ub=s?Z-bp3d( zljcsQ(OK&<-zGCCx_+j0g38aCBZdymQ1kT@HL;>d!LJE!`v&Evx&+QrY_*AXf=CtL z{_^t2diw_7{xsEzL^a`l_vE^DZ{opV6GbLh>!>Dt;w_Nbs+JC}aM3NP6qSQ*jE*g# zREnozWP%9rlx%+|M^hYBH6-JZ%Tz4cY}F}}lv$5CCuZ;TEY3?xG~To_)17aCPrPnVB6OrK0F-~^JX2URqlfvdX7TDiu~^9aMuzlW!=T~ g4jt~nNl`W^h1}=TY0FYq^6qxJ\n" +"Language-Team: Meridiem IT Outsourcing \n" +"Language: es_ES\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.7\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: src/ZfcUser/language/msgIds.php:6 +msgid "Username" +msgstr "Nombre de usuario" + +#: src/ZfcUser/language/msgIds.php:7 +msgid "Email" +msgstr "Correo electrónico" + +#: src/ZfcUser/language/msgIds.php:8 +msgid "New Email" +msgstr "Nuevo correo electrónico" + +#: src/ZfcUser/language/msgIds.php:9 +msgid "Verify New Email" +msgstr "Confirmar correo electrónico" + +#: src/ZfcUser/language/msgIds.php:10 +msgid "Display Name" +msgstr "Nombre a mostrar" + +#: src/ZfcUser/language/msgIds.php:11 +msgid "Password" +msgstr "Contraseña" + +#: src/ZfcUser/language/msgIds.php:12 +msgid "Password Verify" +msgstr "Confirmar Contraseña" + +#: src/ZfcUser/language/msgIds.php:13 +msgid "Current Password" +msgstr "Contraseña actual" + +#: src/ZfcUser/language/msgIds.php:14 +msgid "Verify New Password" +msgstr "Confirmar nueva contraseña" + +#: src/ZfcUser/language/msgIds.php:15 +msgid "New Password" +msgstr "Nueva contraseña" + +#: src/ZfcUser/language/msgIds.php:16 +msgid "Please type the following text" +msgstr "Por favor, ingrese el siguiente texto" + +#: src/ZfcUser/language/msgIds.php:17 +msgid "Submit" +msgstr "Enviar" + +#: src/ZfcUser/language/msgIds.php:18 view/zfc-user/user/login.phtml:1 +msgid "Sign In" +msgstr "Iniciar sesión" + +#: src/ZfcUser/language/msgIds.php:19 view/zfc-user/user/register.phtml:1 +msgid "Register" +msgstr "Registrarse" + +#: src/ZfcUser/language/msgIds.php:20 +msgid "No record matching the input was found" +msgstr "No se encontraron registros coincidentes" + +#: src/ZfcUser/language/msgIds.php:21 +msgid "A record matching the input was found" +msgstr "Se encontró un registro coincidente" + +#: src/ZfcUser/language/msgIds.php:22 +msgid "Authentication failed. Please try again." +msgstr "Autenticación fallida. Por favor, intente nuevamente." + +#: view/zfc-user/user/login.phtml:31 +msgid "Not registered?" +msgstr "Aún no se ha registrado?" + +#: view/zfc-user/user/login.phtml:31 +msgid "Sign up!" +msgstr "Regístrese!" + +#: view/zfc-user/user/changeemail.phtml:1 +#, php-format +msgid "Change Email for %s" +msgstr "Cambiar correo electrónico por %s" + +#: view/zfc-user/user/changeemail.phtml:3 +msgid "Email address changed successfully." +msgstr "" +"La dirección de correo electrónico ha sido cambiada correctamente." + +#: view/zfc-user/user/changeemail.phtml:5 +msgid "Unable to update your email address. Please try again." +msgstr "" +"No se pudo actualizar su dirección de correo electrónico. Por favor, " +"intente nuevamente." + +#: view/zfc-user/user/changepassword.phtml:1 +#, php-format +msgid "Change Password for %s" +msgstr "Cambiar contraseña por %s" + +#: view/zfc-user/user/changepassword.phtml:3 +msgid "Password changed successfully." +msgstr "La contraseña ha sido actualizada correctamente." + +#: view/zfc-user/user/changepassword.phtml:5 +msgid "Unable to update your password. Please try again." +msgstr "" +"No se pudo actualizar su contraseña. Por favor, intente nuevamente." + +#: view/zfc-user/user/index.phtml:2 +msgid "Hello" +msgstr "Hola" + +#: view/zfc-user/user/index.phtml:3 +msgid "Sign Out" +msgstr "Cerrar sesión" From 27e859807dc945557194510f04def07536ed8f82 Mon Sep 17 00:00:00 2001 From: Corneliu Iancu Date: Sat, 9 Jul 2016 00:29:04 +0300 Subject: [PATCH 59/59] Update RegisterFilter.php --- src/ZfcUser/Form/RegisterFilter.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ZfcUser/Form/RegisterFilter.php b/src/ZfcUser/Form/RegisterFilter.php index 071fdcc6..399c7699 100644 --- a/src/ZfcUser/Form/RegisterFilter.php +++ b/src/ZfcUser/Form/RegisterFilter.php @@ -134,6 +134,7 @@ public function setUsernameValidator($usernameValidator) public function setOptions(RegistrationOptionsInterface $options) { $this->options = $options; + return $this; } /**