Skip to content

Commit

Permalink
Updated for latest zf2 conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanDotPro committed Nov 21, 2011
1 parent ed8fee6 commit a227bf1
Show file tree
Hide file tree
Showing 37 changed files with 49 additions and 55 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "library/ZendFramework"]
path = library/ZendFramework
url = git://git.zendframework.com/zf.git
[submodule "vendor/ZendFramework"]
path = vendor/ZendFramework
url = git://github.com/zendframework/zf2.git
16 changes: 0 additions & 16 deletions configs/application.config.php

This file was deleted.

15 changes: 15 additions & 0 deletions etc/application.config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
return array(
'module_paths' => array(
realpath(dirname(__DIR__) . '/module'),
realpath(dirname(__DIR__) . '/vendor'),
),
'modules' => array(
'Application',
),
'module_listener_options' => array(
'config_cache_enabled' => false,
'cache_dir' => realpath(dirname(__DIR__) . '/data/cache'),
'application_environment' => getenv('APPLICATION_ENV'),
),
);
8 changes: 8 additions & 0 deletions etc/conf.d/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
About this directory:
=====================

By default, this application is configured to load all configs in
`./config/autoload/*.config.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.
1 change: 0 additions & 1 deletion library/ZendFramework
Submodule ZendFramework deleted from 9ef861
25 changes: 11 additions & 14 deletions modules/Application/Module.php → module/Application/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,23 @@

namespace Application;

use Zend\Module\Manager,
Zend\Config\Config,
Zend\EventManager\StaticEventManager,
Zend\Loader\AutoloaderFactory;
use Zend\EventManager\StaticEventManager,
Zend\Module\Consumer\AutoloaderProvider;

class Module
class Module implements AutoloaderProvider
{
protected $view;
protected $viewListener;

public function init(Manager $moduleManager)
public function init()
{
$this->initAutoloader($moduleManager->getOptions()->getApplicationEnv());
$events = StaticEventManager::getInstance();
$events->attach('bootstrap', 'bootstrap', array($this, 'initializeView'), 100);
}

protected function initAutoloader($env = null)
public function getAutoloaderConfig()
{
AutoloaderFactory::factory(array(
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
Expand All @@ -30,19 +27,19 @@ protected function initAutoloader($env = null)
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
));
);
}

public function getConfig()
public function getConfig($env = null)
{
return new Config(include __DIR__ . '/configs/module.config.php');
return include __DIR__ . '/config/module.config.php';
}

public function initializeView($e)
{
$app = $e->getParam('application');
$locator = $app->getLocator();
$config = $e->getParam('modules')->getMergedConfig();
$config = $e->getParam('config');
$view = $this->getView($app);
$viewListener = $this->getViewListener($view, $config);
$app->events()->attachAggregate($viewListener);
Expand Down Expand Up @@ -76,7 +73,7 @@ protected function getView($app)

$view->plugin('headTitle')->setSeparator(' - ')
->setAutoEscape(false)
->append('modules.zendframework.com');
->append('ZF2 Modules');
$this->view = $view;
return $view;
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion public/image
28 changes: 9 additions & 19 deletions public/index.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
<?php
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

// Ensure ZF is on the include path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(__DIR__ . '/../library'),
realpath(__DIR__ . '/../library/ZendFramework/library'),
get_include_path(),
)));

require_once 'Zend/Loader/AutoloaderFactory.php';
require_once dirname(__DIR__) . '/vendor/ZendFramework/library/Zend/Loader/AutoloaderFactory.php';
Zend\Loader\AutoloaderFactory::factory(array('Zend\Loader\StandardAutoloader' => array()));

$appConfig = new Zend\Config\Config(include __DIR__ . '/../configs/application.config.php');
$appConfig = include dirname(__DIR__) . '/etc/application.config.php';

$moduleLoader = new Zend\Loader\ModuleAutoloader($appConfig['module_paths']);
$moduleLoader->register();

$moduleManager = new Zend\Module\Manager(
$appConfig['modules'],
new Zend\Module\ManagerOptions($appConfig['module_manager_options'])
);
$moduleManager = new Zend\Module\Manager($appConfig['modules']);
$listenerOptions = new Zend\Module\Listener\ListenerOptions($appConfig['module_listener_options']);
$moduleManager->setDefaultListenerOptions($listenerOptions);
$moduleManager->getConfigListener()->addConfigGlobPath(dirname(__DIR__) . '/etc/conf.d/*.config.php');
$moduleManager->loadModules();

// Create application, bootstrap, and run
$bootstrap = new Zend\Mvc\Bootstrap($moduleManager);
$application = new Zend\Mvc\Application;
$bootstrap = new Zend\Mvc\Bootstrap($moduleManager->getMergedConfig());
$application = new Zend\Mvc\Application;
$bootstrap->bootstrap($application);
$application->run()->send();
2 changes: 1 addition & 1 deletion public/style
1 change: 1 addition & 0 deletions vendor/ZendFramework
Submodule ZendFramework added at a2777d

0 comments on commit a227bf1

Please sign in to comment.