当前位置: 首页>>代码示例>>PHP>>正文


PHP PhabricatorEnv::overrideConfig方法代码示例

本文整理汇总了PHP中PhabricatorEnv::overrideConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorEnv::overrideConfig方法的具体用法?PHP PhabricatorEnv::overrideConfig怎么用?PHP PhabricatorEnv::overrideConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhabricatorEnv的用法示例。


在下文中一共展示了PhabricatorEnv::overrideConfig方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: catch

} catch (AphrontQueryException $ex) {
    $message = phutil_console_format("**%s**\n\n%s\n\n%s\n\n%s\n\n**%s**: %s\n", pht('MySQL Credentials Not Configured'), pht('Unable to connect to MySQL using the configured credentials. ' . 'You must configure standard credentials before you can upgrade ' . 'storage. Run these commands to set up credentials:'), "  phabricator/ \$ ./bin/config set mysql.host __host__\n" . "  phabricator/ \$ ./bin/config set mysql.user __username__\n" . "  phabricator/ \$ ./bin/config set mysql.pass __password__", pht('These standard credentials are separate from any administrative ' . 'credentials provided to this command with __%s__ or ' . '__%s__, and must be configured correctly before you can proceed.', '--user', '--password'), pht('Raw MySQL Error'), $ex->getMessage());
    echo phutil_console_wrap($message);
    exit(1);
}
if ($args->getArg('password') === null) {
    // This is already a PhutilOpaqueEnvelope.
    $password = $conf->getPassword();
} else {
    // Put this in a PhutilOpaqueEnvelope.
    $password = new PhutilOpaqueEnvelope($args->getArg('password'));
    PhabricatorEnv::overrideConfig('mysql.pass', $args->getArg('password'));
}
$api = new PhabricatorStorageManagementAPI();
$api->setUser($args->getArg('user'));
PhabricatorEnv::overrideConfig('mysql.user', $args->getArg('user'));
$api->setHost($default_host);
$api->setPort($default_port);
$api->setPassword($password);
$api->setNamespace($args->getArg('namespace'));
$api->setDisableUTF8MB4($args->getArg('disable-utf8mb4'));
try {
    queryfx($api->getConn(null), 'SELECT 1');
} catch (AphrontQueryException $ex) {
    $message = phutil_console_format("**%s**\n\n%s\n\n**%s**: %s\n", pht('Bad Administrative Credentials'), pht('Unable to connect to MySQL using the administrative credentials ' . 'provided with the __%s__ and __%s__ flags. Check that ' . 'you have entered them correctly.', '--user', '--password'), pht('Raw MySQL Error'), $ex->getMessage());
    echo phutil_console_wrap($message);
    exit(1);
}
$workflows = id(new PhutilSymbolLoader())->setAncestorClass('PhabricatorStorageManagementWorkflow')->loadObjects();
$patches = PhabricatorSQLPatchList::buildAllPatches();
foreach ($workflows as $workflow) {
开发者ID:JohnnyEstilles,项目名称:phabricator,代码行数:31,代码来源:manage_storage.php

示例2: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $user = $request->getUser();
     $application = $request->getURIData('application');
     $application = id(new PhabricatorApplicationQuery())->setViewer($user)->withClasses(array($application))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$application) {
         return new Aphront404Response();
     }
     $title = $application->getName();
     $view_uri = $this->getApplicationURI('view/' . get_class($application) . '/');
     $policies = id(new PhabricatorPolicyQuery())->setViewer($user)->setObject($application)->execute();
     if ($request->isFormPost()) {
         $result = array();
         foreach ($application->getCapabilities() as $capability) {
             $old = $application->getPolicy($capability);
             $new = $request->getStr('policy:' . $capability);
             if ($old == $new) {
                 // No change to the setting.
                 continue;
             }
             if (empty($policies[$new])) {
                 // Not a standard policy, check for a custom policy.
                 $policy = id(new PhabricatorPolicyQuery())->setViewer($user)->withPHIDs(array($new))->executeOne();
                 if (!$policy) {
                     // Not a custom policy either. Can't set the policy to something
                     // invalid, so skip this.
                     continue;
                 }
             }
             if ($new == PhabricatorPolicies::POLICY_PUBLIC) {
                 $capobj = PhabricatorPolicyCapability::getCapabilityByKey($capability);
                 if (!$capobj || !$capobj->shouldAllowPublicPolicySetting()) {
                     // Can't set non-public policies to public.
                     continue;
                 }
             }
             $result[$capability] = $new;
         }
         if ($result) {
             $key = 'phabricator.application-settings';
             $config_entry = PhabricatorConfigEntry::loadConfigEntry($key);
             $value = $config_entry->getValue();
             $phid = $application->getPHID();
             if (empty($value[$phid])) {
                 $value[$application->getPHID()] = array();
             }
             if (empty($value[$phid]['policy'])) {
                 $value[$phid]['policy'] = array();
             }
             $value[$phid]['policy'] = $result + $value[$phid]['policy'];
             // Don't allow users to make policy edits which would lock them out of
             // applications, since they would be unable to undo those actions.
             PhabricatorEnv::overrideConfig($key, $value);
             PhabricatorPolicyFilter::mustRetainCapability($user, $application, PhabricatorPolicyCapability::CAN_VIEW);
             PhabricatorPolicyFilter::mustRetainCapability($user, $application, PhabricatorPolicyCapability::CAN_EDIT);
             PhabricatorConfigEditor::storeNewValue($user, $config_entry, $value, PhabricatorContentSource::newFromRequest($request));
         }
         return id(new AphrontRedirectResponse())->setURI($view_uri);
     }
     $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($user, $application);
     $form = id(new AphrontFormView())->setUser($user);
     $locked_policies = PhabricatorEnv::getEnvConfig('policy.locked');
     foreach ($application->getCapabilities() as $capability) {
         $label = $application->getCapabilityLabel($capability);
         $can_edit = $application->isCapabilityEditable($capability);
         $locked = idx($locked_policies, $capability);
         $caption = $application->getCapabilityCaption($capability);
         if (!$can_edit || $locked) {
             $form->appendChild(id(new AphrontFormStaticControl())->setLabel($label)->setValue(idx($descriptions, $capability))->setCaption($caption));
         } else {
             $control = id(new AphrontFormPolicyControl())->setUser($user)->setDisabled($locked)->setCapability($capability)->setPolicyObject($application)->setPolicies($policies)->setLabel($label)->setName('policy:' . $capability)->setCaption($caption);
             $template = $application->getCapabilityTemplatePHIDType($capability);
             if ($template) {
                 $phid_types = PhabricatorPHIDType::getAllTypes();
                 $phid_type = idx($phid_types, $template);
                 if ($phid_type) {
                     $template_object = $phid_type->newObject();
                     if ($template_object) {
                         $template_policies = id(new PhabricatorPolicyQuery())->setViewer($user)->setObject($template_object)->execute();
                         // NOTE: We want to expose both any object template policies
                         // (like "Subscribers") and any custom policy.
                         $all_policies = $template_policies + $policies;
                         $control->setPolicies($all_policies);
                         $control->setTemplateObject($template_object);
                     }
                 }
                 $control->setTemplatePHIDType($template);
             }
             $form->appendControl($control);
         }
     }
     $form->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Save Policies'))->addCancelButton($view_uri));
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($application->getName(), $view_uri);
     $crumbs->addTextCrumb(pht('Edit Policies'));
     $header = id(new PHUIHeaderView())->setHeader(pht('Edit Policies: %s', $application->getName()));
     $object_box = id(new PHUIObjectBoxView())->setHeader($header)->setForm($form);
     return $this->buildApplicationPage(array($crumbs, $object_box), array('title' => $title));
 }
