Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

151 lines (135 sloc) 6.339 kb
<?php
namespace ZfcUser;
use Zend\ModuleManager\ModuleManager;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\ModuleManager\Feature\ServiceProviderInterface;
class Module implements
AutoloaderProviderInterface,
ConfigProviderInterface,
ServiceProviderInterface
{
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
public function getConfig($env = null)
{
return include __DIR__ . '/config/module.config.php';
}
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->setLoginForm($locator->get('zfcuser_login_form'));
return $viewHelper;
},
),
);
}
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',
),
'factories' => array(
'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\Authentication\Adapter\AdapterChain' => 'ZfcUser\Authentication\Adapter\AdapterChainServiceFactory',
'zfcuser_login_form' => function($sm) {
$options = $sm->get('zfcuser_module_options');
$form = new Form\Login(null, $sm->get('zfcuser_module_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, $sm->get('zfcuser_module_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());
return $mapper;
},
),
);
}
}
Jump to Line
Something went wrong with that request. Please try again.