Merge remote-tracking branch 'weierophinney/feature/mvc-servicemanager-refactor'
authorEvan Coury <me@evancoury.com>
Thu, 17 May 2012 21:06:23 +0000 (14:06 -0700)
committerEvan Coury <me@evancoury.com>
Thu, 17 May 2012 21:06:23 +0000 (14:06 -0700)
Conflicts:
vendor/ZendFramework

.gitmodules
config/application.config.php
config/autoload/README.md
config/autoload/global.config.php [deleted file]
config/autoload/global.php [new file with mode: 0644]
config/autoload/local.config.php.dist [deleted file]
config/autoload/local.php.dist [new file with mode: 0644]
module/Application/Module.php
module/Application/config/module.config.php
public/index.php
vendor/ZendFramework

index 8f630ff..a974f87 100644 (file)
@@ -1,3 +1,3 @@
 [submodule "vendor/ZendFramework"]
        path = vendor/ZendFramework
-       url = git://github.com/zendframework/zf2.git
+       url = git://github.com/weierophinney/zf2.git
index 9edb86d..e8868a3 100644 (file)
@@ -11,4 +11,9 @@ return array(
             './vendor',
         ),
     ),
+    'service_manager' => array(
+        'use_defaults' => true,
+        'factories'    => array(
+        ),
+    ),
 );
index 3b36bee..4e504db 100644 (file)
@@ -2,7 +2,7 @@ About this directory:
 =====================
 
 By default, this application is configured to load all configs in
-`./config/autoload/{,*.}{global,local}.config.php`. Doing this provides a
+`./config/autoload/{,*.}{global,local}.php`. Doing this provides a
 location for a developer to drop in configuration override files provided by
 modules, as well as cleanly provide individual, application-wide config files
 for things like database connections, etc.
diff --git a/config/autoload/global.config.php b/config/autoload/global.config.php
deleted file mode 100644 (file)
index b03c0c4..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-/**
- * Global Configuration Override
- *
- * You can use this file for overridding configuration values from modules, etc.  
- * You would place values in here that are agnostic to the environment and not 
- * sensitive to security. 
- *
- * @NOTE: In practice, this file will typically be INCLUDED in your source 
- * control, so do not include passwords or other sensitive information in this 
- * file.
- */
-
-return array(
-    // ...
-);
diff --git a/config/autoload/global.php b/config/autoload/global.php
new file mode 100644 (file)
index 0000000..b03c0c4
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Global Configuration Override
+ *
+ * You can use this file for overridding configuration values from modules, etc.  
+ * You would place values in here that are agnostic to the environment and not 
+ * sensitive to security. 
+ *
+ * @NOTE: In practice, this file will typically be INCLUDED in your source 
+ * control, so do not include passwords or other sensitive information in this 
+ * file.
+ */
+
+return array(
+    // ...
+);
diff --git a/config/autoload/local.config.php.dist b/config/autoload/local.config.php.dist
deleted file mode 100644 (file)
index 7862eba..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-/**
- * Local Configuration Override
- *
- * This configuration override file is for overriding environment-specific and
- * security-sensitive configuration information. Copy this file without the
- * .dist extension at the end and populate values as needed.
- *
- * @NOTE: This file is ignored from Git by default with the .gitignore included
- * in ZendSkeletonApplication. This is a good practice, as it prevents sensitive
- * credentials from accidentally being comitted into version control.
- */
-
-return array(
-    // ...
-);
diff --git a/config/autoload/local.php.dist b/config/autoload/local.php.dist
new file mode 100644 (file)
index 0000000..7862eba
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Local Configuration Override
+ *
+ * This configuration override file is for overriding environment-specific and
+ * security-sensitive configuration information. Copy this file without the
+ * .dist extension at the end and populate values as needed.
+ *
+ * @NOTE: This file is ignored from Git by default with the .gitignore included
+ * in ZendSkeletonApplication. This is a good practice, as it prevents sensitive
+ * credentials from accidentally being comitted into version control.
+ */
+
+return array(
+    // ...
+);
index 5f93426..a7dd66b 100644 (file)
@@ -2,19 +2,8 @@
 
 namespace Application;
 
