2014-07-07 15:49:44 +02:00
|
|
|
<?php
|
2021-05-12 02:01:22 +02:00
|
|
|
|
2014-07-07 15:49:44 +02:00
|
|
|
namespace DigiComp\Menu\MenuService;
|
2017-06-03 11:39:59 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the DigiComp.Menu package.
|
|
|
|
*
|
|
|
|
* (c) digital competence
|
|
|
|
*
|
|
|
|
* This package is Open Source Software. For the full copyright and license
|
|
|
|
* information, please view the LICENSE file which was distributed with this
|
|
|
|
* source code.
|
|
|
|
*/
|
2014-07-07 15:49:44 +02:00
|
|
|
|
2017-06-03 11:53:57 +02:00
|
|
|
use Neos\Flow\Annotations as Flow;
|
2014-07-07 15:49:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @Flow\Scope("singleton")
|
|
|
|
*/
|
2017-06-03 11:39:59 +02:00
|
|
|
class SettingsService implements ServiceInterface
|
|
|
|
{
|
2014-07-07 15:49:44 +02:00
|
|
|
/**
|
2021-05-12 02:26:43 +02:00
|
|
|
* @Flow\InjectConfiguration(type="Menu")
|
2014-07-07 15:49:44 +02:00
|
|
|
* @var array
|
|
|
|
*/
|
2021-05-12 02:26:43 +02:00
|
|
|
protected array $menuConfiguration;
|
2014-07-07 15:49:44 +02:00
|
|
|
|
2017-06-03 11:39:59 +02:00
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
2021-05-12 02:26:43 +02:00
|
|
|
protected array $items = array();
|
2014-07-07 15:49:44 +02:00
|
|
|
|
2021-06-08 18:35:42 +02:00
|
|
|
public function getItems(string $forPath = null): \Iterator
|
2017-06-03 11:39:59 +02:00
|
|
|
{
|
2021-05-12 02:26:43 +02:00
|
|
|
if ($forPath) {
|
|
|
|
$items = &$this->menuConfiguration[$forPath];
|
2017-06-03 11:48:32 +02:00
|
|
|
} else {
|
2017-06-03 11:39:59 +02:00
|
|
|
$items = &$this->menuConfiguration;
|
|
|
|
}
|
|
|
|
if ($items) {
|
2023-02-07 16:44:52 +01:00
|
|
|
\uasort(
|
2021-05-12 02:01:22 +02:00
|
|
|
$items,
|
2023-02-07 16:44:52 +01:00
|
|
|
static function ($a, $b) {
|
2017-06-03 11:39:59 +02:00
|
|
|
return $a['sorting'] > $b['sorting'];
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2021-06-08 18:35:42 +02:00
|
|
|
return new \ArrayIterator($items);
|
2014-07-07 15:49:44 +02:00
|
|
|
}
|
2021-05-12 02:01:22 +02:00
|
|
|
}
|