开发者ID:pugong,项目名称:phabricator,代码行数:99,代码来源:PhabricatorApplicationEditController.php

示例3: queryfx

    queryfx($test_api->getConn(null), 'SELECT 1');
} catch (AphrontQueryException $ex) {
    $message = phutil_console_format("**%s**\n\n%s\n\n%s\n\n%s\n\n**%s**: %s\n", pht('MySQL Credentials Not Configured'), pht('Unable to connect to MySQL using the configured credentials. ' . 'You must configure standard credentials before you can upgrade ' . 'storage. Run these commands to set up credentials:'), "  phabricator/ \$ ./bin/config set mysql.host __host__\n" . "  phabricator/ \$ ./bin/config set mysql.user __username__\n" . "  phabricator/ \$ ./bin/config set mysql.pass __password__", pht('These standard credentials are separate from any administrative ' . 'credentials provided to this command with __%s__ or ' . '__%s__, and must be configured correctly before you can proceed.', '--user', '--password'), pht('Raw MySQL Error'), $ex->getMessage());
    echo phutil_console_wrap($message);
    exit(1);
}
if ($args->getArg('password') === null) {
    // This is already a PhutilOpaqueEnvelope.
    $password = $conf->getPassword();
} else {
    // Put this in a PhutilOpaqueEnvelope.
    $password = new PhutilOpaqueEnvelope($args->getArg('password'));
    PhabricatorEnv::overrideConfig('mysql.pass', $args->getArg('password'));
}
$api = id(new PhabricatorStorageManagementAPI())->setUser($args->getArg('user'))->setHost($default_host)->setPort($default_port)->setPassword($password)->setNamespace($args->getArg('namespace'))->setDisableUTF8MB4($args->getArg('disable-utf8mb4'));
PhabricatorEnv::overrideConfig('mysql.user', $api->getUser());
try {
    queryfx($api->getConn(null), 'SELECT 1');
} catch (AphrontQueryException $ex) {
    $message = phutil_console_format("**%s**\n\n%s\n\n**%s**: %s\n", pht('Bad Administrative Credentials'), pht('Unable to connect to MySQL using the administrative credentials ' . 'provided with the __%s__ and __%s__ flags. Check that ' . 'you have entered them correctly.', '--user', '--password'), pht('Raw MySQL Error'), $ex->getMessage());
    echo phutil_console_wrap($message);
    exit(1);
}
$workflows = id(new PhutilClassMapQuery())->setAncestorClass('PhabricatorStorageManagementWorkflow')->execute();
$patches = PhabricatorSQLPatchList::buildAllPatches();
foreach ($workflows as $workflow) {
    $workflow->setAPI($api);
    $workflow->setPatches($patches);
}
$workflows[] = new PhutilHelpArgumentWorkflow();
$args->parseWorkflows($workflows);
开发者ID:pugong,项目名称:phabricator,代码行数:31,代码来源:manage_storage.php


注:本文中的PhabricatorEnv::overrideConfig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。