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


PHP PhabricatorUser::getOmnipotentUser方法代码示例

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


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

示例1: loadForRevision

 public static function loadForRevision($revision)
 {
     $app_legalpad = 'PhabricatorLegalpadApplication';
     if (!PhabricatorApplication::isClassInstalled($app_legalpad)) {
         return array();
     }
     if (!$revision->getPHID()) {
         return array();
     }
     $phids = PhabricatorEdgeQuery::loadDestinationPHIDs($revision->getPHID(), LegalpadObjectNeedsSignatureEdgeType::EDGECONST);
     if ($phids) {
         // NOTE: We're bypassing permissions to pull these. We have to expose
         // some information about signature status in order to implement this
         // field meaningfully (otherwise, we could not tell reviewers that they
         // can't accept the revision yet), but that's OK because the only way to
         // require signatures is with a "Global" Herald rule, which requires a
         // high level of access.
         $signatures = id(new LegalpadDocumentSignatureQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withDocumentPHIDs($phids)->withSignerPHIDs(array($revision->getAuthorPHID()))->execute();
         $signatures = mpull($signatures, null, 'getDocumentPHID');
         $phids = array_fuse($phids);
         foreach ($phids as $phid) {
             $phids[$phid] = isset($signatures[$phid]);
         }
     }
     return $phids;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:26,代码来源:DifferentialRequiredSignaturesField.php

示例2: testDetectSlowCopiedCode

    public function testDetectSlowCopiedCode()
    {
        // This tests that the detector has a reasonable runtime when a diff
        // contains a very large number of identical lines. See T5041.
        $parser = new ArcanistDiffParser();
        $line = str_repeat('x', 60);
        $oline = '-' . $line . "\n";
        $nline = '+' . $line . "\n";
        $n = 1000;
        $oblock = str_repeat($oline, $n);
        $nblock = str_repeat($nline, $n);
        $raw_diff = <<<EODIFF
diff --git a/dst b/dst
new file mode 100644
index 0000000..1234567
--- /dev/null
+++ b/dst
@@ -0,0 +1,{$n} @@
{$nblock}
diff --git a/src b/src
deleted file mode 100644
index 123457..0000000
--- a/src
+++ /dev/null
@@ -1,{$n} +0,0 @@
{$oblock}
EODIFF;
        $diff = DifferentialDiff::newFromRawChanges(PhabricatorUser::getOmnipotentUser(), $parser->parseDiff($raw_diff));
        $this->assertTrue(true);
    }
开发者ID:pugong,项目名称:phabricator,代码行数:30,代码来源:DifferentialDiffTestCase.php

示例3: doWork

 protected function doWork()
 {
     $viewer = PhabricatorUser::getOmnipotentUser();
     $task_data = $this->getTaskData();
     $email_phids = idx($task_data, 'emailPHIDs');
     if (!$email_phids) {
         // If we don't have any email targets, don't send any email.
         return;
     }
     $event_phid = idx($task_data, 'eventPHID');
     $event = id(new PhabricatorRepositoryPushEventQuery())->setViewer($viewer)->withPHIDs(array($event_phid))->needLogs(true)->executeOne();
     $repository = $event->getRepository();
     if (!$repository->shouldPublish()) {
         // If the repository is still importing, don't send email.
         return;
     }
     $targets = id(new PhabricatorRepositoryPushReplyHandler())->setMailReceiver($repository)->getMailTargets($email_phids, array());
     $messages = array();
     foreach ($targets as $target) {
         $messages[] = $this->sendMail($target, $repository, $event);
     }
     foreach ($messages as $message) {
         $message->save();
     }
 }
开发者ID:pugong,项目名称:phabricator,代码行数:25,代码来源:PhabricatorRepositoryPushMailWorker.php

示例4: getBlockers

 private function getBlockers(PhabricatorRepositoryCommit $commit, HarbormasterBuildPlan $plan, HarbormasterBuild $source)
 {
     $call = new ConduitCall('diffusion.commitparentsquery', array('commit' => $commit->getCommitIdentifier(), 'repository' => $commit->getRepository()->getPHID()));
     $call->setUser(PhabricatorUser::getOmnipotentUser());
     $parents = $call->execute();
     $parents = id(new DiffusionCommitQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withRepository($commit->getRepository())->withIdentifiers($parents)->execute();
     $blockers = array();
     $build_objects = array();
     foreach ($parents as $parent) {
         if (!$parent->isImported()) {
             $blockers[] = pht('Commit %s', $parent->getCommitIdentifier());
         } else {
             $build_objects[] = $parent->getPHID();
         }
     }
     if ($build_objects) {
         $buildables = id(new HarbormasterBuildableQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withBuildablePHIDs($build_objects)->withManualBuildables(false)->execute();
         $buildable_phids = mpull($buildables, 'getPHID');
         if ($buildable_phids) {
             $builds = id(new HarbormasterBuildQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withBuildablePHIDs($buildable_phids)->withBuildPlanPHIDs(array($plan->getPHID()))->execute();
             foreach ($builds as $build) {
                 if (!$build->isComplete()) {
                     $blockers[] = pht('Build %d', $build->getID());
                 }
             }
         }
     }
     return $blockers;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:29,代码来源:HarbormasterWaitForPreviousBuildStepImplementation.php

示例5: updateBranchStates

 private function updateBranchStates(PhabricatorRepository $repository, array $branches)
 {
     assert_instances_of($branches, 'DiffusionRepositoryRef');
     $all_cursors = id(new PhabricatorRepositoryRefCursorQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withRepositoryPHIDs(array($repository->getPHID()))->execute();
     $state_map = array();
     $type_branch = PhabricatorRepositoryRefCursor::TYPE_BRANCH;
     foreach ($all_cursors as $cursor) {
         if ($cursor->getRefType() !== $type_branch) {
             continue;
         }
         $raw_name = $cursor->getRefNameRaw();
         $hash = $cursor->getCommitIdentifier();
         $state_map[$raw_name][$hash] = $cursor;
     }
     foreach ($branches as $branch) {
         $cursor = idx($state_map, $branch->getShortName(), array());
         $cursor = idx($cursor, $branch->getCommitIdentifier());
         if (!$cursor) {
             continue;
         }
         $fields = $branch->getRawFields();
         $cursor_state = (bool) $cursor->getIsClosed();
         $branch_state = (bool) idx($fields, 'closed');
         if ($cursor_state != $branch_state) {
             $cursor->setIsClosed((int) $branch_state)->save();
         }
     }
 }
开发者ID:vinzent,项目名称:phabricator,代码行数:28,代码来源:PhabricatorRepositoryRefEngine.php

示例6: render

 public function render()
 {
     $viewer = $this->getUser();
     $blueprint_phids = $this->getBlueprintPHIDs();
     $object_phid = $this->getObjectPHID();
     // NOTE: We're intentionally letting you see the authorization state on
     // blueprints you can't see because this has a tremendous potential to
     // be extremely confusing otherwise. You still can't see the blueprints
     // themselves, but you can know if the object is authorized on something.
     if ($blueprint_phids) {
         $handles = $viewer->loadHandles($blueprint_phids);
         $authorizations = id(new DrydockAuthorizationQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withObjectPHIDs(array($object_phid))->withBlueprintPHIDs($blueprint_phids)->execute();
         $authorizations = mpull($authorizations, null, 'getBlueprintPHID');
     } else {
         $handles = array();
         $authorizations = array();
     }
     $items = array();
     foreach ($blueprint_phids as $phid) {
         $authorization = idx($authorizations, $phid);
         if (!$authorization) {
             continue;
         }
         $handle = $handles[$phid];
         $item = id(new PHUIStatusItemView())->setTarget($handle->renderLink());
         $state = $authorization->getBlueprintAuthorizationState();
         $item->setIcon(DrydockAuthorization::getBlueprintStateIcon($state), null, DrydockAuthorization::getBlueprintStateName($state));
         $items[] = $item;
     }
     $status = new PHUIStatusListView();
     foreach ($items as $item) {
         $status->addItem($item);
     }
     return $status;
 }
开发者ID:GauravSahu,项目名称:phabricator,代码行数:35,代码来源:DrydockObjectAuthorizationView.php

示例7: executeAllocateResource

 protected function executeAllocateResource(DrydockLease $lease)
 {
     $repository_id = $lease->getAttribute('repositoryID');
     if (!$repository_id) {
         throw new Exception(pht("Lease is missing required '%s' attribute.", 'repositoryID'));
     }
     $repository = id(new PhabricatorRepositoryQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withIDs(array($repository_id))->executeOne();
     if (!$repository) {
         throw new Exception(pht("Repository '%s' does not exist!", $repository_id));
     }
     switch ($repository->getVersionControlSystem()) {
         case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
             break;
         default:
             throw new Exception(pht('Unsupported VCS!'));
     }
     // TODO: Policy stuff here too.
     $host_lease = id(new DrydockLease())->setResourceType('host')->waitUntilActive();
     $path = $host_lease->getAttribute('path') . $repository->getCallsign();
     $this->log(pht('Cloning %s into %s....', $repository->getCallsign(), $path));
     $cmd = $host_lease->getInterface('command');
     $cmd->execx('git clone --origin origin %P %s', $repository->getRemoteURIEnvelope(), $path);
     $this->log(pht('Complete.'));
     $resource = $this->newResourceTemplate(pht('Working Copy (%s)', $repository->getCallsign()));
     $resource->setStatus(DrydockResourceStatus::STATUS_OPEN);
     $resource->setAttribute('lease.host', $host_lease->getID());
     $resource->setAttribute('path', $path);
     $resource->setAttribute('repositoryID', $repository->getID());
     $resource->save();
     return $resource;
 }
开发者ID:fengshao0907,项目名称:phabricator,代码行数:31,代码来源:DrydockWorkingCopyBlueprintImplementation.php

示例8: willFilterPage

 protected function willFilterPage(array $items)
 {
     $source_phids = mpull($items, 'getSourcePHID');
     // NOTE: We always load sources, even if the viewer can't formally see
     // them. If they can see the item, they're allowed to be aware of the
     // source in some sense.
     $sources = id(new NuanceSourceQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withPHIDs($source_phids)->execute();
     $sources = mpull($sources, null, 'getPHID');
     foreach ($items as $key => $item) {
         $source = idx($sources, $item->getSourcePHID());
         if (!$source) {
             $this->didRejectResult($items[$key]);
             unset($items[$key]);
             continue;
         }
         $item->attachSource($source);
     }
     $type_map = NuanceItemType::getAllItemTypes();
     foreach ($items as $key => $item) {
         $type = idx($type_map, $item->getItemType());
         if (!$type) {
             $this->didRejectResult($items[$key]);
             unset($items[$key]);
             continue;
         }
         $item->attachImplementation($type);
     }
     return $items;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:29,代码来源:NuanceItemQuery.php

示例9: loadAffiliatedUserPHIDs

 public static function loadAffiliatedUserPHIDs(array $package_ids)
 {
     if (!$package_ids) {
         return array();
     }
     $owners = id(new PhabricatorOwnersOwner())->loadAllWhere('packageID IN (%Ls)', $package_ids);
     $type_user = PhabricatorPeopleUserPHIDType::TYPECONST;
     $type_project = PhabricatorProjectProjectPHIDType::TYPECONST;
     $user_phids = array();
     $project_phids = array();
     foreach ($owners as $owner) {
         $owner_phid = $owner->getUserPHID();
         switch (phid_get_type($owner_phid)) {
             case PhabricatorPeopleUserPHIDType::TYPECONST:
                 $user_phids[] = $owner_phid;
                 break;
             case PhabricatorProjectProjectPHIDType::TYPECONST:
                 $project_phids[] = $owner_phid;
                 break;
         }
     }
     if ($project_phids) {
         $projects = id(new PhabricatorProjectQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withPHIDs($project_phids)->needMembers(true)->execute();
         foreach ($projects as $project) {
             foreach ($project->getMemberPHIDs() as $member_phid) {
                 $user_phids[] = $member_phid;
             }
         }
     }
     $user_phids = array_fuse($user_phids);
     return array_values($user_phids);
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:32,代码来源:PhabricatorOwnersOwner.php

示例10: validateTransaction

 protected function validateTransaction(PhabricatorLiskDAO $object, $type, array $xactions)
 {
     $errors = parent::validateTransaction($object, $type, $xactions);
     switch ($type) {
         case AlmanacBindingTransaction::TYPE_INTERFACE:
             $missing = $this->validateIsEmptyTextField($object->getInterfacePHID(), $xactions);
             if ($missing) {
                 $error = new PhabricatorApplicationTransactionValidationError($type, pht('Required'), pht('Bindings must specify an interface.'), nonempty(last($xactions), null));
                 $error->setIsMissingFieldError(true);
                 $errors[] = $error;
             } else {
                 if ($xactions) {
                     foreach ($xactions as $xaction) {
                         $interfaces = id(new AlmanacInterfaceQuery())->setViewer($this->requireActor())->withPHIDs(array($xaction->getNewValue()))->execute();
                         if (!$interfaces) {
                             $error = new PhabricatorApplicationTransactionValidationError($type, pht('Invalid'), pht('You can not bind a service to an invalid or restricted ' . 'interface.'), $xaction);
                             $errors[] = $error;
                         }
                     }
                     $final_value = last($xactions)->getNewValue();
                     $binding = id(new AlmanacBindingQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withServicePHIDs(array($object->getServicePHID()))->withInterfacePHIDs(array($final_value))->executeOne();
                     if ($binding && $binding->getID() != $object->getID()) {
                         $error = new PhabricatorApplicationTransactionValidationError($type, pht('Already Bound'), pht('You can not bind a service to the same interface multiple ' . 'times.'), last($xactions));
                         $errors[] = $error;
                     }
                 }
             }
             break;
     }
     return $errors;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:31,代码来源:AlmanacBindingEditor.php

示例11: applyRequire

 protected function applyRequire(array $phids)
 {
     $adapter = $this->getAdapter();
     $edgetype_legal = LegalpadObjectNeedsSignatureEdgeType::EDGECONST;
     $current = $adapter->loadEdgePHIDs($edgetype_legal);
     $allowed_types = array(PhabricatorLegalpadDocumentPHIDType::TYPECONST);
     $targets = $this->loadStandardTargets($phids, $allowed_types, $current);
     if (!$targets) {
         return;
     }
     $phids = array_fuse(array_keys($targets));
     $object = $adapter->getObject();
     $author_phid = $object->getAuthorPHID();
     $signatures = id(new LegalpadDocumentSignatureQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withDocumentPHIDs($phids)->withSignerPHIDs(array($author_phid))->execute();
     $signatures = mpull($signatures, null, 'getDocumentPHID');
     $signed = array();
     foreach ($phids as $phid) {
         if (isset($signatures[$phid])) {
             $signed[] = $phid;
             unset($phids[$phid]);
         }
     }
     if ($signed) {
         $this->logEffect(self::DO_SIGNED, $phids);
     }
     if (!$phids) {
         return;
     }
     $xaction = $adapter->newTransaction()->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $edgetype_legal)->setNewValue(array('+' => $phids));
     $adapter->queueTransaction($xaction);
     $this->logEffect(self::DO_REQUIRED, $phids);
 }
开发者ID:fengshao0907,项目名称:phabricator,代码行数:32,代码来源:LegalpadRequireSignatureHeraldAction.php

示例12: updateRefs

 public function updateRefs()
 {
     $this->newRefs = array();
     $this->deadRefs = array();
     $this->closeCommits = array();
     $repository = $this->getRepository();
     $vcs = $repository->getVersionControlSystem();
     switch ($vcs) {
         case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
             // No meaningful refs of any type in Subversion.
             $branches = array();
             $bookmarks = array();
             $tags = array();
             break;
         case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
             $branches = $this->loadMercurialBranchPositions($repository);
             $bookmarks = $this->loadMercurialBookmarkPositions($repository);
             $tags = array();
             break;
         case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
             $branches = $this->loadGitBranchPositions($repository);
             $bookmarks = array();
             $tags = $this->loadGitTagPositions($repository);
             break;
         default:
             throw new Exception(pht('Unknown VCS "%s"!', $vcs));
     }
     $maps = array(PhabricatorRepositoryRefCursor::TYPE_BRANCH => $branches, PhabricatorRepositoryRefCursor::TYPE_TAG => $tags, PhabricatorRepositoryRefCursor::TYPE_BOOKMARK => $bookmarks);
     $all_cursors = id(new PhabricatorRepositoryRefCursorQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withRepositoryPHIDs(array($repository->getPHID()))->execute();
     $cursor_groups = mgroup($all_cursors, 'getRefType');
     $this->hasNoCursors = !$all_cursors;
     // Find all the heads of closing refs.
     $all_closing_heads = array();
     foreach ($all_cursors as $cursor) {
         if ($this->shouldCloseRef($cursor->getRefType(), $cursor->getRefName())) {
             $all_closing_heads[] = $cursor->getCommitIdentifier();
         }
     }
     $all_closing_heads = array_unique($all_closing_heads);
     $all_closing_heads = $this->removeMissingCommits($all_closing_heads);
     foreach ($maps as $type => $refs) {
         $cursor_group = idx($cursor_groups, $type, array());
         $this->updateCursors($cursor_group, $refs, $type, $all_closing_heads);
     }
     if ($this->closeCommits) {
         $this->setCloseFlagOnCommits($this->closeCommits);
     }
     if ($this->newRefs || $this->deadRefs) {
         $repository->openTransaction();
         foreach ($this->newRefs as $ref) {
             $ref->save();
         }
         foreach ($this->deadRefs as $ref) {
             $ref->delete();
         }
         $repository->saveTransaction();
         $this->newRefs = array();
         $this->deadRefs = array();
     }
 }
开发者ID:denghp,项目名称:phabricator,代码行数:60,代码来源:PhabricatorRepositoryRefEngine.php

示例13: newEditableObject

 protected function newEditableObject()
 {
     $viewer = $this->getViewer();
     $repository = PhabricatorRepository::initializeNewRepository($viewer);
     $repository->setDetail('newly-initialized', true);
     $vcs = $this->getVersionControlSystem();
     if ($vcs) {
         $repository->setVersionControlSystem($vcs);
     }
     // Pick a random open service to allocate this repository on, if any exist.
     // If there are no services, we aren't in cluster mode and will allocate
     // locally. If there are services but none permit allocations, we fail.
     // Eventually we can make this more flexible, but this rule is a reasonable
     // starting point as we begin to deploy cluster services.
     $services = id(new AlmanacServiceQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withServiceTypes(array(AlmanacClusterRepositoryServiceType::SERVICETYPE))->needProperties(true)->execute();
     if ($services) {
         // Filter out services which do not permit new allocations.
         foreach ($services as $key => $possible_service) {
             if ($possible_service->getAlmanacPropertyValue('closed')) {
                 unset($services[$key]);
             }
         }
         if (!$services) {
             throw new Exception(pht('This install is configured in cluster mode, but all available ' . 'repository cluster services are closed to new allocations. ' . 'At least one service must be open to allow new allocations to ' . 'take place.'));
         }
         shuffle($services);
         $service = head($services);
         $repository->setAlmanacServicePHID($service->getPHID());
     }
     return $repository;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:31,代码来源:DiffusionRepositoryEditEngine.php

示例14: getViewer

 public function getViewer()
 {
     // Some day, we might provide a more general viewer mechanism to scripts.
     // For now, workflows can call this method for convenience and future
     // flexibility.
     return PhabricatorUser::getOmnipotentUser();
 }
开发者ID:denghp,项目名称:phabricator,代码行数:7,代码来源:PhabricatorManagementWorkflow.php

示例15: execute

 public function execute(HarbormasterBuild $build, HarbormasterBuildTarget $build_target)
 {
     $viewer = PhabricatorUser::getOmnipotentUser();
     $settings = $this->getSettings();
     $variables = $build_target->getVariables();
     $uri = $settings['uri'] . '/httpAuth/app/rest/buildQueue';
     $method = 'POST';
     $contentType = 'application/xml';
     $xmlBuilder = new TeamCityXmlBuildBuilder();
     $payload = $xmlBuilder->addBuildId($settings['buildId'])->addBranchName(implode(array("D", $variables['buildable.diff'])))->addDiffId(implode(array("D", $variables['buildable.diff'])))->addHarbormasterPHID($variables['target.phid'])->addRevisionId($variables['buildable.revision'])->build();
     $future = id(new HTTPFuture($uri, $payload))->setMethod($method)->addHeader('Content-Type', $contentType)->setTimeout(60);
     $credential_phid = $this->getSetting('credential');
     if ($credential_phid) {
         $key = PassphrasePasswordKey::loadFromPHID($credential_phid, $viewer);
         $future->setHTTPBasicAuthCredentials($key->getUsernameEnvelope()->openEnvelope(), $key->getPasswordEnvelope());
     }
     $this->resolveFutures($build, $build_target, array($future));
     list($status, $body, $headers) = $future->resolve();
     $header_lines = array();
     // TODO: We don't currently preserve the entire "HTTP" response header, but
     // should. Once we do, reproduce it here faithfully.
     $status_code = $status->getStatusCode();
     $header_lines[] = "HTTP {$status_code}";
     foreach ($headers as $header) {
         list($head, $tail) = $header;
         $header_lines[] = "{$head}: {$tail}";
     }
     $header_lines = implode("\n", $header_lines);
     $build_target->newLog($uri, 'http.head')->append($header_lines);
     $build_target->newLog($uri, 'http.body')->append($body);
     if ($status->isError()) {
         throw new HarbormasterBuildFailureException();
     }
 }
开发者ID:joprice,项目名称:TeamCity-Phabricator-Plugin,代码行数:34,代码来源:HarbormasterTeamCityBuildStepImplementation.php


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