mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 23:52:49 +08:00
改进分页类和数据集类的each方法
This commit is contained in:
@@ -189,8 +189,11 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
|
|||||||
public function each(callable $callback)
|
public function each(callable $callback)
|
||||||
{
|
{
|
||||||
foreach ($this->items as $key => $item) {
|
foreach ($this->items as $key => $item) {
|
||||||
if ($callback($item, $key) === false) {
|
$result = $callback($item, $key);
|
||||||
|
if (false === $result) {
|
||||||
break;
|
break;
|
||||||
|
} elseif (!is_object($item)) {
|
||||||
|
$this->items[$key] = $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -288,8 +288,11 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J
|
|||||||
public function each(callable $callback)
|
public function each(callable $callback)
|
||||||
{
|
{
|
||||||
foreach ($this->items as $key => $item) {
|
foreach ($this->items as $key => $item) {
|
||||||
if ($callback($item, $key) === false) {
|
$result = $callback($item, $key);
|
||||||
|
if (false === $result) {
|
||||||
break;
|
break;
|
||||||
|
} elseif (!is_object($item)) {
|
||||||
|
$this->items[$key] = $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user