DigiComp.Menu/Classes/MenuService/SettingsService.php

56 lines
1.2 KiB
PHP

<?php
namespace DigiComp\Menu\MenuService;
/*
* 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;
/**
* @package DigiComp\Menu\Menu
*
* @Flow\Scope("singleton")
*/
class SettingsService implements ServiceInterface
{
/**
* @Flow\InjectConfiguration(type="Menu")
* @var array
*/
protected array $menuConfiguration;
/**
* @var array
*/
protected array $items = array();
/**
* @param string|null $forPath
* @return array
*/
public function getItems(string $forPath = null): array
{
if ($forPath) {
$items = &$this->menuConfiguration[$forPath];
} else {
$items = &$this->menuConfiguration;
}
if ($items) {
uasort(
$items,
function ($a, $b) {
return $a['sorting'] > $b['sorting'];
}
);
}
return $items;
}
}