Merge in Phergie changes

This commit is contained in:
Luke Fitzgerald
2010-08-12 11:58:53 -07:00
parent d2c72d8ae1
commit a3fea6f673
16 changed files with 1513 additions and 590 deletions

View File

@@ -54,10 +54,27 @@ class Phergie_Plugin_Reload extends Phergie_Plugin_Abstract
{
$plugin = ucfirst($plugin);
$evalClass = true;
if (strpos($plugin, ' ') !== false) {
$args = explode(' ', $plugin);
$plugin = $args[0];
if (strtolower($args[1]) == 'force') {
$evalClass = false;
}
}
if (!$this->plugins->hasPlugin($plugin)) {
echo 'DEBUG(Reload): ' . ucfirst($plugin) . ' is not loaded yet, loading', PHP_EOL;
$this->plugins->getPlugin($plugin);
$this->plugins->command->populateMethodCache();
try {
$this->plugins->getPlugin($plugin);
$this->plugins->command->populateMethodCache();
} catch (Phergie_Plugin_Exception $e) {
if ($e->getCode() == Phergie_Plugin_Exception::ERR_CLASS_NOT_FOUND) {
echo 'DEBUG(Reload): ', $e->getMessage(), PHP_EOL;
} else {
throw $e;
}
}
return;
}
@@ -75,17 +92,19 @@ class Phergie_Plugin_Reload extends Phergie_Plugin_Abstract
$newClass = $class . '_' . sha1($contents);
if (class_exists($newClass, false)) {
echo 'DEBUG(Reload): Class ', $class, ' has not changed since last reload', PHP_EOL;
return;
if ($evalClass == true) {
echo 'DEBUG(Reload): Class ', $class, ' has not changed since last reload', PHP_EOL;
return;
}
} else {
$contents = preg_replace(
array('/^<\?(?:php)?/', '/class\s+' . $class . '/i'),
array('', 'class ' . $newClass),
$contents
);
eval($contents);
}
$contents = preg_replace(
array('/^<\?(?:php)?/', '/class\s+' . $class . '/i'),
array('', 'class ' . $newClass),
$contents
);
eval($contents);
$instance = new $newClass;
$instance->setName($plugin);
$instance->setEvent($this->event);