1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-10 23:01:04 +01:00

Check required classes in setup

Test Plan:
Run setup with 'differential.attach-task-class' set to:

- ''
- 'FacebookTasksAttacher'
- 'X'

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1999
This commit is contained in:
vrana 2012-03-22 15:44:34 -07:00
parent 1eca595e4d
commit 330d62984b
2 changed files with 35 additions and 16 deletions

View file

@ -22,21 +22,6 @@
final class PhabricatorEnv {
private static $env;
private static $requiredClasses = array(
'metamta.mail-adapter' => 'PhabricatorMailImplementationAdapter',
'metamta.maniphest.reply-handler' => 'PhabricatorMailReplyHandler',
'metamta.differential.reply-handler' => 'PhabricatorMailReplyHandler',
'metamta.diffusion.reply-handler' => 'PhabricatorMailReplyHandler',
'storage.engine-selector' => 'PhabricatorFileStorageEngineSelector',
'search.engine-selector' => 'PhabricatorSearchEngineSelector',
'differential.field-selector' => 'DifferentialFieldSelector',
'maniphest.custom-task-extensions-class' => 'ManiphestTaskExtensions',
'aphront.default-application-configuration-class' =>
'AphrontApplicationConfiguration',
'controller.oauth-registration' => 'PhabricatorOAuthRegistrationController',
'differential.attach-task-class' => 'DifferentialTasksAttacher',
);
public static function setEnvConfig(array $config) {
self::$env = $config;
}
@ -48,7 +33,7 @@ final class PhabricatorEnv {
public static function newObjectFromConfig($key, $args = array()) {
$class = self::getEnvConfig($key);
$object = newv($class, $args);
$instanceof = idx(self::$requiredClasses, $key);
$instanceof = idx(self::getRequiredClasses(), $key);
if (!($object instanceof $instanceof)) {
throw new Exception("Config setting '$key' must be an instance of ".
"'$instanceof', is '".get_class($object)."'.");
@ -56,6 +41,24 @@ final class PhabricatorEnv {
return $object;
}
public static function getRequiredClasses() {
return array(
'metamta.mail-adapter' => 'PhabricatorMailImplementationAdapter',
'metamta.maniphest.reply-handler' => 'PhabricatorMailReplyHandler',
'metamta.differential.reply-handler' => 'PhabricatorMailReplyHandler',
'metamta.diffusion.reply-handler' => 'PhabricatorMailReplyHandler',
'storage.engine-selector' => 'PhabricatorFileStorageEngineSelector',
'search.engine-selector' => 'PhabricatorSearchEngineSelector',
'differential.field-selector' => 'DifferentialFieldSelector',
'maniphest.custom-task-extensions-class' => 'ManiphestTaskExtensions',
'aphront.default-application-configuration-class' =>
'AphrontApplicationConfiguration',
'controller.oauth-registration' =>
'PhabricatorOAuthRegistrationController',
'differential.attach-task-class' => 'DifferentialTasksAttacher',
);
}
public static function envConfigExists($key) {
return array_key_exists($key, self::$env);
}

View file

@ -734,6 +734,22 @@ final class PhabricatorSetup {
self::write("[OKAY] Mail configuration OKAY\n");
}
self::writeHeader('CONFIG CLASSES');
foreach (PhabricatorEnv::getRequiredClasses() as $key => $class) {
if (!PhabricatorEnv::getEnvConfig($key)) {
self::writeNote("'$key' is not set.");
} else {
try {
PhabricatorEnv::newObjectFromConfig($key);
} catch (Exception $ex) {
self::writeFailure();
self::write("Setup failure! ".$ex->getMessage());
return;
}
}
}
self::write("[OKAY] Config classes OKAY\n");
self::writeHeader('SUCCESS!');
self::write(
"Congratulations! Your setup seems mostly correct, or at least fairly ".