mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 10:12:41 +01:00
Use PhabricatorEnv::newObjectFromConfig() wherever possible
Test Plan: /mail/send/ scripts/aphront/aphrontpath.php / Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1983
This commit is contained in:
parent
74cc558ed8
commit
4fba549a99
16 changed files with 23 additions and 35 deletions
|
@ -30,8 +30,7 @@ $url = parse_url($argv[1]);
|
|||
$path = '/'.(isset($url['path']) ? ltrim($url['path'], '/') : '');
|
||||
|
||||
$config_key = 'aphront.default-application-configuration-class';
|
||||
$config_class = PhabricatorEnv::getEnvConfig($config_key);
|
||||
$application = newv($config_class, array());
|
||||
$application = PhabricatorEnv::newObjectFromConfig($config_key);
|
||||
$mapper = new AphrontURIMapper($application->getURIMap());
|
||||
|
||||
list($controller) = $mapper->mapPath($path);
|
||||
|
|
|
@ -267,9 +267,8 @@ final class PhabricatorAuditCommentEditor {
|
|||
}
|
||||
|
||||
public static function newReplyHandlerForCommit($commit) {
|
||||
$handler_class = PhabricatorEnv::getEnvConfig(
|
||||
$reply_handler = PhabricatorEnv::newObjectFromConfig(
|
||||
'metamta.diffusion.reply-handler');
|
||||
$reply_handler = newv($handler_class, array());
|
||||
$reply_handler->setMailReceiver($commit);
|
||||
return $reply_handler;
|
||||
}
|
||||
|
|
|
@ -206,9 +206,8 @@ final class PhabricatorOAuthLoginController
|
|||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||
}
|
||||
|
||||
$class = PhabricatorEnv::getEnvConfig('controller.oauth-registration');
|
||||
PhutilSymbolLoader::loadClass($class);
|
||||
$controller = newv($class, array($this->getRequest()));
|
||||
$key = 'controller.oauth-registration';
|
||||
$controller = PhabricatorEnv::newObjectFromConfig($key);
|
||||
|
||||
$controller->setOAuthProvider($provider);
|
||||
$controller->setOAuthInfo($oauth_info);
|
||||
|
|
|
@ -20,7 +20,6 @@ phutil_require_module('phabricator', 'view/dialog');
|
|||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
phutil_require_module('phutil', 'parser/uri');
|
||||
phutil_require_module('phutil', 'symbols');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
|
|
|
@ -23,9 +23,7 @@ abstract class DifferentialFieldSelector {
|
|||
}
|
||||
|
||||
final public static function newSelector() {
|
||||
$class = PhabricatorEnv::getEnvConfig('differential.field-selector');
|
||||
$selector = newv($class, array());
|
||||
return $selector;
|
||||
return PhabricatorEnv::newObjectFromConfig('differential.field-selector');
|
||||
}
|
||||
|
||||
abstract public function getFieldSpecifications();
|
||||
|
|
|
@ -8,7 +8,5 @@
|
|||
|
||||
phutil_require_module('phabricator', 'infrastructure/env');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('DifferentialFieldSelector.php');
|
||||
|
|
|
@ -84,8 +84,7 @@ final class PhabricatorFile extends PhabricatorFileDAO {
|
|||
|
||||
public static function newFromFileData($data, array $params = array()) {
|
||||
|
||||
$selector_class = PhabricatorEnv::getEnvConfig('storage.engine-selector');
|
||||
$selector = newv($selector_class, array());
|
||||
$selector = PhabricatorEnv::newObjectFromConfig('storage.engine-selector');
|
||||
|
||||
$engines = $selector->selectStorageEngines($data, $params);
|
||||
if (!$engines) {
|
||||
|
|
|
@ -284,10 +284,8 @@ final class ManiphestTransactionEditor {
|
|||
}
|
||||
|
||||
public function buildReplyHandler(ManiphestTask $task) {
|
||||
$handler_class = PhabricatorEnv::getEnvConfig(
|
||||
$handler_object = PhabricatorEnv::newObjectFromConfig(
|
||||
'metamta.maniphest.reply-handler');
|
||||
|
||||
$handler_object = newv($handler_class, array());
|
||||
$handler_object->setMailReceiver($task);
|
||||
|
||||
return $handler_object;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -30,8 +30,7 @@ abstract class ManiphestTaskExtensions {
|
|||
|
||||
final public static function newExtensions() {
|
||||
$key = 'maniphest.custom-task-extensions-class';
|
||||
$class = PhabricatorEnv::getEnvConfig($key);
|
||||
return newv($class, array());
|
||||
return PhabricatorEnv::newObjectFromConfig($key);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,5 @@
|
|||
|
||||
phutil_require_module('phabricator', 'infrastructure/env');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('ManiphestTaskExtensions.php');
|
||||
|
|
|
@ -247,9 +247,7 @@ final class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO {
|
|||
|
||||
|
||||
public function buildDefaultMailer() {
|
||||
$class_name = PhabricatorEnv::getEnvConfig('metamta.mail-adapter');
|
||||
PhutilSymbolLoader::loadClass($class_name);
|
||||
return newv($class_name, array());
|
||||
return PhabricatorEnv::newObjectFromConfig('metamta.mail-adapter');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,6 @@ phutil_require_module('phabricator', 'applications/phid/handle/data');
|
|||
phutil_require_module('phabricator', 'infrastructure/daemon/workers/storage/task');
|
||||
phutil_require_module('phabricator', 'infrastructure/env');
|
||||
|
||||
phutil_require_module('phutil', 'symbols');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -28,8 +28,7 @@ abstract class PhabricatorSearchEngineSelector {
|
|||
abstract public function newEngine();
|
||||
|
||||
final public static function newSelector() {
|
||||
$class = PhabricatorEnv::getEnvConfig('search.engine-selector');
|
||||
return newv($class, array());
|
||||
return PhabricatorEnv::newObjectFromConfig('search.engine-selector');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,5 @@
|
|||
|
||||
phutil_require_module('phabricator', 'infrastructure/env');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorSearchEngineSelector.php');
|
||||
|
|
10
src/infrastructure/env/PhabricatorEnv.php
vendored
10
src/infrastructure/env/PhabricatorEnv.php
vendored
|
@ -23,7 +23,17 @@ 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',
|
||||
);
|
||||
|
||||
public static function setEnvConfig(array $config) {
|
||||
|
|
|
@ -106,9 +106,7 @@ $path = $_REQUEST['__path__'];
|
|||
switch ($host) {
|
||||
default:
|
||||
$config_key = 'aphront.default-application-configuration-class';
|
||||
$config_class = PhabricatorEnv::getEnvConfig($config_key);
|
||||
PhutilSymbolLoader::loadClass($config_class);
|
||||
$application = newv($config_class, array());
|
||||
$application = PhabricatorEnv::newObjectFromConfig($config_key);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue