Permalink
Browse files

Revert PR #91, move Module.php out of src/

This was mainly to appease composer's PSR0 autoloader, however we should
not have to alter module structure (especially the one and only single
requirement for a ZF2 module) simply for the sake of composer. Besides,
composer supports classmaps which resolves the issue just fine.
  • Loading branch information...
1 parent d2f034d commit 681468b21c1b6db8e794601d34f72d9986b6eebf @EvanDotPro EvanDotPro committed Jul 30, 2012
Showing with 130 additions and 132 deletions.
  1. +129 −1 Module.php
  2. +1 −1 composer.json
  3. +0 −130 src/ZfcUser/Module.php
View
@@ -1,2 +1,130 @@
<?php
-require_once(__DIR__ . '/src/ZfcUser/Module.php');
+
+namespace ZfcUser;
+
+use Zend\ModuleManager\ModuleManager,
+ Zend\ModuleManager\Feature\AutoloaderProviderInterface,
+ Zend\ModuleManager\Feature\ConfigProviderInterface,
+ 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_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;
+ },
+ ),
+ );
+ }
+}
View
@@ -28,7 +28,7 @@
"ZfcUser": "src/"
},
"classmap": [
- "./"
+ "./Module.php"
]
}
}
View
@@ -1,130 +0,0 @@
-<?php
-
-namespace ZfcUser;
-
-use Zend\ModuleManager\ModuleManager,
- Zend\ModuleManager\Feature\AutoloaderProviderInterface,
- Zend\ModuleManager\Feature\ConfigProviderInterface,
- 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__,
- ),
- ),
- );
- }
-
- 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_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;
- },
- ),
- );
- }
-}

0 comments on commit 681468b

Please sign in to comment.