DigiComp.Menu/Classes/DigiComp/Menu/MenuService/SettingsService.php

53 lines
No EOL
1.3 KiB
PHP

<?php
namespace DigiComp\Menu\MenuService;
/* *
* This script belongs to the FLOW3 package "DigiComp.Controls". *
* *
* */
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Configuration\ConfigurationManager;
/**
* Class Menu
* @package DigiComp\Controls\Menu
*
* @Flow\Scope("singleton")
*/
class SettingsService implements ServiceInterface {
/**
* @var \TYPO3\Flow\Configuration\ConfigurationManager
*/
protected $configurationManager;
public function injectConfigurationManager(ConfigurationManager $configurationManager) {
$this->configurationManager = $configurationManager;
$this->menu = $this->configurationManager->getConfiguration('Menu');
}
/**
* @var array
*/
protected $menu;
protected $items = array();
/**
* @param string $forMenu
* @return array
*/
public function getItems($forMenu = NULL) {
if ($forMenu){
$items = &$this->menu[$forMenu];
}else {
$items = &$this->menu;
}
if ($items) {
uasort($items, function ($a, $b) {
return $a['sorting'] > $b['sorting'];
});
}
return $items;
}
}