DigiComp.Menu/Classes/MenuService/SettingsService.php

57 lines
1.2 KiB
PHP
Raw Normal View History

<?php
2021-05-12 02:01:22 +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.
*/
use Neos\Flow\Annotations as Flow;
/**
2014-07-08 09:02:34 +02:00
* @package DigiComp\Menu\Menu
*
* @Flow\Scope("singleton")
*/
2017-06-03 11:39:59 +02:00
class SettingsService implements ServiceInterface
{
/**
* @Flow\InjectConfiguration(type="Menu")
* @var array
*/
protected array $menuConfiguration;
2017-06-03 11:39:59 +02:00
/**
* @var array
*/
protected array $items = array();
2017-06-03 11:39:59 +02:00
/**
* @param string|null $forPath
2017-06-03 11:39:59 +02:00
* @return array
*/
public function getItems(string $forPath = null): array
2017-06-03 11:39:59 +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) {
uasort(
2021-05-12 02:01:22 +02:00
$items,
function ($a, $b) {
2017-06-03 11:39:59 +02:00
return $a['sorting'] > $b['sorting'];
}
);
}
return $items;
}
2021-05-12 02:01:22 +02:00
}