本文整理汇总了PHP中PhabricatorEnv::getEnvConfigIfExists方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorEnv::getEnvConfigIfExists方法的具体用法?PHP PhabricatorEnv::getEnvConfigIfExists怎么用?PHP PhabricatorEnv::getEnvConfigIfExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhabricatorEnv
的用法示例。
在下文中一共展示了PhabricatorEnv::getEnvConfigIfExists方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendChangesRetry
/**
* Try to post a message to Changes. Returns a status message that should
* be posted to the user.
*/
private function sendChangesRetry($diffId)
{
$changes_uri = PhabricatorEnv::getEnvConfigIfExists('changes.uri');
if (!$changes_uri) {
return 'changes.uri not set';
}
$uri = sprintf('%s/api/0/phabricator_diffs/%s/retry/', rtrim($changes_uri, '/'), $diffId);
$future = id(new HTTPSFuture($uri))->setMethod('POST');
list($status, $body, $headers) = $future->resolve();
$statusCode = $status->getStatusCode();
switch ($statusCode) {
case 200:
$builds = json_decode($body, true);
if ($builds === null) {
return "Error while retrying builds. Received an invalid response from Changes.";
} else {
$count = count($builds);
if ($count == 0) {
return 'No builds restarted.';
} else {
$names = array();
foreach ($builds as $build) {
$names[] = $build['project']['name'];
}
$namesText = implode(', ', $names);
return "Builds restarted: {$namesText}";
}
}
case 400:
$dict = json_decode($body, true);
if (!$dict || !array_key_exists('error', $dict)) {
return "Error while retrying builds. Received in invalid error message from Changes.";
} else {
return $dict['error'];
}
case 500:
return "Error on Changes while retrying builds: Internal Server Error";
case 7:
// CURLE_COULDNT_CONNECT
// CURLE_COULDNT_CONNECT
case 52:
// CURLE_GOT_NOTHING
return 'Unable to connect to Changes to restart the builds.';
default:
return "An unknown error occurred while retrying builds. Error code: {$statusCode}.";
}
assert(false);
}
示例2: register
public function register()
{
$sentry_dsn = PhabricatorEnv::getEnvConfigIfExists('sentry.dsn');
if (empty($sentry_dsn)) {
return;
}
Raven_Autoloader::register();
// Configure the client
$client = new Raven_Client($sentry_dsn);
// Install error handlers
$error_handler = new Raven_ErrorHandler($client);
$error_handler->registerExceptionHandler();
$error_handler->registerErrorHandler();
// We can't override DarkConsole, so let's capture them at the
// end of the request
SentryLogger::setClient($client);
register_shutdown_function(array('SentryLogger', 'logAllPendingErrors'));
}
示例3: executeBuild
public function executeBuild($object, $build_target = null)
{
$changes_uri = PhabricatorEnv::getEnvConfigIfExists('changes.uri');
if (!$changes_uri) {
return array(false, 'Missing changes.uri setting');
}
$uri = sprintf('%s/api/0/phabricator/notify-diff/', rtrim($changes_uri, '/'));
if ($object instanceof DifferentialDiff) {
list($success, $data) = $this->getParamsForDiff($object, $build_target);
if (!$success) {
return array(false, $data);
}
// } else if ($object instanceof PhabricatorRepositoryCommit) {
// list($success, $data) = $this->getParamsForCommit($object);
} else {
return array(false, 'Object of type is not buildable');
}
try {
if (!empty($data['patch'])) {
$patch_file = tempnam('', 'changes-patch');
$fp = fopen($patch_file, 'wb');
fwrite($fp, $data['patch']);
fclose($fp);
$data['patch'] = '@' . $patch_file;
}
list($success, $result) = $this->sendBuildToChanges($uri, $data);
} catch (Exception $ex) {
if ($data['patch']) {
unlink($patch_file);
}
throw $ex;
}
if ($data['patch']) {
unlink($patch_file);
}
return array($success, $result);
}
示例4: array
<?php
echo "Migrating Maniphest custom field configuration...\n";
$old_key = 'maniphest.custom-fields';
$new_key = 'maniphest.custom-field-definitions';
if (PhabricatorEnv::getEnvConfig($new_key)) {
echo "Skipping migration, new data is already set.\n";
return;
}
$old = PhabricatorEnv::getEnvConfigIfExists($old_key);
if (!$old) {
echo "Skipping migration, old data does not exist.\n";
return;
}
$new = array();
foreach ($old as $field_key => $spec) {
$new_spec = array();
foreach ($spec as $key => $value) {
switch ($key) {
case 'label':
$new_spec['name'] = $value;
break;
case 'required':
case 'default':
case 'caption':
case 'options':
$new_spec[$key] = $value;
break;
case 'checkbox-label':
$new_spec['strings']['edit.checkbox'] = $value;
break;
示例5: idx
} else {
$registration = (int) PhabricatorEnv::getEnvConfigIfExists($registration_key, true);
}
}
$unlink_key = idx($spec, 'permanent');
if (!$unlink_key) {
$unlink = 1;
} else {
$unlink = (int) (!PhabricatorEnv::getEnvConfigIfExists($unlink_key));
}
$config = id(new PhabricatorAuthProviderConfig())->setIsEnabled(1)->setShouldAllowLogin(1)->setShouldAllowRegistration($registration)->setShouldAllowLink(1)->setShouldAllowUnlink($unlink)->setProviderType(idx($spec, 'type'))->setProviderDomain(idx($spec, 'domain'))->setProviderClass($provider_class);
if (isset($spec['oauth.id'])) {
$config->setProperty(PhabricatorAuthProviderOAuth::PROPERTY_APP_ID, PhabricatorEnv::getEnvConfigIfExists(idx($spec, 'oauth.id')));
$config->setProperty(PhabricatorAuthProviderOAuth::PROPERTY_APP_SECRET, PhabricatorEnv::getEnvConfigIfExists(idx($spec, 'oauth.secret')));
}
switch ($provider_class) {
case 'PhabricatorFacebookAuthProvider':
$config->setProperty(PhabricatorFacebookAuthProvider::KEY_REQUIRE_SECURE, (int) PhabricatorEnv::getEnvConfigIfExists('facebook.require-https-auth'));
break;
case 'PhabricatorLDAPAuthProvider':
$ldap_map = array(PhabricatorLDAPAuthProvider::KEY_HOSTNAME => 'ldap.hostname', PhabricatorLDAPAuthProvider::KEY_PORT => 'ldap.port', PhabricatorLDAPAuthProvider::KEY_DISTINGUISHED_NAME => 'ldap.base_dn', PhabricatorLDAPAuthProvider::KEY_SEARCH_ATTRIBUTES => 'ldap.search_attribute', PhabricatorLDAPAuthProvider::KEY_USERNAME_ATTRIBUTE => 'ldap.username-attribute', PhabricatorLDAPAuthProvider::KEY_REALNAME_ATTRIBUTES => 'ldap.real_name_attributes', PhabricatorLDAPAuthProvider::KEY_VERSION => 'ldap.version', PhabricatorLDAPAuthProvider::KEY_REFERRALS => 'ldap.referrals', PhabricatorLDAPAuthProvider::KEY_START_TLS => 'ldap.start-tls', PhabricatorLDAPAuthProvider::KEY_ANONYMOUS_USERNAME => 'ldap.anonymous-user-name', PhabricatorLDAPAuthProvider::KEY_ANONYMOUS_PASSWORD => 'ldap.anonymous-user-password', PhabricatorLDAPAuthProvider::KEY_ALWAYS_SEARCH => 'ldap.search-first', PhabricatorLDAPAuthProvider::KEY_ACTIVEDIRECTORY_DOMAIN => 'ldap.activedirectory_domain');
$defaults = array('ldap.version' => 3, 'ldap.port' => 389);
foreach ($ldap_map as $pkey => $ckey) {
$default = idx($defaults, $ckey);
$config->setProperty($pkey, PhabricatorEnv::getEnvConfigIfExists($ckey, $default));
}
break;
}
$config->save();
}
echo "Done.\n";
示例6: pht
<?php
$key = 'metamta.maniphest.default-public-author';
echo pht("Migrating `%s` to new application email infrastructure...\n", $key);
$value = PhabricatorEnv::getEnvConfigIfExists($key);
$maniphest = new PhabricatorManiphestApplication();
$config_key = PhabricatorMetaMTAApplicationEmail::CONFIG_DEFAULT_AUTHOR;
if ($value) {
$app_emails = id(new PhabricatorMetaMTAApplicationEmailQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withApplicationPHIDs(array($maniphest->getPHID()))->execute();
foreach ($app_emails as $app_email) {
$app_email->setConfigValue($config_key, $value);
$app_email->save();
}
}
echo pht('Done.') . "\n";
示例7: pht
<?php
$key_files = 'metamta.files.public-create-email';
$key_paste = 'metamta.paste.public-create-email';
echo pht("Migrating `%s` and `%s` to new application email infrastructure...\n", $key_files, $key_paste);
$value_files = PhabricatorEnv::getEnvConfigIfExists($key_files);
$files_app = new PhabricatorFilesApplication();
if ($value_files) {
try {
PhabricatorMetaMTAApplicationEmail::initializeNewAppEmail(PhabricatorUser::getOmnipotentUser())->setAddress($value_files)->setApplicationPHID($files_app->getPHID())->save();
} catch (AphrontDuplicateKeyQueryException $ex) {
// Already migrated?
}
}
$value_paste = PhabricatorEnv::getEnvConfigIfExists($key_paste);
$paste_app = new PhabricatorPasteApplication();
if ($value_paste) {
try {
PhabricatorMetaMTAApplicationEmail::initializeNewAppEmail(PhabricatorUser::getOmnipotentUser())->setAddress($value_paste)->setApplicationPHID($paste_app->getPHID())->save();
} catch (AphrontDuplicateKeyQueryException $ex) {
// Already migrated?
}
}
echo pht('Done.') . "\n";