Adjusting interface and implementation to use \Iterator instead of array
This commit is contained in:
parent
6339e96084
commit
27bfb049f3
2 changed files with 3 additions and 7 deletions
|
@ -22,5 +22,5 @@ interface ServiceInterface
|
||||||
*
|
*
|
||||||
* @return array|\Iterator
|
* @return array|\Iterator
|
||||||
*/
|
*/
|
||||||
public function getItems(string $forPath = null): array;
|
public function getItems(string $forPath = null): \Iterator;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,11 +32,7 @@ class SettingsService implements ServiceInterface
|
||||||
*/
|
*/
|
||||||
protected array $items = array();
|
protected array $items = array();
|
||||||
|
|
||||||
/**
|
public function getItems(string $forPath = null): \Iterator
|
||||||
* @param string|null $forPath
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getItems(string $forPath = null): array
|
|
||||||
{
|
{
|
||||||
if ($forPath) {
|
if ($forPath) {
|
||||||
$items = &$this->menuConfiguration[$forPath];
|
$items = &$this->menuConfiguration[$forPath];
|
||||||
|
@ -51,6 +47,6 @@ class SettingsService implements ServiceInterface
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $items;
|
return new \ArrayIterator($items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue