Merge remote-tracking branch 'weierophinney/feature/routing'
authorRob Allen <rob@akrabat.com>
Mon, 2 Jul 2012 13:46:31 +0000 (14:46 +0100)
committerRob Allen <rob@akrabat.com>
Mon, 2 Jul 2012 13:46:31 +0000 (14:46 +0100)
module/Application/Module.php
module/Application/config/module.config.php

index a31d253..2cc8fdb 100644 (file)
@@ -2,8 +2,17 @@
 
 namespace Application;
 
+use Zend\Mvc\ModuleRouteListener;
+
 class Module
 {
+    public function onBootstrap($e)
+    {
+        $eventManager        = $e->getApplication()->getEventManager();
+        $moduleRouteListener = new ModuleRouteListener();
+        $moduleRouteListener->attach($eventManager);
+    }
+
     public function getConfig()
     {
         return include __DIR__ . '/config/module.config.php';
index a52739c..cdda3bd 100644 (file)
@@ -2,35 +2,51 @@
 return array(
     'router' => array(
         'routes' => array(
-            'default' => array(
-                'type'    => 'Zend\Mvc\Router\Http\Segment',
+            'home' => array(
+                'type' => 'Zend\Mvc\Router\Http\Literal',
                 'options' => array(
-                    'route'    => '/[:controller[/:action]]',
-                    'constraints' => array(
-                        'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
-                        'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
-                    ),
+                    'route'    => '/',
                     'defaults' => array(
-                        'controller' => 'index',
+                        'controller' => 'Application\Controller\Index',
                         'action'     => 'index',
                     ),
                 ),
             ),
-            'home' => array(
-                'type' => 'Zend\Mvc\Router\Http\Literal',
+            // The following is a route to simplify getting started creating
+            // new controllers and actions without needing to create a new
+            // module. Simply drop new controllers in, and you can access them
+            // using the path /application/:controller/:action
+            'application' => array(
+                'type'    => 'Literal',
                 'options' => array(
-                    'route'    => '/',
+                    'route'    => '/application',
                     'defaults' => array(
-                        'controller' => 'index',
-                        'action'     => 'index',
+                        '__NAMESPACE__' => 'Application\Controller',
+                        'controller'    => 'Index',
+                        'action'        => 'index',
+                    ),
+                ),
+                'may_terminate' => true,
+                'child_routes' => array(
+                    'default' => array(
+                        'type'    => 'Segment',
+                        'options' => array(
+                            'route'    => '/[:controller[/:action]]',
+                            'constraints' => array(
+                                'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
+                                'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
+                            ),
+                            'defaults' => array(
+                            ),
+                        ),
                     ),
                 ),
             ),
         ),
     ),
-    'controller' => array(
-        'classes' => array(
-            'index' => 'Application\Controller\IndexController'
+    'controllers' => array(
+        'invokables' => array(
+            'Application\Controller\Index' => 'Application\Controller\IndexController'
         ),
     ),
     'view_manager' => array(