当前位置: 首页>>代码示例>>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;未经允许,请勿转载。