Initial Menu Functions (originally found in DigiComp.Controls)
This commit is contained in:
parent
d0d1541344
commit
6301329853
5 changed files with 125 additions and 0 deletions
15
Classes/DigiComp/Menu/MenuService/ServiceInterface.php
Normal file
15
Classes/DigiComp/Menu/MenuService/ServiceInterface.php
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
namespace DigiComp\Menu\MenuService;
|
||||
/* *
|
||||
* This script belongs to the FLOW3 package "DigiComp.Controls". *
|
||||
* *
|
||||
* */
|
||||
|
||||
/**
|
||||
* Interface for Menu-Configuration
|
||||
*/
|
||||
interface ServiceInterface {
|
||||
|
||||
public function getItems();
|
||||
|
||||
}
|
53
Classes/DigiComp/Menu/MenuService/SettingsService.php
Normal file
53
Classes/DigiComp/Menu/MenuService/SettingsService.php
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?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;
|
||||
}
|
||||
|
||||
|
||||
}
|
25
Classes/DigiComp/Menu/Package.php
Normal file
25
Classes/DigiComp/Menu/Package.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
/**
|
||||
* @author skoetzing
|
||||
* @date 07.07.14
|
||||
*/
|
||||
|
||||
namespace DigiComp\Menu;
|
||||
use TYPO3\Flow\Core\Bootstrap;
|
||||
use TYPO3\Flow\Package\Package as BasePackage;
|
||||
use TYPO3\Flow\Annotations as Flow;
|
||||
use TYPO3\Flow\Configuration\ConfigurationManager;
|
||||
|
||||
class Package extends BasePackage{
|
||||
|
||||
public function boot(Bootstrap $bootstrap){
|
||||
parent::boot($bootstrap);
|
||||
|
||||
$dispatcher = $bootstrap->getSignalSlotDispatcher();
|
||||
$dispatcher->connect('TYPO3\Flow\Configuration\ConfigurationManager', 'configurationManagerReady',
|
||||
function(ConfigurationManager $configurationManager){
|
||||
$configurationManager->registerConfigurationType('Menu');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
30
Classes/DigiComp/Menu/ViewHelpers/MenuViewHelper.php
Normal file
30
Classes/DigiComp/Menu/ViewHelpers/MenuViewHelper.php
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
namespace DigiComp\Menu\ViewHelpers;
|
||||
/* *
|
||||
* This script belongs to the FLOW3 package "DigiComp.Controls". *
|
||||
* *
|
||||
* */
|
||||
use TYPO3\Flow\Annotations as Flow;
|
||||
/**
|
||||
* Renders the sum of given collection and property name
|
||||
*/
|
||||
class MenuViewHelper extends \TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper {
|
||||
|
||||
/**
|
||||
* @var \DigiComp\Menu\MenuService\ServiceInterface
|
||||
* @Flow\Inject
|
||||
*/
|
||||
protected $menuService;
|
||||
|
||||
/**
|
||||
* @param string $as
|
||||
* @param string $forPath
|
||||
* @return mixed
|
||||
*/
|
||||
public function render($as = 'menuItems', $forPath = NULL) {
|
||||
$this->templateVariableContainer->add($as, $this->menuService->getItems($forPath));
|
||||
return $this->renderChildren();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
2
Configuration/Objects.yaml
Normal file
2
Configuration/Objects.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
DigiComp\Controls\Menu\ServiceInterface:
|
||||
className: DigiComp\Controls\Menu\SettingsService
|
Loading…
Reference in a new issue