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


PHP PhabricatorSpacesNamespaceQuery::getViewerActiveSpaces方法代码示例

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


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

示例1: validateSpaceTransactions

 private function validateSpaceTransactions(PhabricatorLiskDAO $object, array $xactions, $transaction_type)
 {
     $errors = array();
     $actor = $this->getActor();
     $has_spaces = PhabricatorSpacesNamespaceQuery::getViewerSpacesExist($actor);
     $actor_spaces = PhabricatorSpacesNamespaceQuery::getViewerSpaces($actor);
     $active_spaces = PhabricatorSpacesNamespaceQuery::getViewerActiveSpaces($actor);
     foreach ($xactions as $xaction) {
         $space_phid = $xaction->getNewValue();
         if ($space_phid === null) {
             if (!$has_spaces) {
                 // The install doesn't have any spaces, so this is fine.
                 continue;
             }
             // The install has some spaces, so every object needs to be put
             // in a valid space.
             $errors[] = new PhabricatorApplicationTransactionValidationError($transaction_type, pht('Invalid'), pht('You must choose a space for this object.'), $xaction);
             continue;
         }
         // If the PHID isn't `null`, it needs to be a valid space that the
         // viewer can see.
         if (empty($actor_spaces[$space_phid])) {
             $errors[] = new PhabricatorApplicationTransactionValidationError($transaction_type, pht('Invalid'), pht('You can not shift this object in the selected space, because ' . 'the space does not exist or you do not have access to it.'), $xaction);
         } else {
             if (empty($active_spaces[$space_phid])) {
                 // It's OK to edit objects in an archived space, so just move on if
                 // we aren't adjusting the value.
                 $old_space_phid = $this->getTransactionOldValue($object, $xaction);
                 if ($space_phid == $old_space_phid) {
                     continue;
                 }
                 $errors[] = new PhabricatorApplicationTransactionValidationError($transaction_type, pht('Archived'), pht('You can not shift this object into the selected space, because ' . 'the space is archived. Objects can not be created inside (or ' . 'moved into) archived spaces.'), $xaction);
             }
         }
     }
     return $errors;
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:37,代码来源:PhabricatorApplicationTransactionEditor.php

示例2: getDefaultSpacePHID

 public function getDefaultSpacePHID()
 {
     // TODO: We might let the user switch which space they're "in" later on;
     // for now just use the global space if one exists.
     // If the viewer has access to the default space, use that.
     $spaces = PhabricatorSpacesNamespaceQuery::getViewerActiveSpaces($this);
     foreach ($spaces as $space) {
         if ($space->getIsDefaultNamespace()) {
             return $space->getPHID();
         }
     }
     // Otherwise, use the space with the lowest ID that they have access to.
     // This just tends to keep the default stable and predictable over time,
     // so adding a new space won't change behavior for users.
     if ($spaces) {
         $spaces = msort($spaces, 'getID');
         return head($spaces)->getPHID();
     }
     return null;
 }
开发者ID:demon,项目名称:phabricator,代码行数:20,代码来源:PhabricatorUser.php


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