mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-01 19:22:42 +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'], '/') : '');
|
$path = '/'.(isset($url['path']) ? ltrim($url['path'], '/') : '');
|
||||||
|
|
||||||
$config_key = 'aphront.default-application-configuration-class';
|
$config_key = 'aphront.default-application-configuration-class';
|
||||||
$config_class = PhabricatorEnv::getEnvConfig($config_key);
|
$application = PhabricatorEnv::newObjectFromConfig($config_key);
|
||||||
$application = newv($config_class, array());
|
|
||||||
$mapper = new AphrontURIMapper($application->getURIMap());
|
$mapper = new AphrontURIMapper($application->getURIMap());
|
||||||
|
|
||||||
list($controller) = $mapper->mapPath($path);
|
list($controller) = $mapper->mapPath($path);
|
||||||
|
|
|
@ -267,9 +267,8 @@ final class PhabricatorAuditCommentEditor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function newReplyHandlerForCommit($commit) {
|
public static function newReplyHandlerForCommit($commit) {
|
||||||
$handler_class = PhabricatorEnv::getEnvConfig(
|
$reply_handler = PhabricatorEnv::newObjectFromConfig(
|
||||||
'metamta.diffusion.reply-handler');
|
'metamta.diffusion.reply-handler');
|
||||||
$reply_handler = newv($handler_class, array());
|
|
||||||
$reply_handler->setMailReceiver($commit);
|
$reply_handler->setMailReceiver($commit);
|
||||||
return $reply_handler;
|
return $reply_handler;
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,9 +206,8 @@ final class PhabricatorOAuthLoginController
|
||||||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
$class = PhabricatorEnv::getEnvConfig('controller.oauth-registration');
|
$key = 'controller.oauth-registration';
|
||||||
PhutilSymbolLoader::loadClass($class);
|
$controller = PhabricatorEnv::newObjectFromConfig($key);
|
||||||
$controller = newv($class, array($this->getRequest()));
|
|
||||||
|
|
||||||
$controller->setOAuthProvider($provider);
|
$controller->setOAuthProvider($provider);
|
||||||
$controller->setOAuthInfo($oauth_info);
|
$controller->setOAuthInfo($oauth_info);
|
||||||
|
|
|
@ -20,7 +20,6 @@ phutil_require_module('phabricator', 'view/dialog');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'markup');
|
phutil_require_module('phutil', 'markup');
|
||||||
phutil_require_module('phutil', 'parser/uri');
|
phutil_require_module('phutil', 'parser/uri');
|
||||||
phutil_require_module('phutil', 'symbols');
|
|
||||||
phutil_require_module('phutil', 'utils');
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,7 @@ abstract class DifferentialFieldSelector {
|
||||||
}
|
}
|
||||||
|
|
||||||
final public static function newSelector() {
|
final public static function newSelector() {
|
||||||
$class = PhabricatorEnv::getEnvConfig('differential.field-selector');
|
return PhabricatorEnv::newObjectFromConfig('differential.field-selector');
|
||||||
$selector = newv($class, array());
|
|
||||||
return $selector;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public function getFieldSpecifications();
|
abstract public function getFieldSpecifications();
|
||||||
|
|
|
@ -8,7 +8,5 @@
|
||||||
|
|
||||||
phutil_require_module('phabricator', 'infrastructure/env');
|
phutil_require_module('phabricator', 'infrastructure/env');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'utils');
|
|
||||||
|
|
||||||
|
|
||||||
phutil_require_source('DifferentialFieldSelector.php');
|
phutil_require_source('DifferentialFieldSelector.php');
|
||||||
|
|
|
@ -84,8 +84,7 @@ final class PhabricatorFile extends PhabricatorFileDAO {
|
||||||
|
|
||||||
public static function newFromFileData($data, array $params = array()) {
|
public static function newFromFileData($data, array $params = array()) {
|
||||||
|
|
||||||
$selector_class = PhabricatorEnv::getEnvConfig('storage.engine-selector');
|
$selector = PhabricatorEnv::newObjectFromConfig('storage.engine-selector');
|
||||||
$selector = newv($selector_class, array());
|
|
||||||
|
|
||||||
$engines = $selector->selectStorageEngines($data, $params);
|
$engines = $selector->selectStorageEngines($data, $params);
|
||||||
if (!$engines) {
|
if (!$engines) {
|
||||||
|
|
|
@ -284,10 +284,8 @@ final class ManiphestTransactionEditor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildReplyHandler(ManiphestTask $task) {
|
public function buildReplyHandler(ManiphestTask $task) {
|
||||||
$handler_class = PhabricatorEnv::getEnvConfig(
|
$handler_object = PhabricatorEnv::newObjectFromConfig(
|
||||||
'metamta.maniphest.reply-handler');
|
'metamta.maniphest.reply-handler');
|
||||||
|
|
||||||
$handler_object = newv($handler_class, array());
|
|
||||||
$handler_object->setMailReceiver($task);
|
$handler_object->setMailReceiver($task);
|
||||||
|
|
||||||
return $handler_object;
|
return $handler_object;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2011 Facebook, Inc.
|
* Copyright 2012 Facebook, Inc.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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() {
|
final public static function newExtensions() {
|
||||||
$key = 'maniphest.custom-task-extensions-class';
|
$key = 'maniphest.custom-task-extensions-class';
|
||||||
$class = PhabricatorEnv::getEnvConfig($key);
|
return PhabricatorEnv::newObjectFromConfig($key);
|
||||||
return newv($class, array());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,5 @@
|
||||||
|
|
||||||
phutil_require_module('phabricator', 'infrastructure/env');
|
phutil_require_module('phabricator', 'infrastructure/env');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'utils');
|
|
||||||
|
|
||||||
|
|
||||||
phutil_require_source('ManiphestTaskExtensions.php');
|
phutil_require_source('ManiphestTaskExtensions.php');
|
||||||
|
|
|
@ -247,9 +247,7 @@ final class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO {
|
||||||
|
|
||||||
|
|
||||||
public function buildDefaultMailer() {
|
public function buildDefaultMailer() {
|
||||||
$class_name = PhabricatorEnv::getEnvConfig('metamta.mail-adapter');
|
return PhabricatorEnv::newObjectFromConfig('metamta.mail-adapter');
|
||||||
PhutilSymbolLoader::loadClass($class_name);
|
|
||||||
return newv($class_name, array());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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/daemon/workers/storage/task');
|
||||||
phutil_require_module('phabricator', 'infrastructure/env');
|
phutil_require_module('phabricator', 'infrastructure/env');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'symbols');
|
|
||||||
phutil_require_module('phutil', 'utils');
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2011 Facebook, Inc.
|
* Copyright 2012 Facebook, Inc.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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();
|
abstract public function newEngine();
|
||||||
|
|
||||||
final public static function newSelector() {
|
final public static function newSelector() {
|
||||||
$class = PhabricatorEnv::getEnvConfig('search.engine-selector');
|
return PhabricatorEnv::newObjectFromConfig('search.engine-selector');
|
||||||
return newv($class, array());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,5 @@
|
||||||
|
|
||||||
phutil_require_module('phabricator', 'infrastructure/env');
|
phutil_require_module('phabricator', 'infrastructure/env');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'utils');
|
|
||||||
|
|
||||||
|
|
||||||
phutil_require_source('PhabricatorSearchEngineSelector.php');
|
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 $env;
|
||||||
|
|
||||||
private static $requiredClasses = array(
|
private static $requiredClasses = array(
|
||||||
|
'metamta.mail-adapter' => 'PhabricatorMailImplementationAdapter',
|
||||||
|
'metamta.maniphest.reply-handler' => 'PhabricatorMailReplyHandler',
|
||||||
'metamta.differential.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) {
|
public static function setEnvConfig(array $config) {
|
||||||
|
|
|
@ -106,9 +106,7 @@ $path = $_REQUEST['__path__'];
|
||||||
switch ($host) {
|
switch ($host) {
|
||||||
default:
|
default:
|
||||||
$config_key = 'aphront.default-application-configuration-class';
|
$config_key = 'aphront.default-application-configuration-class';
|
||||||
$config_class = PhabricatorEnv::getEnvConfig($config_key);
|
$application = PhabricatorEnv::newObjectFromConfig($config_key);
|
||||||
PhutilSymbolLoader::loadClass($config_class);
|
|
||||||
$application = newv($config_class, array());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue