DigiComp.Menu/Classes/MenuService/SettingsService.php

64 lines
1.5 KiB
PHP
Raw Permalink Normal View History

<?php
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;
use Neos\Flow\Configuration\ConfigurationManager;
/**
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
{
/**
* @var \Neos\Flow\Configuration\ConfigurationManager
*/
protected $configurationManager;
2017-06-03 11:39:59 +02:00
public function injectConfigurationManager(ConfigurationManager $configurationManager)
{
$this->configurationManager = $configurationManager;
2017-06-03 11:39:59 +02:00
$this->menuConfiguration = $this->configurationManager->getConfiguration('Menu');
}
/**
* @var array
*/
2017-06-03 11:39:59 +02:00
protected $menuConfiguration;
2017-06-03 11:39:59 +02:00
/**
* @var array
*/
protected $items = array();
2017-06-03 11:39:59 +02:00
/**
* @param string $forMenu
* @return array
*/
public function getItems($forMenu = null)
{
if ($forMenu) {
$items = &$this->menuConfiguration[$forMenu];
2017-06-03 11:48:32 +02:00
} else {
2017-06-03 11:39:59 +02:00
$items = &$this->menuConfiguration;
}
if ($items) {
uasort(
$items, function ($a, $b) {
return $a['sorting'] > $b['sorting'];
}
);
}
return $items;
}
}