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


PHP xPDO::getIterator方法代碼示例

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


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

示例1: getIterator

 /**
  * Get an xPDOIterator for a collection of objects related by aggregate or composite relations.
  *
  * @param string $alias The alias of the relation.
  * @param null|array|xPDOCriteria $criteria A valid xPDO criteria expression.
  * @param bool|int $cacheFlag Indicates if the objects should be cached and optionally, by
  * specifying  an integer values, for how many seconds.
  * @return bool|xPDOIterator An iterator for the collection or false if no relation is found.
  */
 public function getIterator($alias, $criteria = null, $cacheFlag = true)
 {
     $iterator = false;
     $fkMeta = $this->getFKDefinition($alias);
     if ($fkMeta) {
         $fkCriteria = isset($fkMeta['criteria']) && isset($fkMeta['criteria']['foreign']) ? $fkMeta['criteria']['foreign'] : null;
         if ($criteria === null) {
             $criteria = array($fkMeta['foreign'] => $this->get($fkMeta['local']));
             if ($fkCriteria !== null) {
                 $criteria = array($fkCriteria, $criteria);
             }
         } else {
             $criteria = $this->xpdo->newQuery($fkMeta['class'], $criteria);
             $addCriteria = array("{$criteria->getAlias()}.{$fkMeta['foreign']}" => $this->get($fkMeta['local']));
             if ($fkCriteria !== null) {
                 $fkAddCriteria = array();
                 foreach ($fkCriteria as $fkCritKey => $fkCritVal) {
                     if (is_numeric($fkCritKey)) {
                         continue;
                     }
                     $fkAddCriteria["{$criteria->getAlias()}.{$fkCritKey}"] = $fkCritVal;
                 }
                 if (!empty($fkAddCriteria)) {
                     $addCriteria = array($fkAddCriteria, $addCriteria);
                 }
             }
             $criteria->andCondition($addCriteria);
         }
         $iterator = $this->xpdo->getIterator($fkMeta['class'], $criteria, $cacheFlag);
     }
     return $iterator;
 }
開發者ID:e-gob,項目名稱:apps.gob.cl,代碼行數:41,代碼來源:xpdoobject.class.php

示例2: getIterator

 /**
  * Get an xPDOIterator for a collection of objects related by aggregate or composite relations.
  *
  * @param string $alias The alias of the relation.
  * @param null|array|xPDOCriteria $criteria A valid xPDO criteria expression.
  * @param bool|int $cacheFlag Indicates if the objects should be cached and optionally, by
  * specifying  an integer values, for how many seconds.
  * @return bool|xPDOIterator An iterator for the collection or false if no relation is found.
  */
 public function getIterator($alias, $criteria = null, $cacheFlag = true)
 {
     $iterator = false;
     $fkMeta = $this->getFKDefinition($alias);
     if ($fkMeta) {
         if ($criteria === null) {
             $criteria = array($fkMeta['foreign'] => $this->get($fkMeta['local']));
         } else {
             $criteria = $this->xpdo->newQuery($fkMeta['class'], $criteria);
             $criteria->andCondition(array("{$criteria->getAlias()}.{$fkMeta['foreign']}" => $this->get($fkMeta['local'])));
         }
         $iterator = $this->xpdo->getIterator($fkMeta['class'], $criteria, $cacheFlag);
     }
     return $iterator;
 }
開發者ID:rosstimson,項目名稱:revolution,代碼行數:24,代碼來源:xpdoobject.class.php

示例3: findResolution

 /**
  * Search for package to satisfy a dependency.
  *
  * @param string $package The name of the dependent package.
  * @param string $constraint The version constraint the package must satisfy.
  * @param modTransportProvider|null $provider A reference which is set to the
  * modTransportProvider which satisfies the dependency.
  *
  * @return array|bool The metadata for the package version which satisfies the dependency, or FALSE.
  */
 public function findResolution($package, $constraint, &$provider = null)
 {
     $resolution = false;
     $conditions = array('active' => true);
     switch (strtolower($package)) {
         case 'php':
             /* you must resolve php dependencies manually */
             $this->xpdo->log(xPDO::LOG_LEVEL_WARN, "PHP version dependencies must be resolved manually", '', __METHOD__, __FILE__, __LINE__);
             break;
         case 'modx':
         case 'revo':
         case 'revolution':
             /* resolve core dependencies manually for now */
             $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, "MODX core version dependencies must be resolved manually", '', __METHOD__, __FILE__, __LINE__);
             break;
         default:
             /* TODO: scan for local packages to satisfy dependency */
             /* see if current provider can satisfy dependency */
             /** @var modTransportProvider $provider */
             $provider = $this->Provider;
             if ($provider) {
                 $resolution = $provider->latest($package, $constraint);
             }
             /* loop through active providers if all else fails */
             if ($resolution === false) {
                 $query = $this->xpdo->newQuery('transport.modTransportProvider', $conditions);
                 $query->sortby('priority', 'ASC');
                 /** @var modTransportProvider $p */
                 foreach ($this->xpdo->getIterator('transport.modTransportProvider', $query) as $p) {
                     $resolution = $p->latest($package, $constraint);
                     if ($resolution) {
                         $provider = $p;
                         break;
                     }
                 }
             }
             if ($resolution === false) {
                 $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, "Could not find package to satisfy dependency {$package} @ {$constraint} from your currently active providers", '', __METHOD__, __FILE__, __LINE__);
             }
             break;
     }
     return $resolution;
 }
開發者ID:ChrstnMgcn,項目名稱:revolution,代碼行數:53,代碼來源:modtransportpackage.class.php


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