/** * {@inheritDoc} */ public function createService(ServiceLocatorInterface $serviceLocator) { $options = $serviceLocator->get('zfcuser_module_options'); $form = new Login(null, $options); $form->setInputFilter(new LoginFilter($options)); return $form; }
/** * @covers ZfcUser\Form\Login::getAuthenticationOptions * @covers ZfcUser\Form\Login::setAuthenticationOptions */ public function testSetGetAuthenticationOptions() { $options = $this->getMock('ZfcUser\\Options\\AuthenticationOptionsInterface'); $options->expects($this->once())->method('getAuthIdentityFields')->will($this->returnValue(array())); $form = new Form(null, $options); $this->assertSame($options, $form->getAuthenticationOptions()); }
/** * {@inheritDoc} */ public function createService(ServiceLocatorInterface $serviceManager) { /* @var $options Options\ModuleOptions */ $options = $serviceManager->get('zfcuser_module_options'); $inputFilter = new LoginFilter($options); $form = new Login(null, $options); $form->setInputFilter($inputFilter); return $form; }
public function getServiceConfig() { return array('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_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()); }, 'zfcuser_auth_service' => function ($sm) { return new \Zend\Authentication\AuthenticationService($sm->get('ZfcUser\\Authentication\\Storage\\Db'), $sm->get('ZfcUser\\Authentication\\Adapter\\AdapterChain')); }, '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'); var_dump($options); dia; $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; }, '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; })); }
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 = $sm->get('zfcuser_module_options'); $form = new Form\Login(null, $options); // Inject the FormElementManager to support custom FormElements $form->getFormFactory()->setFormElementManager($fem); $form->setInputFilter(new Form\LoginFilter($options)); return $form; }
public function __construct($name, AuthenticationOptionsInterface $options) { $this->setUseInputFilterDefaults(false); // remove zf2 default validators $this->setAuthenticationOptions($options); parent::__construct($name, $options); $this->get('identity')->setAttributes(array('class' => 'form-control', 'id' => 'identity', 'autofocus' => 'autofocus')); $this->get('credential')->setAttributes(array('placeholder' => 'Password', 'class' => 'form-control', 'id' => 'credential')); $this->add(array('type' => 'Zend\\Form\\Element\\Checkbox', 'name' => 'remember_me', 'options' => array('label' => 'Remember Me', 'use_hidden_element' => true, 'checked_value' => '1', 'unchecked_value' => '0'), 'attributes' => array('class' => 'checkbox', 'id' => 'remember_me'))); $this->get('submit')->setName('login')->setAttributes(array('class' => 'btn btn-sm btn-primary btn-block', 'id' => 'login')); }
/** * Constructor * * @param string $name * @param AuthenticationOptionsInterface $options */ public function __construct($name = null, AuthenticationOptionsInterface $options) { parent::__construct($name, $options); $this->add(['type' => 'Zend\\Form\\Element\\Checkbox', 'name' => 'remember_me', 'options' => ['label' => 'Stay logged in', 'use_hidden_element' => true, 'checked_value' => '1', 'unchecked_value' => '0']]); }