-use Zend\Module\Manager,
-    Zend\EventManager\StaticEventManager,
-    Zend\Module\Consumer\AutoloaderProvider;
-
-class Module implements AutoloaderProvider
+class Module
 {
-    public function init(Manager $moduleManager)
-    {
-        $events       = $moduleManager->events();
-        $sharedEvents = $events->getSharedManager();
-        $sharedEvents->attach('bootstrap', 'bootstrap', array($this, 'initializeView'), 100);
-    }
-
     public function getAutoloaderConfig()
     {
         return array(
@@ -33,13 +22,4 @@ class Module implements AutoloaderProvider
     {
         return include __DIR__ . '/config/module.config.php';
     }
-    
-    public function initializeView($e)
-    {
-        $app          = $e->getParam('application');
-        $basePath     = $app->getRequest()->getBasePath();
-        $locator      = $app->getLocator();
-        $renderer     = $locator->get('Zend\View\Renderer\PhpRenderer');
-        $renderer->plugin('basePath')->setBasePath($basePath);
-    }
 }
index 6a300aa..b68e949 100644 (file)
 <?php
 return array(
-    'di' => array(
-        'instance' => array(
-
-            // Setup for controllers.
-
-            // Injecting the plugin broker for controller plugins into
-            // the action controller for use by all controllers that
-            // extend it
-            'Zend\Mvc\Controller\ActionController' => array(
-                'parameters' => array(
-                    'broker'       => 'Zend\Mvc\Controller\PluginBroker',
-                ),
-            ),
-            'Zend\Mvc\Controller\PluginBroker' => array(
-                'parameters' => array(
-                    'loader' => 'Zend\Mvc\Controller\PluginLoader',
-                ),
-            ),
-
-            // Setup for router and routes
-            'Zend\Mvc\Router\RouteStackInterface' => array(
-                'parameters' => array(
-                    'routes' => array(
-                        'default' => array(
-                            'type'    => 'Zend\Mvc\Router\Http\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' => 'Application\Controller\IndexController',
-                                    'action'     => 'index',
-                                ),
-                            ),
-                        ),
-                        'home' => array(
-                            'type' => 'Zend\Mvc\Router\Http\Literal',
-                            'options' => array(
-                                'route'    => '/',
-                                'defaults' => array(
-                                    'controller' => 'Application\Controller\IndexController',
-                                    'action'     => 'index',
-                                ),
-                            ),
-                        ),
+    'router' => array(
+        'routes' => array(
+            'default' => array(
+                'type'    => 'Zend\Mvc\Router\Http\Segment',
+                'options' => array(
+                    'route'    => '/[:controller[/:action]]',
+                    'constraints' => array(
+                        'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
+                        'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
                     ),
-                ),
-            ),
-
-            // Setup for the view layer.
-
-            // Using the PhpRenderer, which just handles html produced by php 
-            // scripts
-            'Zend\View\Renderer\PhpRenderer' => array(
-                'parameters' => array(
-                    'resolver' => 'Zend\View\Resolver\AggregateResolver',
-                ),
-            ),
-            // Defining how the view scripts should be resolved by stacking up
-            // a Zend\View\Resolver\TemplateMapResolver and a
-            // Zend\View\Resolver\TemplatePathStack
-            'Zend\View\Resolver\AggregateResolver' => array(
-                'injections' => array(
-                    'Zend\View\Resolver\TemplateMapResolver',
-                    'Zend\View\Resolver\TemplatePathStack',
-                ),
-            ),
-            // Defining where the layout/layout view should be located
-            'Zend\View\Resolver\TemplateMapResolver' => array(
-                'parameters' => array(
-                    'map'  => array(
-                        'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
+                    'defaults' => array(
+                        'controller' => 'IndexController',
+                        'action'     => 'index',
                     ),
                 ),
             ),
-            // Defining where to look for views. This works with multiple paths,
-            // very similar to include_path
-            'Zend\View\Resolver\TemplatePathStack' => array(
-                'parameters' => array(
-                    'paths'  => array(
-                        'application' => __DIR__ . '/../view',
+            'home' => array(
+                'type' => 'Zend\Mvc\Router\Http\Literal',
+                'options' => array(
+                    'route'    => '/',
+                    'defaults' => array(
+                        'controller' => 'IndexController',
+                        'action'     => 'index',
                     ),
                 ),
             ),
-            // View for the layout
-            'Zend\Mvc\View\DefaultRenderingStrategy' => array(
-                'parameters' => array(
-                    'layoutTemplate' => 'layout/layout',
-                ),
-            ),
-            // Injecting the router into the url helper
-            'Zend\View\Helper\Url' => array(
-                'parameters' => array(
-                    'router' => 'Zend\Mvc\Router\RouteStackInterface',
-                ),
-            ),
-            // Configuration for the doctype helper
-            'Zend\View\Helper\Doctype' => array(
-                'parameters' => array(
-                    'doctype' => 'HTML5',
-                ),
-            ),
-            // View script rendered in case of 404 exception
-            'Zend\Mvc\View\RouteNotFoundStrategy' => array(
-                'parameters' => array(
-                    'displayNotFoundReason' => true,
-                    'displayExceptions'     => true,
-                    'notFoundTemplate'      => 'error/404',
-                ),
-            ),
-            // View script rendered in case of other exceptions
-            'Zend\Mvc\View\ExceptionStrategy' => array(
-                'parameters' => array(
-                    'displayExceptions' => true,
-                    'exceptionTemplate' => 'error/index',
-                ),
-            ),
+        ),
+    ),
+    'controller' => array(
+        'classes' => array(
+            'IndexController' => 'Application\Controller\IndexController'
+        ),
+    ),
+    'view_manager' => array(
+        'display_not_found_reason' => true,
+        'display_exceptions'       => true,
+        'doctype'                  => 'HTML5',
+        'not_found_template'       => 'error/404',
+        'exception_template'       => 'error/index',
+        'template_map' => array(
+            'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
+            'index/index'   => __DIR__ . '/../view/index/index.phtml',
+            'error/404'     => __DIR__ . '/../view/error/404.phtml',
+            'error/index'   => __DIR__ . '/../view/error/index.phtml',
+        ),
+        'template_path_stack' => array(
+            'application' => __DIR__ . '/../view',
         ),
     ),
 );
index edd629b..2868a5c 100644 (file)
@@ -1,25 +1,21 @@
 <?php
 chdir(dirname(__DIR__));
 require_once (getenv('ZF2_PATH') ?: 'vendor/ZendFramework/library') . '/Zend/Loader/AutoloaderFactory.php';
-Zend\Loader\AutoloaderFactory::factory();
 
-$appConfig = include 'config/application.config.php';
+use Zend\Loader\AutoloaderFactory,
+Zend\ServiceManager\ServiceManager,
+Zend\Mvc\Service\ServiceManagerConfiguration;
 
-$sharedEvents     = new Zend\EventManager\SharedEventManager();
-$listenerOptions  = new Zend\Module\Listener\ListenerOptions($appConfig['module_listener_options']);
-$defaultListeners = new Zend\Module\Listener\DefaultListenerAggregate($listenerOptions);
-$defaultListeners->getConfigListener()->addConfigGlobPath("config/autoload/*.php");
-    
+// setup autoloader
+AutoloaderFactory::factory();
 
-$moduleManager = new Zend\Module\Manager($appConfig['modules']);
-$events        = $moduleManager->events();
-$events->setSharedManager($sharedEvents);
-$events->attach($defaultListeners);
-$moduleManager->loadModules();
+// get application stack configuration
+$configuration = include 'config/application.config.php';
 
-// Create application, bootstrap, and run
-$bootstrap   = new Zend\Mvc\Bootstrap($defaultListeners->getConfigListener()->getMergedConfig());
-$bootstrap->events()->setSharedManager($sharedEvents);
-$application = new Zend\Mvc\Application;
-$bootstrap->bootstrap($application);
-$application->run()->send();
+// setup service manager
+$serviceManager = new ServiceManager(new ServiceManagerConfiguration($configuration['service_manager']));
+$serviceManager->setService('ApplicationConfiguration', $configuration);
+$serviceManager->get('ModuleManager')->loadModules();
+
+// run application
+$serviceManager->get('Application')->bootstrap()->run()->send();
index 448f2bf..8eb84d3 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 448f2bfaad4bfde6200401efda29250a5d6a6af6
+Subproject commit 8eb84d3957d69346bccd876a5dc0f4e2dbb91e9c