本文整理汇总了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;
}
示例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;
}
示例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;
}