From 6301329853641f0db051bda1544bfa59399032ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20K=C3=B6tzing?= Date: Mon, 7 Jul 2014 15:49:44 +0200 Subject: [PATCH] Initial Menu Functions (originally found in DigiComp.Controls) --- .../Menu/MenuService/ServiceInterface.php | 15 ++++++ .../Menu/MenuService/SettingsService.php | 53 +++++++++++++++++++ Classes/DigiComp/Menu/Package.php | 25 +++++++++ .../Menu/ViewHelpers/MenuViewHelper.php | 30 +++++++++++ Configuration/Objects.yaml | 2 + 5 files changed, 125 insertions(+) create mode 100644 Classes/DigiComp/Menu/MenuService/ServiceInterface.php create mode 100644 Classes/DigiComp/Menu/MenuService/SettingsService.php create mode 100644 Classes/DigiComp/Menu/Package.php create mode 100644 Classes/DigiComp/Menu/ViewHelpers/MenuViewHelper.php create mode 100644 Configuration/Objects.yaml diff --git a/Classes/DigiComp/Menu/MenuService/ServiceInterface.php b/Classes/DigiComp/Menu/MenuService/ServiceInterface.php new file mode 100644 index 0000000..6873d98 --- /dev/null +++ b/Classes/DigiComp/Menu/MenuService/ServiceInterface.php @@ -0,0 +1,15 @@ +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; + } + + +} \ No newline at end of file diff --git a/Classes/DigiComp/Menu/Package.php b/Classes/DigiComp/Menu/Package.php new file mode 100644 index 0000000..a252707 --- /dev/null +++ b/Classes/DigiComp/Menu/Package.php @@ -0,0 +1,25 @@ +getSignalSlotDispatcher(); + $dispatcher->connect('TYPO3\Flow\Configuration\ConfigurationManager', 'configurationManagerReady', + function(ConfigurationManager $configurationManager){ + $configurationManager->registerConfigurationType('Menu'); + }); + } + +} \ No newline at end of file diff --git a/Classes/DigiComp/Menu/ViewHelpers/MenuViewHelper.php b/Classes/DigiComp/Menu/ViewHelpers/MenuViewHelper.php new file mode 100644 index 0000000..2656162 --- /dev/null +++ b/Classes/DigiComp/Menu/ViewHelpers/MenuViewHelper.php @@ -0,0 +1,30 @@ +templateVariableContainer->add($as, $this->menuService->getItems($forPath)); + return $this->renderChildren(); + } +} + +?> \ No newline at end of file diff --git a/Configuration/Objects.yaml b/Configuration/Objects.yaml new file mode 100644 index 0000000..53e3ed5 --- /dev/null +++ b/Configuration/Objects.yaml @@ -0,0 +1,2 @@ +DigiComp\Controls\Menu\ServiceInterface: + className: DigiComp\Controls\Menu\SettingsService \ No newline at end of file