Skip to content

@weierophinney /gist:1348598
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Prototype of module initialization listener system
<?php
interface Installable
{
public function install();
}
interface Upgradable
{
public function upgrade();
}
interface ConfigProvider
{
public function getConfig();
}
interface AutoloaderProvider
{
public function initAutoloader();
}
namespace FooBlog
{
class Module implements \Installable, \Upgradable, \ConfigProvider, \AutoloaderProvider
{
public function install()
{
}
public function upgrade()
{
}
public function getConfig()
{
}
public function initAutoloader()
{
}
}
}
namespace Zend\Module\Listener
{
class AutoloadTrigger
{
public function __invoke($e)
{
$module = $e->getModule();
if (!$module instanceof \AutoloaderProvider) {
return;
}
$module->initAutoloader();
}
}
}
$manager = new Zend\Module\Manager($modules);
$autoloader = new Zend\Module\Listener\AutoloadTrigger();
$config = new Zend\Module\Listener\ConfigListener();
$installer = new Zend\Module\Listener\InstallerListener();
$upgrader = new Zend\Module\Listener\UpgraderListener();
$manager->events()->attach('loadModule', $autoloader);
$manager->events()->attach('loadModule', $config);
$manager->events()->attach('loadModule', $installer);
$manager->events()->attach('loadModule', $upgrader);
$bootstrap = new Bootstrap($config->getMergedConfig());
$app = new Application();
$bootstrap->bootstrap($app);
$app->run()->send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.