DigiComp.Menu/Classes/MenuService/SettingsService.php
2021-05-12 02:01:22 +02:00

66 lines
1.5 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;
use Neos\Flow\Configuration\ConfigurationManager;
/**
* @package DigiComp\Menu\Menu
*
* @Flow\Scope("singleton")
*/
class SettingsService implements ServiceInterface
{
/**
* @var \Neos\Flow\Configuration\ConfigurationManager
*/
protected $configurationManager;
public function injectConfigurationManager(ConfigurationManager $configurationManager)
{
$this->configurationManager = $configurationManager;
$this->menuConfiguration = $this->configurationManager->getConfiguration('Menu');
}
/**
* @var array
*/
protected $menuConfiguration;
/**
* @var array
*/
protected $items = array();
/**
* @param string $forMenu
* @return array
*/
public function getItems($forMenu = null)
{
if ($forMenu) {
$items = &$this->menuConfiguration[$forMenu];
} else {
$items = &$this->menuConfiguration;
}
if ($items) {
uasort(
$items,
function ($a, $b) {
return $a['sorting'] > $b['sorting'];
}
);
}
return $items;
}
}