本文整理汇总了PHP中array_mergev函数的典型用法代码示例。如果您正苦于以下问题:PHP array_mergev函数的具体用法?PHP array_mergev怎么用?PHP array_mergev使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了array_mergev函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processRequest
public function processRequest()
{
if (!PhabricatorEnv::getEnvConfig('feed.public')) {
return new Aphront404Response();
}
// TODO: Profile images won't render correctly for logged-out users.
$request = $this->getRequest();
$query = new PhabricatorFeedQuery();
$stories = $query->execute();
$handles = array();
$objects = array();
if ($stories) {
$handle_phids = array_mergev(mpull($stories, 'getRequiredHandlePHIDs'));
$object_phids = array_mergev(mpull($stories, 'getRequiredObjectPHIDs'));
$handles = id(new PhabricatorObjectHandleData($handle_phids))->loadHandles();
$objects = id(new PhabricatorObjectHandleData($object_phids))->loadObjects();
}
// TODO: We need this for timezones but should develop some more general
// solution for logged-out pages.
$dummy_user = new PhabricatorUser();
$views = array();
foreach ($stories as $story) {
$story->setHandles($handles);
$story->setObjects($objects);
$view = $story->renderView();
$view->setViewer($dummy_user);
$views[] = $view->render();
}
return $this->buildStandardPageResponse($views, array('title' => 'Public Feed', 'public' => true));
}
示例2: renderResultList
protected function renderResultList(array $builds, PhabricatorSavedQuery $query, array $handles)
{
assert_instances_of($builds, 'HarbormasterBuild');
$viewer = $this->requireViewer();
$buildables = mpull($builds, 'getBuildable');
$object_phids = mpull($buildables, 'getBuildablePHID');
$initiator_phids = mpull($builds, 'getInitiatorPHID');
$phids = array_mergev(array($initiator_phids, $object_phids));
$phids = array_unique(array_filter($phids));
$handles = $viewer->loadHandles($phids);
$list = new PHUIObjectItemListView();
foreach ($builds as $build) {
$id = $build->getID();
$initiator = $handles[$build->getInitiatorPHID()];
$buildable_object = $handles[$build->getBuildable()->getBuildablePHID()];
$item = id(new PHUIObjectItemView())->setViewer($viewer)->setObject($build)->setObjectName(pht('Build %d', $build->getID()))->setHeader($build->getName())->setHref($build->getURI())->setEpoch($build->getDateCreated())->addAttribute($buildable_object->getName());
if ($initiator) {
$item->addHandleIcon($initiator, $initiator->getName());
}
$status = $build->getBuildStatus();
$status_icon = HarbormasterBuildStatus::getBuildStatusIcon($status);
$status_color = HarbormasterBuildStatus::getBuildStatusColor($status);
$status_label = HarbormasterBuildStatus::getBuildStatusName($status);
$item->setStatusIcon("{$status_icon} {$status_color}", $status_label);
$list->addItem($item);
}
$result = new PhabricatorApplicationSearchResultView();
$result->setObjectList($list);
$result->setNoDataString(pht('No builds found.'));
return $result;
}
示例3: buildSearchForm
public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved)
{
$backer_phids = $saved->getParameter('backerPHIDs', array());
$all_phids = array_mergev(array($backer_phids));
$handles = id(new PhabricatorHandleQuery())->setViewer($this->requireViewer())->withPHIDs($all_phids)->execute();
$form->appendChild(id(new AphrontFormTokenizerControl())->setLabel(pht('Backers'))->setName('backers')->setDatasource(new PhabricatorPeopleDatasource())->setValue(array_select_keys($handles, $backer_phids)));
}
示例4: shouldShowStory
private function shouldShowStory($story)
{
$story_objectphid = $story['objectPHID'];
$story_text = $story['text'];
$show = $this->getConfig('notification.types');
if ($show) {
$obj_type = phid_get_type($story_objectphid);
if (!in_array(strtolower($obj_type), $show)) {
return false;
}
}
$verbosity = $this->getConfig('notification.verbosity', 3);
$verbs = array();
switch ($verbosity) {
case 2:
$verbs[] = array('commented', 'added', 'changed', 'resigned', 'explained', 'modified', 'attached', 'edited', 'joined', 'left', 'removed');
// fallthrough
// fallthrough
case 1:
$verbs[] = array('updated', 'accepted', 'requested', 'planned', 'claimed', 'summarized', 'commandeered', 'assigned');
// fallthrough
// fallthrough
case 0:
$verbs[] = array('created', 'closed', 'raised', 'committed', 'abandoned', 'reclaimed', 'reopened', 'deleted');
break;
case 3:
default:
return true;
}
$verbs = '/(' . implode('|', array_mergev($verbs)) . ')/';
if (preg_match($verbs, $story_text)) {
return true;
}
return false;
}
示例5: buildPanels
private function buildPanels()
{
$panel_specs = id(new PhutilSymbolLoader())->setAncestorClass('PhabricatorSettingsPanel')->setConcreteOnly(true)->selectAndLoadSymbols();
$panels = array();
foreach ($panel_specs as $spec) {
$class = newv($spec['name'], array());
$panels[] = $class->buildPanels();
}
$panels = array_mergev($panels);
$panels = mpull($panels, null, 'getPanelKey');
$result = array();
foreach ($panels as $key => $panel) {
$panel->setUser($this->user);
if (!$panel->isEnabled()) {
continue;
}
if (!$this->isSelf()) {
if (!$panel->isEditableByAdministrators()) {
continue;
}
}
if (!empty($result[$key])) {
throw new Exception(pht("Two settings panels share the same panel key ('%s'): %s, %s.", $key, get_class($panel), get_class($result[$key])));
}
$result[$key] = $panel;
}
$result = msort($result, 'getPanelSortKey');
if (!$result) {
throw new Exception(pht('No settings panels are available.'));
}
return $result;
}
示例6: buildView
public function buildView()
{
if (!$this->user) {
throw new Exception('Call setUser() before buildView()!');
}
$user = $this->user;
$stories = $this->stories;
$handles = array();
if ($stories) {
$handle_phids = array_mergev(mpull($stories, 'getRequiredHandlePHIDs'));
$object_phids = array_mergev(mpull($stories, 'getRequiredObjectPHIDs'));
$handles = id(new PhabricatorObjectHandleData($handle_phids))->loadHandles();
}
$null_view = new AphrontNullView();
require_celerity_resource('phabricator-feed-css');
$last_date = null;
foreach ($stories as $story) {
$story->setHandles($handles);
$story->setFramed($this->framed);
$date = ucfirst(phabricator_relative_date($story->getEpoch(), $user));
if ($date !== $last_date) {
if ($last_date !== null) {
$null_view->appendChild('<div class="phabricator-feed-story-date-separator"></div>');
}
$last_date = $date;
$null_view->appendChild(phutil_render_tag('div', array('class' => 'phabricator-feed-story-date'), phutil_escape_html($date)));
}
$view = $story->renderView();
$view->setViewer($user);
$null_view->appendChild($view);
}
return id(new AphrontNullView())->appendChild('<div class="phabricator-feed-frame">' . $null_view->render() . '</div>');
}
示例7: parseCommit
protected function parseCommit(PhabricatorRepository $repository, PhabricatorRepositoryCommit $commit)
{
// Reload the commit to pull commit data and audit requests.
$commit = id(new DiffusionCommitQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withIDs(array($commit->getID()))->needCommitData(true)->needAuditRequests(true)->executeOne();
$data = $commit->getCommitData();
if (!$data) {
throw new PhabricatorWorkerPermanentFailureException(pht('Unable to load commit data. The data for this task is invalid ' . 'or no longer exists.'));
}
$commit->attachRepository($repository);
$content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_DAEMON, array());
$committer_phid = $data->getCommitDetail('committerPHID');
$author_phid = $data->getCommitDetail('authorPHID');
$acting_as_phid = nonempty($committer_phid, $author_phid, id(new PhabricatorDiffusionApplication())->getPHID());
$editor = id(new PhabricatorAuditEditor())->setActor(PhabricatorUser::getOmnipotentUser())->setActingAsPHID($acting_as_phid)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true)->setContentSource($content_source);
$xactions = array();
$xactions[] = id(new PhabricatorAuditTransaction())->setTransactionType(PhabricatorAuditTransaction::TYPE_COMMIT)->setDateCreated($commit->getEpoch())->setNewValue(array('description' => $data->getCommitMessage(), 'summary' => $data->getSummary(), 'authorName' => $data->getAuthorName(), 'authorPHID' => $commit->getAuthorPHID(), 'committerName' => $data->getCommitDetail('committer'), 'committerPHID' => $data->getCommitDetail('committerPHID')));
$reverts_refs = id(new DifferentialCustomFieldRevertsParser())->parseCorpus($data->getCommitMessage());
$reverts = array_mergev(ipull($reverts_refs, 'monograms'));
if ($reverts) {
$reverted_commits = id(new DiffusionCommitQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withRepository($repository)->withIdentifiers($reverts)->execute();
$reverted_commit_phids = mpull($reverted_commits, 'getPHID', 'getPHID');
// NOTE: Skip any write attempts if a user cleverly implies a commit
// reverts itself.
unset($reverted_commit_phids[$commit->getPHID()]);
$reverts_edge = DiffusionCommitRevertsCommitEdgeType::EDGECONST;
$xactions[] = id(new PhabricatorAuditTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $reverts_edge)->setNewValue(array('+' => array_fuse($reverted_commit_phids)));
}
try {
$raw_patch = $this->loadRawPatchText($repository, $commit);
} catch (Exception $ex) {
$raw_patch = pht('Unable to generate patch: %s', $ex->getMessage());
}
$editor->setRawPatch($raw_patch);
return $editor->applyTransactions($commit, $xactions);
}
示例8: runTests
public function runTests($test_paths, $source_path)
{
if (empty($test_paths)) {
return array();
}
$futures = array();
$tmpfiles = array();
foreach ($test_paths as $test_path) {
$xunit_tmp = new TempFile();
$cover_tmp = new TempFile();
$future = $this->buildTestFuture($test_path, $xunit_tmp, $cover_tmp);
$futures[$test_path] = $future;
$tmpfiles[$test_path] = array('xunit' => $xunit_tmp, 'cover' => $cover_tmp);
}
$results = array();
$futures = id(new FutureIterator($futures))->limit(4);
foreach ($futures as $test_path => $future) {
try {
list($stdout, $stderr) = $future->resolvex();
} catch (CommandException $exc) {
if ($exc->getError() > 1) {
// 'nose' returns 1 when tests are failing/broken.
throw $exc;
}
}
$xunit_tmp = $tmpfiles[$test_path]['xunit'];
$cover_tmp = $tmpfiles[$test_path]['cover'];
$this->parser = new ArcanistXUnitTestResultParser();
$results[] = $this->parseTestResults($source_path, $xunit_tmp, $cover_tmp);
}
return array_mergev($results);
}
示例9: getRequiredHandlePHIDsForResultList
protected function getRequiredHandlePHIDsForResultList(array $objects, PhabricatorSavedQuery $query)
{
$phids = array();
foreach ($objects as $mail) {
$phids[] = $mail->getExpandedRecipientPHIDs();
}
return array_mergev($phids);
}
示例10: getRequiredObjectPHIDs
public function getRequiredObjectPHIDs()
{
$phids = array();
foreach ($this->getAggregateStories() as $story) {
$phids[] = $story->getRequiredObjectPHIDs();
}
return array_mergev($phids);
}
示例11: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $this->getViewer();
$package = id(new PhabricatorOwnersPackageQuery())->setViewer($viewer)->withIDs(array($request->getURIData('id')))->needPaths(true)->executeOne();
if (!$package) {
return new Aphront404Response();
}
$paths = $package->getPaths();
$repository_phids = array();
foreach ($paths as $path) {
$repository_phids[$path->getRepositoryPHID()] = true;
}
if ($repository_phids) {
$repositories = id(new PhabricatorRepositoryQuery())->setViewer($viewer)->withPHIDs(array_keys($repository_phids))->execute();
$repositories = mpull($repositories, null, 'getPHID');
} else {
$repositories = array();
}
$actions = $this->buildPackageActionView($package);
$properties = $this->buildPackagePropertyView($package);
$properties->setActionList($actions);
$header = id(new PHUIHeaderView())->setUser($viewer)->setHeader($package->getName())->setPolicyObject($package);
$panel = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties);
$commit_views = array();
$commit_uri = id(new PhutilURI('/audit/'))->setQueryParams(array('auditorPHIDs' => $package->getPHID()));
$attention_commits = id(new DiffusionCommitQuery())->setViewer($request->getUser())->withAuditorPHIDs(array($package->getPHID()))->withAuditStatus(DiffusionCommitQuery::AUDIT_STATUS_CONCERN)->needCommitData(true)->setLimit(10)->execute();
if ($attention_commits) {
$view = id(new PhabricatorAuditListView())->setUser($viewer)->setCommits($attention_commits);
$commit_views[] = array('view' => $view, 'header' => pht('Commits in this Package that Need Attention'), 'button' => id(new PHUIButtonView())->setTag('a')->setHref($commit_uri->alter('status', 'open'))->setText(pht('View All Problem Commits')));
}
$all_commits = id(new DiffusionCommitQuery())->setViewer($request->getUser())->withAuditorPHIDs(array($package->getPHID()))->needCommitData(true)->setLimit(100)->execute();
$view = id(new PhabricatorAuditListView())->setUser($viewer)->setCommits($all_commits)->setNoDataString(pht('No commits in this package.'));
$commit_views[] = array('view' => $view, 'header' => pht('Recent Commits in Package'), 'button' => id(new PHUIButtonView())->setTag('a')->setHref($commit_uri)->setText(pht('View All Package Commits')));
$phids = array();
foreach ($commit_views as $commit_view) {
$phids[] = $commit_view['view']->getRequiredHandlePHIDs();
}
$phids = array_mergev($phids);
$handles = $this->loadViewerHandles($phids);
$commit_panels = array();
foreach ($commit_views as $commit_view) {
$commit_panel = new PHUIObjectBoxView();
$header = new PHUIHeaderView();
$header->setHeader($commit_view['header']);
if (isset($commit_view['button'])) {
$header->addActionLink($commit_view['button']);
}
$commit_view['view']->setHandles($handles);
$commit_panel->setHeader($header);
$commit_panel->appendChild($commit_view['view']);
$commit_panels[] = $commit_panel;
}
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($package->getName());
$timeline = $this->buildTransactionTimeline($package, new PhabricatorOwnersPackageTransactionQuery());
$timeline->setShouldTerminate(true);
return $this->buildApplicationPage(array($crumbs, $panel, $this->renderPathsTable($paths, $repositories), $commit_panels, $timeline), array('title' => $package->getName()));
}
示例12: extractPHIDs
private function extractPHIDs(PhabricatorPolicy $policy, array $rule_objects)
{
$phids = array();
foreach ($policy->getRules() as $rule) {
$rule_object = $rule_objects[$rule['rule']];
$phids[] = $rule_object->getRequiredHandlePHIDsForSummary($rule['value']);
}
return array_filter(array_mergev($phids));
}
示例13: parseTestResults
public function parseTestResults($path)
{
$results = array();
foreach (glob($path . "/*.xml") as $filename) {
$parser = new ArcanistXUnitTestResultParser();
$results[] = $parser->parseTestResults(Filesystem::readFile($filename));
}
return array_mergev($results);
}
示例14: loadResults
public function loadResults()
{
$results = array();
foreach ($this->getUsableDatasources() as $source) {
$source->setRawQuery($this->getRawQuery())->setQuery($this->getQuery())->setViewer($this->getViewer())->setLimit($this->getLimit());
$results[] = $source->loadResults();
}
return array_mergev($results);
}
示例15: loadResults
public function loadResults()
{
$offset = $this->getOffset();
$limit = $this->getLimit();
// If the input query is a function like `members(platy`, and we can
// parse the function, we strip the function off and hand the stripped
// query to child sources. This makes it easier to implement function
// sources in terms of real object sources.
$raw_query = $this->getRawQuery();
$is_function = false;
if (self::isFunctionToken($raw_query)) {
$is_function = true;
}
$stack = $this->getFunctionStack();
$is_browse = $this->getIsBrowse();
$results = array();
foreach ($this->getUsableDatasources() as $source) {
$source_stack = $stack;
$source_query = $raw_query;
if ($is_function) {
// If this source can't handle the function, skip it.
$function = $source->parseFunction($raw_query, $allow_partial = true);
if (!$function) {
continue;
}
// If this source handles the function directly, strip the function.
// Otherwise, this is something like a composite source which has
// some internal source which can evaluate the function, but will
// perform stripping later.
if ($source->shouldStripFunction($function['name'])) {
$source_query = head($function['argv']);
$source_stack[] = $function['name'];
}
}
$source->setFunctionStack($source_stack)->setRawQuery($source_query)->setQuery($this->getQuery())->setViewer($this->getViewer());
if ($limit) {
$source->setLimit($offset + $limit);
}
if ($is_browse) {
$source->setIsBrowse(true);
}
$source_results = $source->loadResults();
$source_results = $source->didLoadResults($source_results);
$results[] = $source_results;
}
$results = array_mergev($results);
$results = msort($results, 'getSortKey');
$count = count($results);
if ($offset || $limit) {
if (!$limit) {
$limit = count($results);
}
$results = array_slice($results, $offset, $limit, $preserve_keys = true);
}
return $results;
}