Skip to content

Commit

Permalink
how to make it faster to loading modules?
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunlee committed Sep 12, 2013
1 parent 33f8e07 commit 6c4c941
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions ajoy/ajoy.php
Expand Up @@ -1345,26 +1345,19 @@ public function loadModels($className)
*/
public function loadModules()
{
static $loadedModules = array();

foreach ($this->get('modules') as $module) {
if (isset($loadedModules[$module]))
continue;

$paths = explode('.', $module);
$modfile = '/modules/' . implode('/', $paths) . '.php';
array_map(function($module) {
$modfile = '/modules/' . $module . '.php';

$filename = $this->get('app root') . $modfile;
if (!file_exists($filename))
if (!file_exists($filename)) {
$filename = $this->get('ajoy root') . $modfile;

if (!file_exists($filename))
$this->raise('Module with name "' . $module . '" does not exists.');
if (!file_exists($filename))
$this->raise('Module with name "' . $module . '" does not exists.');
}

include $filename;

$loadedModules[$module] = true;
}
}, $this->get('modules'));
}

/**
Expand Down

0 comments on commit 6c4c941

Please sign in to comment.