Skip to content

Commit 2dbcf2d

Browse files
author
Codeliner
committed
ChapterFour: Move RoutingService to own module
1 parent 8114cff commit 2dbcf2d

File tree

8 files changed

+55
-6
lines changed

8 files changed

+55
-6
lines changed

config/application.config.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
'DoctrineModule',
66
'DoctrineORMModule',
77
'ZfcTwitterBootstrap',
8+
'CargoBackend',
9+
'RoutingService',
810
'Application',
911
),
1012

module/Application/Module.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ public function onBootstrap(MvcEvent $e)
2323

2424
public function getConfig()
2525
{
26-
$config = include __DIR__ . '/config/module.config.php';
27-
$config['locations'] = include __DIR__ . '/config/locations.php';
28-
$config['itineraries'] = include __DIR__ . '/config/itineraries.php';
29-
return $config;
26+
return include __DIR__ . '/config/module.config.php';
3027
}
3128

3229
public function getAutoloaderConfig()

module/RoutingService/Module.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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-2013 Zend Technologies USA Inc. (http://www.zend.com)
7+
* @license http://framework.zend.com/license/new-bsd New BSD License
8+
*/
9+
10+
namespace RoutingService;
11+
12+
use Zend\Mvc\ModuleRouteListener;
13+
use Zend\Mvc\MvcEvent;
14+
15+
class Module
16+
{
17+
public function onBootstrap(MvcEvent $e)
18+
{
19+
$eventManager = $e->getApplication()->getEventManager();
20+
$moduleRouteListener = new ModuleRouteListener();
21+
$moduleRouteListener->attach($eventManager);
22+
}
23+
24+
public function getConfig()
25+
{
26+
$config = include __DIR__ . '/config/module.config.php';
27+
$config['locations'] = include __DIR__ . '/config/locations.php';
28+
$config['itineraries'] = include __DIR__ . '/config/itineraries.php';
29+
return $config;
30+
}
31+
32+
public function getAutoloaderConfig()
33+
{
34+
return array(
35+
'Zend\Loader\StandardAutoloader' => array(
36+
'namespaces' => array(
37+
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
38+
),
39+
),
40+
);
41+
}
42+
}
File renamed without changes.
File renamed without changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
return array(
3+
'service_manager' => array(
4+
'factories' => array(
5+
'routing_service' => 'RoutingService\Service\RoutingServiceFactory',
6+
),
7+
),
8+
);

module/Application/src/Application/Service/RoutingService.php renamed to module/RoutingService/src/RoutingService/RoutingService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Date: 01.03.14 - 22:35
1010
*/
1111

12-
namespace Application\Service;
12+
namespace RoutingService;
1313

1414
use Application\Domain\Model\Cargo\Itinerary;
1515
use Application\Domain\Model\Cargo\Leg;

module/Application/src/Application/Service/RoutingServiceFactory.php renamed to module/RoutingService/src/RoutingService/RoutingServiceFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Date: 01.03.14 - 22:49
1010
*/
1111

12-
namespace Application\Service;
12+
namespace RoutingService;
1313

1414
use Zend\ServiceManager\FactoryInterface;
1515
use Zend\ServiceManager\ServiceLocatorInterface;

0 commit comments

Comments
 (0)