-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated Bootstrap #59
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ | |
class Bootstrap | ||
{ | ||
protected static $serviceManager; | ||
protected static $config; | ||
protected static $bootstrap; | ||
|
||
public static function init() | ||
{ | ||
|
@@ -23,12 +25,15 @@ public static function init() | |
$testConfig = include __DIR__ . '/TestConfig.php.dist'; | ||
} | ||
|
||
$zf2ModulePaths = array(dirname(dirname(__DIR__))); | ||
if (($path = static::findParentPath('vendor'))) { | ||
$zf2ModulePaths[] = $path; | ||
} | ||
if (($path = static::findParentPath('module')) !== $zf2ModulePaths[0]) { | ||
$zf2ModulePaths[] = $path; | ||
$zf2ModulePaths = array(); | ||
|
||
if(isset($testConfig['module_listener_options']['module_paths'])) { | ||
$modulePaths = $testConfig['module_listener_options']['module_paths']; | ||
foreach($modulePaths as $modulePath) { | ||
if (($path = static::findParentPath($modulePath)) ) { | ||
$zf2ModulePaths[] = $path; | ||
} | ||
} | ||
} | ||
|
||
$zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR; | ||
|
@@ -48,41 +53,46 @@ public static function init() | |
$serviceManager = new ServiceManager(new ServiceManagerConfig()); | ||
$serviceManager->setService('ApplicationConfig', $config); | ||
$serviceManager->get('ModuleManager')->loadModules(); | ||
|
||
static::$serviceManager = $serviceManager; | ||
static::$config = $config; | ||
} | ||
|
||
public static function getServiceManager() | ||
{ | ||
return static::$serviceManager; | ||
} | ||
|
||
public static function getConfig() | ||
{ | ||
return static::$config; | ||
} | ||
|
||
protected static function initAutoloader() | ||
{ | ||
$vendorPath = static::findParentPath('vendor'); | ||
|
||
if (is_readable($vendorPath . '/autoload.php')) { | ||
$loader = include $vendorPath . '/autoload.php'; | ||
} | ||
} else { | ||
$zf2Path = getenv('ZF2_PATH') ?: (defined('ZF2_PATH') ? ZF2_PATH : (is_dir($vendorPath . '/ZF2/library') ? $vendorPath . '/ZF2/library' : false)); | ||
|
||
if (!$zf2Path) { | ||
throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.'); | ||
} | ||
|
||
$zf2Path = getenv('ZF2_PATH') ?: (defined('ZF2_PATH') ? ZF2_PATH : (is_dir($vendorPath . '/ZF2/library') ? $vendorPath . '/ZF2/library' : false)); | ||
include $zf2Path . '/Zend/Loader/AutoloaderFactory.php'; | ||
|
||
if (!$zf2Path) { | ||
throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.'); | ||
} | ||
|
||
if (isset($loader)) { | ||
$loader->add('Zend', $zf2Path . '/Zend'); | ||
} else { | ||
include $zf2Path . '/Zend/Loader/AutoloaderFactory.php'; | ||
AutoloaderFactory::factory(array( | ||
'Zend\Loader\StandardAutoloader' => array( | ||
'autoregister_zf' => true, | ||
'namespaces' => array( | ||
__NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__, | ||
), | ||
AutoloaderFactory::factory(array( | ||
'Zend\Loader\StandardAutoloader' => array( | ||
'autoregister_zf' => true, | ||
'namespaces' => array( | ||
__NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__, | ||
), | ||
)); | ||
} | ||
), | ||
)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this whole autoloading thing should left to Composer. |
||
} | ||
|
||
protected static function findParentPath($path) | ||
|
@@ -98,4 +108,4 @@ protected static function findParentPath($path) | |
} | ||
} | ||
|
||
Bootstrap::init(); | ||
Bootstrap::init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
<?php | ||
define('ZF2_PATH', getenv('HOME') . '/workspace/zf2/library'); | ||
|
||
return array( | ||
'modules' => array( | ||
'ZfcBase', | ||
), | ||
'module_listener_options' => array( | ||
'module_paths' => array( | ||
'module', | ||
'vendor', | ||
), | ||
), | ||
); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Hounddog
What's this method needed for?