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


PHP mgroup函数代码示例

本文整理汇总了PHP中mgroup函数的典型用法代码示例。如果您正苦于以下问题:PHP mgroup函数的具体用法?PHP mgroup怎么用?PHP mgroup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: getQuickMenuItems

 public function getQuickMenuItems()
 {
     $viewer = $this->getViewer();
     $engines = PhabricatorEditEngine::getAllEditEngines();
     foreach ($engines as $key => $engine) {
         if (!$engine->hasQuickCreateActions()) {
             unset($engines[$key]);
         }
     }
     if (!$engines) {
         return array();
     }
     $engine_keys = array_keys($engines);
     $configs = id(new PhabricatorEditEngineConfigurationQuery())->setViewer($viewer)->withEngineKeys($engine_keys)->withIsDefault(true)->withIsDisabled(false)->execute();
     $configs = msort($configs, 'getCreateSortKey');
     $configs = mgroup($configs, 'getEngineKey');
     $items = array();
     foreach ($engines as $key => $engine) {
         $engine_configs = idx($configs, $key, array());
         $engine_items = $engine->newQuickCreateActions($engine_configs);
         foreach ($engine_items as $engine_item) {
             $items[] = $engine_item;
         }
     }
     return $items;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:26,代码来源:PhabricatorEditEngineCreateQuickActions.php

示例2: lookupRepository

 public function lookupRepository()
 {
     $viewer = $this->viewer;
     $diff = $this->diff;
     // Look for a repository UUID.
     if ($diff->getRepositoryUUID()) {
         $repositories = id(new PhabricatorRepositoryQuery())->setViewer($viewer)->withUUIDs(array($diff->getRepositoryUUID()))->execute();
         if ($repositories) {
             return head($repositories);
         }
     }
     // Look for the base commit in Git and Mercurial.
     $vcs = $diff->getSourceControlSystem();
     $vcs_git = PhabricatorRepositoryType::REPOSITORY_TYPE_GIT;
     $vcs_hg = PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL;
     if ($vcs == $vcs_git || $vcs == $vcs_hg) {
         $base = $diff->getSourceControlBaseRevision();
         if ($base) {
             $commits = id(new DiffusionCommitQuery())->setViewer($viewer)->withIdentifiers(array($base))->execute();
             $commits = mgroup($commits, 'getRepositoryID');
             if (count($commits) == 1) {
                 $repository_id = key($commits);
                 $repositories = id(new PhabricatorRepositoryQuery())->setViewer($viewer)->withIDs(array($repository_id))->execute();
                 if ($repositories) {
                     return head($repositories);
                 }
             }
         }
     }
     // TODO: Compare SVN remote URIs? Compare Git/Hg remote URIs? Add
     // an explicit option to `.arcconfig`?
     return null;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:33,代码来源:DifferentialRepositoryLookup.php

示例3: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $applications = PhabricatorApplication::getAllInstalledApplications();
     foreach ($applications as $key => $application) {
         if (!$application->shouldAppearInLaunchView()) {
             unset($applications[$key]);
         }
     }
     $groups = PhabricatorApplication::getApplicationGroups();
     $applications = msort($applications, 'getApplicationOrder');
     $applications = mgroup($applications, 'getApplicationGroup');
     $applications = array_select_keys($applications, array_keys($groups));
     $view = array();
     foreach ($applications as $group => $application_list) {
         $status = array();
         foreach ($application_list as $key => $application) {
             $status[$key] = $application->loadStatus($user);
         }
         $views = array();
         foreach ($application_list as $key => $application) {
             $views[] = id(new PhabricatorApplicationLaunchView())->setApplication($application)->setApplicationStatus(idx($status, $key, array()))->setUser($user);
         }
         $view[] = id(new PhabricatorHeaderView())->setHeader($groups[$group]);
         $view[] = phutil_render_tag('div', array('class' => 'phabricator-application-list'), id(new AphrontNullView())->appendChild($views)->render());
     }
     return $this->buildApplicationPage($view, array('title' => 'Applications', 'device' => true));
 }
开发者ID:rudimk,项目名称:phabricator,代码行数:29,代码来源:PhabricatorApplicationsListController.php

示例4: execute

 protected function execute(ConduitAPIRequest $request)
 {
     $results = array();
     $revision_ids = $request->getValue('ids');
     if (!$revision_ids) {
         return $results;
     }
     $comments = id(new DifferentialComment())->loadAllWhere('revisionID IN (%Ld)', $revision_ids);
     $with_inlines = $request->getValue('inlines');
     if ($with_inlines) {
         $inlines = id(new DifferentialInlineComment())->loadAllWhere('revisionID IN (%Ld)', $revision_ids);
         $changesets = array();
         if ($inlines) {
             $changesets = id(new DifferentialChangeset())->loadAllWhere('id IN (%Ld)', array_unique(mpull($inlines, 'getChangesetID')));
             $inlines = mgroup($inlines, 'getCommentID');
         }
     }
     foreach ($comments as $comment) {
         $revision_id = $comment->getRevisionID();
         $result = array('revisionID' => $revision_id, 'action' => $comment->getAction(), 'authorPHID' => $comment->getAuthorPHID(), 'dateCreated' => $comment->getDateCreated(), 'content' => $comment->getContent());
         if ($with_inlines) {
             $result['inlines'] = array();
             foreach (idx($inlines, $comment->getID(), array()) as $inline) {
                 $changeset = idx($changesets, $inline->getChangesetID());
                 $result['inlines'][] = $this->buildInlineInfoDictionary($inline, $changeset);
             }
             // TODO: Put synthetic inlines without an attached comment somewhere.
         }
         $results[$revision_id][] = $result;
     }
     return $results;
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:32,代码来源:ConduitAPI_differential_getrevisioncomments_Method.php

示例5: didFilterPage

 protected function didFilterPage(array $objects)
 {
     $has_properties = head($objects) instanceof AlmanacPropertyInterface;
     if ($has_properties && $this->needProperties) {
         $property_query = id(new AlmanacPropertyQuery())->setViewer($this->getViewer())->setParentQuery($this)->withObjects($objects);
         $properties = $property_query->execute();
         $properties = mgroup($properties, 'getObjectPHID');
         foreach ($objects as $object) {
             $object_properties = idx($properties, $object->getPHID(), array());
             $object_properties = mpull($object_properties, null, 'getFieldName');
             // Create synthetic properties for defaults on the object itself.
             $specs = $object->getAlmanacPropertyFieldSpecifications();
             foreach ($specs as $key => $spec) {
                 if (empty($object_properties[$key])) {
                     $object_properties[$key] = id(new AlmanacProperty())->setObjectPHID($object->getPHID())->setFieldName($key)->setFieldValue($spec->getValueForTransaction());
                 }
             }
             foreach ($object_properties as $property) {
                 $property->attachObject($object);
             }
             $object->attachAlmanacProperties($object_properties);
         }
     }
     return $objects;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:25,代码来源:AlmanacQuery.php

示例6: processRequest

 public function processRequest()
 {
     $items = id(new PhabricatorDirectoryItem())->loadAll();
     $items = msort($items, 'getSortKey');
     $categories = id(new PhabricatorDirectoryCategory())->loadAll();
     $categories = msort($categories, 'getSequence');
     $category_map = mpull($categories, 'getName', 'getID');
     $category_map[0] = 'Free Radicals';
     $items = mgroup($items, 'getCategoryID');
     require_celerity_resource('phabricator-directory-css');
     $content = array();
     foreach ($category_map as $id => $category_name) {
         $category_items = idx($items, $id);
         if (!$category_items) {
             continue;
         }
         $item_markup = array();
         foreach ($category_items as $item) {
             $item_markup[] = '<div>' . '<h2>' . phutil_render_tag('a', array('href' => $item->getHref()), phutil_escape_html($item->getName())) . '</h2>' . '<p>' . phutil_escape_html($item->getDescription()) . '</p>' . '</div>';
         }
         $content[] = '<div class="aphront-directory-category">' . '<h1>' . phutil_escape_html($category_name) . '</h1>' . '<div class="aphront-directory-group">' . implode("\n", $item_markup) . '</div>' . '</div>';
     }
     $content = '<div class="aphront-directory-list">' . implode("\n", $content) . '</div>';
     return $this->buildStandardPageResponse($content, array('title' => 'Directory', 'tab' => 'directory'));
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:25,代码来源:PhabricatorDirectoryMainController.php

示例7: loadPage

 protected function loadPage()
 {
     $table = new PhortuneProduct();
     $conn = $table->establishConnection('r');
     $rows = queryfx_all($conn, 'SELECT * FROM %T %Q %Q %Q', $table->getTableName(), $this->buildWhereClause($conn), $this->buildOrderClause($conn), $this->buildLimitClause($conn));
     $page = $table->loadAllFromArray($rows);
     // NOTE: We're loading product implementations here, but also creating any
     // products which do not yet exist.
     $class_map = mgroup($page, 'getProductClass');
     if ($this->refMap) {
         $class_map += array_fill_keys(array_keys($this->refMap), array());
     }
     foreach ($class_map as $class => $products) {
         $refs = mpull($products, null, 'getProductRef');
         if (isset($this->refMap[$class])) {
             $refs += array_fill_keys($this->refMap[$class], null);
         }
         $implementations = newv($class, array())->loadImplementationsForRefs($this->getViewer(), array_keys($refs));
         $implementations = mpull($implementations, null, 'getRef');
         foreach ($implementations as $ref => $implementation) {
             $product = idx($refs, $ref);
             if ($product === null) {
                 // If this product does not exist yet, create it and add it to the
                 // result page.
                 $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
                 $product = PhortuneProduct::initializeNewProduct()->setProductClass($class)->setProductRef($ref)->save();
                 unset($unguarded);
                 $page[] = $product;
             }
             $product->attachImplementation($implementation);
         }
     }
     return $page;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:34,代码来源:PhortuneProductQuery.php

示例8: loadAllForProjectPHIDs

 public static function loadAllForProjectPHIDs($phids)
 {
     if (!$phids) {
         return array();
     }
     $default = array_fill_keys($phids, array());
     $affiliations = id(new PhabricatorProjectAffiliation())->loadAllWhere('projectPHID IN (%Ls) ORDER BY IF(status = "former", 1, 0), dateCreated', $phids);
     return mgroup($affiliations, 'getProjectPHID') + $default;
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:9,代码来源:PhabricatorProjectAffiliation.php

示例9: getAllPanelGroupsWithPanels

 public static final function getAllPanelGroupsWithPanels()
 {
     $groups = self::getAllPanelGroups();
     $panels = PhabricatorSettingsPanel::getAllPanels();
     $panels = mgroup($panels, 'getPanelGroupKey');
     foreach ($groups as $key => $group) {
         $group->panels = idx($panels, $key, array());
     }
     return $groups;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:10,代码来源:PhabricatorSettingsPanelGroup.php

示例10: save

 public function save()
 {
     if (!$this->comment) {
         throw new Exception("Must set comment before saving it");
     }
     if (!$this->question) {
         throw new Exception("Must set question before saving comment");
     }
     if (!$this->targetPHID) {
         throw new Exception("Must set target before saving comment");
     }
     if (!$this->viewer) {
         throw new Exception("Must set viewer before saving comment");
     }
     $comment = $this->comment;
     $question = $this->question;
     $target = $this->targetPHID;
     $viewer = $this->viewer;
     $comment->save();
     $question->attachRelated();
     PhabricatorSearchPonderIndexer::indexQuestion($question);
     // subscribe author and @mentions
     $subeditor = id(new PhabricatorSubscriptionsEditor())->setObject($question)->setUser($viewer);
     $subeditor->subscribeExplicit(array($comment->getAuthorPHID()));
     $content = $comment->getContent();
     $at_mention_phids = PhabricatorMarkupEngine::extractPHIDsFromMentions(array($content));
     $subeditor->subscribeImplicit($at_mention_phids);
     $subeditor->save();
     if ($this->shouldEmail) {
         // now load subscribers, including implicitly-added @mention victims
         $subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID($question->getPHID());
         // @mention emails (but not for anyone who has explicitly unsubscribed)
         if (array_intersect($at_mention_phids, $subscribers)) {
             id(new PonderMentionMail($question, $comment, $viewer))->setToPHIDs($at_mention_phids)->send();
         }
         if ($target === $question->getPHID()) {
             $target = $question;
         } else {
             $answers_by_phid = mgroup($question->getAnswers(), 'getPHID');
             $target = head($answers_by_phid[$target]);
         }
         // only send emails to others in the same thread
         $thread = mpull($target->getComments(), 'getAuthorPHID');
         $thread[] = $target->getAuthorPHID();
         $thread[] = $question->getAuthorPHID();
         $other_subs = array_diff(array_intersect($thread, $subscribers), $at_mention_phids);
         // 'Comment' emails for subscribers who are in the same comment thread,
         // including the author of the parent question and/or answer, excluding
         // @mentions (and excluding the author, depending on their MetaMTA
         // settings).
         if ($other_subs) {
             id(new PonderCommentMail($question, $comment, $viewer))->setToPHIDs($other_subs)->send();
         }
     }
 }
开发者ID:rudimk,项目名称:phabricator,代码行数:55,代码来源:PonderCommentEditor.php

示例11: publishFeedStory

 /**
  * Publishes stories into JIRA using the JIRA API.
  */
 protected function publishFeedStory()
 {
     $story = $this->getFeedStory();
     $viewer = $this->getViewer();
     $provider = $this->getProvider();
     $object = $this->getStoryObject();
     $publisher = $this->getPublisher();
     $jira_issue_phids = PhabricatorEdgeQuery::loadDestinationPHIDs($object->getPHID(), PhabricatorJiraIssueHasObjectEdgeType::EDGECONST);
     if (!$jira_issue_phids) {
         $this->log("%s\n", pht('Story is about an object with no linked JIRA issues.'));
         return;
     }
     $do_anything = $this->shouldPostComment() || $this->shouldPostLink();
     if (!$do_anything) {
         $this->log("%s\n", pht('JIRA integration is configured not to post anything.'));
         return;
     }
     $xobjs = id(new DoorkeeperExternalObjectQuery())->setViewer($viewer)->withPHIDs($jira_issue_phids)->execute();
     if (!$xobjs) {
         $this->log("%s\n", pht('Story object has no corresponding external JIRA objects.'));
         return;
     }
     $try_users = $this->findUsersToPossess();
     if (!$try_users) {
         $this->log("%s\n", pht('No users to act on linked JIRA objects.'));
         return;
     }
     $xobjs = mgroup($xobjs, 'getApplicationDomain');
     foreach ($xobjs as $domain => $xobj_list) {
         $accounts = id(new PhabricatorExternalAccountQuery())->setViewer($viewer)->withUserPHIDs($try_users)->withAccountTypes(array($provider->getProviderType()))->withAccountDomains(array($domain))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->execute();
         // Reorder accounts in the original order.
         // TODO: This needs to be adjusted if/when we allow you to link multiple
         // accounts.
         $accounts = mpull($accounts, null, 'getUserPHID');
         $accounts = array_select_keys($accounts, $try_users);
         foreach ($xobj_list as $xobj) {
             foreach ($accounts as $account) {
                 try {
                     $jira_key = $xobj->getObjectID();
                     if ($this->shouldPostComment()) {
                         $this->postComment($account, $jira_key);
                     }
                     if ($this->shouldPostLink()) {
                         $this->postLink($account, $jira_key);
                     }
                     break;
                 } catch (HTTPFutureResponseStatus $ex) {
                     phlog($ex);
                     $this->log("%s\n", pht('Failed to update object %s using user %s.', $xobj->getObjectID(), $account->getUserPHID()));
                 }
             }
         }
     }
 }
开发者ID:pugong,项目名称:phabricator,代码行数:57,代码来源:DoorkeeperJIRAFeedWorker.php

示例12: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $book_name = $request->getURIData('book');
     $book = id(new DivinerBookQuery())->setViewer($viewer)->withNames(array($book_name))->needRepositories(true)->executeOne();
     if (!$book) {
         return new Aphront404Response();
     }
     $actions = $this->buildActionView($viewer, $book);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->setBorder(true);
     $crumbs->addTextCrumb($book->getShortTitle(), '/book/' . $book->getName() . '/');
     $action_button = id(new PHUIButtonView())->setTag('a')->setText(pht('Actions'))->setHref('#')->setIconFont('fa-bars')->addClass('phui-mobile-menu')->setDropdownMenu($actions);
     $header = id(new PHUIHeaderView())->setHeader($book->getTitle())->setUser($viewer)->setPolicyObject($book)->setEpoch($book->getDateModified())->addActionLink($action_button);
     // TODO: This could probably look better.
     if ($book->getRepositoryPHID()) {
         $header->addTag(id(new PHUITagView())->setType(PHUITagView::TYPE_STATE)->setBackgroundColor(PHUITagView::COLOR_BLUE)->setName($book->getRepository()->getMonogram()));
     }
     $document = new PHUIDocumentView();
     $document->setHeader($header);
     $document->addClass('diviner-view');
     $document->setFontKit(PHUIDocumentView::FONT_SOURCE_SANS);
     $atoms = id(new DivinerAtomQuery())->setViewer($viewer)->withBookPHIDs(array($book->getPHID()))->withGhosts(false)->withIsDocumentable(true)->execute();
     $atoms = msort($atoms, 'getSortKey');
     $group_spec = $book->getConfig('groups');
     if (!is_array($group_spec)) {
         $group_spec = array();
     }
     $groups = mgroup($atoms, 'getGroupName');
     $groups = array_select_keys($groups, array_keys($group_spec)) + $groups;
     if (isset($groups[''])) {
         $no_group = $groups[''];
         unset($groups['']);
         $groups[''] = $no_group;
     }
     $out = array();
     foreach ($groups as $group => $atoms) {
         $group_name = $book->getGroupName($group);
         if (!strlen($group_name)) {
             $group_name = pht('Free Radicals');
         }
         $section = id(new DivinerSectionView())->setHeader($group_name);
         $section->addContent($this->renderAtomList($atoms));
         $out[] = $section;
     }
     $preface = $book->getPreface();
     $preface_view = null;
     if (strlen($preface)) {
         $preface_view = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($preface), 'default', $viewer);
     }
     $document->appendChild($preface_view);
     $document->appendChild($out);
     return $this->buildApplicationPage(array($crumbs, $document), array('title' => $book->getTitle()));
 }
开发者ID:hrb518,项目名称:phabricator,代码行数:54,代码来源:DivinerBookController.php

示例13: didFilterPage

 protected function didFilterPage(array $hunks)
 {
     if ($this->shouldAttachToChangesets) {
         $hunk_groups = mgroup($hunks, 'getChangesetID');
         foreach ($this->changesets as $changeset) {
             $hunks = idx($hunk_groups, $changeset->getID(), array());
             $changeset->attachHunks($hunks);
         }
     }
     return $hunks;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:11,代码来源:DifferentialHunkQuery.php

示例14: handlePropertyEvent

 private function handlePropertyEvent($ui_event)
 {
     $user = $ui_event->getUser();
     $object = $ui_event->getValue('object');
     if (!$object || !$object->getPHID()) {
         // No object, or the object has no PHID yet..
         return;
     }
     if (!$object instanceof PhrequentTrackableInterface) {
         // This object isn't a time trackable object.
         return;
     }
     if (!$this->canUseApplication($ui_event->getUser())) {
         return;
     }
     $events = id(new PhrequentUserTimeQuery())->setViewer($user)->withObjectPHIDs(array($object->getPHID()))->needPreemptingEvents(true)->execute();
     $event_groups = mgroup($events, 'getUserPHID');
     if (!$events) {
         return;
     }
     $handles = id(new PhabricatorHandleQuery())->setViewer($user)->withPHIDs(array_keys($event_groups))->execute();
     $status_view = new PHUIStatusListView();
     foreach ($event_groups as $user_phid => $event_group) {
         $item = new PHUIStatusItemView();
         $item->setTarget($handles[$user_phid]->renderLink());
         $state = 'stopped';
         foreach ($event_group as $event) {
             if ($event->getDateEnded() === null) {
                 if ($event->isPreempted()) {
                     $state = 'suspended';
                 } else {
                     $state = 'active';
                     break;
                 }
             }
         }
         switch ($state) {
             case 'active':
                 $item->setIcon(PHUIStatusItemView::ICON_CLOCK, 'green', pht('Working Now'));
                 break;
             case 'suspended':
                 $item->setIcon(PHUIStatusItemView::ICON_CLOCK, 'yellow', pht('Interrupted'));
                 break;
             case 'stopped':
                 $item->setIcon(PHUIStatusItemView::ICON_CLOCK, 'bluegrey', pht('Not Working Now'));
                 break;
         }
         $block = new PhrequentTimeBlock($event_group);
         $item->setNote(phutil_format_relative_time($block->getTimeSpentOnObject($object->getPHID(), time())));
         $status_view->addItem($item);
     }
     $view = $ui_event->getValue('view');
     $view->addProperty(pht('Time Spent'), $status_view);
 }
开发者ID:pugong,项目名称:phabricator,代码行数:54,代码来源:PhrequentUIEventListener.php

示例15: didFilterPage

 protected function didFilterPage(array $carts)
 {
     if ($this->needPurchases) {
         $purchases = id(new PhortunePurchaseQuery())->setViewer($this->getViewer())->setParentQuery($this)->withCartPHIDs(mpull($carts, 'getPHID'))->execute();
         $purchases = mgroup($purchases, 'getCartPHID');
         foreach ($carts as $cart) {
             $cart->attachPurchases(idx($purchases, $cart->getPHID(), array()));
         }
     }
     return $carts;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:11,代码来源:PhortuneCartQuery.php


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