當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PhabricatorPolicyFilter::raisePolicyExceptions方法代碼示例

本文整理匯總了PHP中PhabricatorPolicyFilter::raisePolicyExceptions方法的典型用法代碼示例。如果您正苦於以下問題:PHP PhabricatorPolicyFilter::raisePolicyExceptions方法的具體用法?PHP PhabricatorPolicyFilter::raisePolicyExceptions怎麽用?PHP PhabricatorPolicyFilter::raisePolicyExceptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PhabricatorPolicyFilter的用法示例。


在下文中一共展示了PhabricatorPolicyFilter::raisePolicyExceptions方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 public final function execute()
 {
     if (!$this->viewer) {
         throw new Exception("Call setViewer() before execute()!");
     }
     $results = array();
     $filter = new PhabricatorPolicyFilter();
     $filter->setViewer($this->viewer);
     $filter->setCapability(PhabricatorPolicyCapability::CAN_VIEW);
     $filter->raisePolicyExceptions($this->raisePolicyExceptions);
     do {
         $page = $this->loadPage();
         $visible = $filter->apply($page);
         foreach ($visible as $key => $result) {
             $results[$key] = $result;
             if ($this->getLimit() && count($results) >= $this->getLimit()) {
                 break 2;
             }
         }
         if (!$this->getLimit() || count($page) < $this->getLimit()) {
             break;
         }
         $this->nextPage($page);
     } while (true);
     return $results;
 }
開發者ID:nexeck,項目名稱:phabricator,代碼行數:26,代碼來源:PhabricatorPolicyQuery.php

示例2: requireCapability

 public static function requireCapability(PhabricatorUser $user, PhabricatorPolicyInterface $object, $capability)
 {
     $filter = new PhabricatorPolicyFilter();
     $filter->setViewer($user);
     $filter->requireCapabilities(array($capability));
     $filter->raisePolicyExceptions(true);
     $filter->apply(array($object));
 }
開發者ID:neoxen,項目名稱:phabricator,代碼行數:8,代碼來源:PhabricatorPolicyFilter.php

示例3: getPolicyFilter

 private function getPolicyFilter()
 {
     $filter = new PhabricatorPolicyFilter();
     $filter->setViewer($this->viewer);
     $capabilities = $this->getRequiredCapabilities();
     $filter->requireCapabilities($capabilities);
     $filter->raisePolicyExceptions($this->shouldRaisePolicyExceptions());
     return $filter;
 }
開發者ID:NeoArmageddon,項目名稱:phabricator,代碼行數:9,代碼來源:PhabricatorPolicyAwareQuery.php

示例4: execute

 /**
  * Execute the query, loading all visible results.
  *
  * @return list<PhabricatorPolicyInterface> Result objects.
  * @task exec
  */
 public final function execute()
 {
     if (!$this->viewer) {
         throw new Exception("Call setViewer() before execute()!");
     }
     $results = array();
     $filter = new PhabricatorPolicyFilter();
     $filter->setViewer($this->viewer);
     if (!$this->capabilities) {
         $capabilities = array(PhabricatorPolicyCapability::CAN_VIEW);
     } else {
         $capabilities = $this->capabilities;
     }
     $filter->requireCapabilities($capabilities);
     $filter->raisePolicyExceptions($this->raisePolicyExceptions);
     $offset = (int) $this->getOffset();
     $limit = (int) $this->getLimit();
     $count = 0;
     if ($limit) {
         $need = $offset + $limit;
     } else {
         $need = 0;
     }
     $this->willExecute();
     do {
         if ($need) {
             $this->rawResultLimit = min($need - $count, 1024);
         } else {
             $this->rawResultLimit = 0;
         }
         $page = $this->loadPage();
         $visible = $filter->apply($page);
         foreach ($visible as $key => $result) {
             ++$count;
             // If we have an offset, we just ignore that many results and start
             // storing them only once we've hit the offset. This reduces memory
             // requirements for large offsets, compared to storing them all and
             // slicing them away later.
             if ($count > $offset) {
                 $results[$key] = $result;
             }
             if ($need && $count >= $need) {
                 // If we have all the rows we need, break out of the paging query.
                 break 2;
             }
         }
         if (!$this->rawResultLimit) {
             // If we don't have a load count, we loaded all the results. We do
             // not need to load another page.
             break;
         }
         if (count($page) < $this->rawResultLimit) {
             // If we have a load count but the unfiltered results contained fewer
             // objects, we know this was the last page of objects; we do not need
             // to load another page because we can deduce it would be empty.
             break;
         }
         $this->nextPage($page);
     } while (true);
     return $results;
 }
開發者ID:rudimk,項目名稱:phabricator,代碼行數:67,代碼來源:PhabricatorPolicyAwareQuery.php


注:本文中的PhabricatorPolicyFilter::raisePolicyExceptions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。