Advertisement
Guest User

Basic module

a guest
Apr 1st, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.67 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Zend Framework (http://framework.zend.com/)
  4.  *
  5.  * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
  6.  * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  7.  * @license   http://framework.zend.com/license/new-bsd New BSD License
  8.  */
  9.  
  10. namespace Application;
  11.  
  12. use Zend\Mvc\ModuleRouteListener;
  13. use Zend\Mvc\MvcEvent;
  14. use ZF\Apigility\Provider\ApigilityProviderInterface;
  15.  
  16. class Module implements ApigilityProviderInterface
  17. {
  18.     public function onBootstrap(MvcEvent $e)
  19.     {
  20.         $eventManager        = $e->getApplication()->getEventManager();
  21.         $moduleRouteListener = new ModuleRouteListener();
  22.         $moduleRouteListener->attach($eventManager);
  23.     }
  24.  
  25.     public function getConfig()
  26.     {
  27.         return include __DIR__ . '/config/module.config.php';
  28.     }
  29.  
  30.     public function getAutoloaderConfig()
  31.     {
  32. //        var_dump(array(__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,));
  33.         return array(
  34.             'Zend\Loader\StandardAutoloader' => array(
  35.                 'namespaces' => array(
  36.                     __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
  37.                     __NAMESPACE__ => __DIR__ . '/test/' . __NAMESPACE__,
  38.                 ),
  39.             ),
  40.         );
  41.     }
  42.  
  43.  
  44.     public function getServiceConfig()
  45.     {
  46.         return array(
  47.             'factories' => array(
  48.                 'UserService' => function($sm){
  49.                     $em = $sm->get('Doctrine\ORM\EntityManager');
  50.                     return new \Application\Service\UserService($sm,$em);
  51.                 }
  52.             ),
  53.         );
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement