本文整理汇总了PHP中DataObjectCollection::filter方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObjectCollection::filter方法的具体用法?PHP DataObjectCollection::filter怎么用?PHP DataObjectCollection::filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataObjectCollection
的用法示例。
在下文中一共展示了DataObjectCollection::filter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseRelations
private function parseRelations()
{
$map = $this->getMap();
$mapFields = $map->getFields();
$relations = array_filter($mapFields, function ($elem) {
return isset($elem['type']) && $elem['type'] == 'relation';
});
if (count($relations) > 0) {
foreach ($relations as $field => $relation) {
$relObjectType = $relation['itemType'];
if (strpos($relObjectType, '\\') === false) {
$refClass = new \ReflectionClass($map->getObject());
$relObjectType = '\\' . $refClass->getNamespaceName() . "\\" . $relObjectType;
}
if (!class_exists($relObjectType)) {
throw new \Exception("Can't find relating type " . $relObjectType);
}
$relCollection = new DataObjectCollection(new $relObjectType());
$relCollection->setMapper($this->mapper);
$conds = array();
foreach ($relation['conditions'] as $key => $fkey) {
if (isset($this->{$key})) {
$conds[$fkey] = $this->{$key};
} else {
throw new \Exception("Can't resolve relation ({$key} => {$fkey}) for " . get_class($this));
}
}
$relCollection->filter($conds);
$this->{$field} = $relCollection;
}
}
}