diff --git a/Classes/MenuService/ServiceInterface.php b/Classes/MenuService/ServiceInterface.php index ae40c38..bb3c892 100644 --- a/Classes/MenuService/ServiceInterface.php +++ b/Classes/MenuService/ServiceInterface.php @@ -1,4 +1,5 @@ configurationManager = $configurationManager; - $this->menuConfiguration = $this->configurationManager->getConfiguration('Menu'); - } + protected array $menuConfiguration; /** * @var array */ - protected $menuConfiguration; + protected array $items = array(); - /** - * @var array - */ - protected $items = array(); - - /** - * @param string $forMenu - * @return array - */ - public function getItems($forMenu = null) + public function getItems(string $forPath = null): \Iterator { - if ($forMenu) { - $items = &$this->menuConfiguration[$forMenu]; + if ($forPath) { + $items = &$this->menuConfiguration[$forPath]; } else { $items = &$this->menuConfiguration; } if ($items) { uasort( - $items, function ($a, $b) { + $items, + function ($a, $b) { return $a['sorting'] > $b['sorting']; } ); } - return $items; + return new \ArrayIterator($items); } -} \ No newline at end of file +} diff --git a/Classes/Package.php b/Classes/Package.php index 4f9ee49..dd0dd7c 100644 --- a/Classes/Package.php +++ b/Classes/Package.php @@ -1,4 +1,5 @@ getSignalSlotDispatcher(); $dispatcher->connect( - 'Neos\Flow\Configuration\ConfigurationManager', 'configurationManagerReady', + ConfigurationManager::class, + 'configurationManagerReady', function (ConfigurationManager $configurationManager) { $configurationManager->registerConfigurationType('Menu'); } ); } -} \ No newline at end of file +} diff --git a/Classes/ViewHelpers/ItemsViewHelper.php b/Classes/ViewHelpers/ItemsViewHelper.php index faa92b6..12ed9a9 100644 --- a/Classes/ViewHelpers/ItemsViewHelper.php +++ b/Classes/ViewHelpers/ItemsViewHelper.php @@ -1,4 +1,5 @@ templateVariableContainer->add($as, $this->menuService->getItems($for)); + $this->registerArgument('for', 'string', 'path in Menu.yaml', false); + $this->registerArgument('as', 'string', 'Name in Frontend', false); + } + + /** + * @return mixed + */ + public function render() + { + $this->templateVariableContainer->add( + $this->arguments['as'], + $this->menuService->getItems($this->arguments['for']) + ); return $this->renderChildren(); } } diff --git a/Classes/ViewHelpers/ProgressViewHelper.php b/Classes/ViewHelpers/ProgressViewHelper.php index c59f8bd..33a7e01 100644 --- a/Classes/ViewHelpers/ProgressViewHelper.php +++ b/Classes/ViewHelpers/ProgressViewHelper.php @@ -1,4 +1,5 @@ registerArgument('for', 'string', 'path in Menu.yaml', false); + $this->registerArgument('as', 'string', 'Name in Frontend', false); + $this->registerArgument('links', 'array', 'links to show', true); + $this->registerArgument('activeStep', 'int', 'current active link index', false, 1); + $this->registerArgument('returnable', 'bool', 'can you go back to the last index', false, true); + $this->registerArgument('stepsAs', 'string', 'variable name of a single step', false, 'steps'); + $this->registerArgument('backLinkAs', 'string', 'variable name of a backlink', false, 'backLink'); + $this->registerArgument('linksAs', 'string', 'variable name of the links array', false, 'links'); + $this->registerArgument( + 'activeStepLinkAs', + 'string', + 'variable name of the active step link', + false, + 'activeStepLink' + ); + $this->registerArgument('offset', 'int', 'offset to start with', false, 1); + $this->registerArgument('linkCount', 'int', 'force this number of steps', false); + } + + /** + * @return mixed + */ + public function render() + { + $links = $activeStep = $returnable = $stepsAs = $backLinkAs = $activeStepAs = $linksAs = + $activeStepLinkAs = $offset = $linkCount = null; + extract($this->arguments); //handling famous off by one $activeStep -= $offset; //make sure our array index is numeric diff --git a/License.txt b/License.txt index 2ffa411..8b9c3be 100644 --- a/License.txt +++ b/License.txt @@ -1,4 +1,4 @@ -Copyright (c) 2016 Ferdinand Kuhl +Copyright (c) 2021 Ferdinand Kuhl Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file +THE SOFTWARE. diff --git a/composer.json b/composer.json index bd7c901..deadeb0 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "digicomp/menu", - "type": "typo3-flow-package", + "type": "neos-package", "description": "Helps with the creation of simple fluid based menus", "keywords": [ "flow", @@ -16,9 +16,10 @@ } ], "license": "MIT", - "homepage": "https://github.com/digicomp/DigiComp.Sequence", + "homepage": "https://github.com/digicomp/DigiComp.Menu", "require": { - "neos/flow": "~4.0" + "neos/flow": "~6.3", + "php": "^7.4" }, "autoload": { "psr-4": { @@ -27,7 +28,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-develop": "3.0.x-dev", + "dev-version/2.x-dev": "2.0.x-dev" }, "applied-flow-migrations": [ "TYPO3.Fluid-20150214130800", @@ -60,7 +62,9 @@ "TYPO3.FluidAdaptor-20161130112935", "Neos.Media-20161219094126", "Neos.Flow-20170125103800", - "Neos.Flow-20170127183102" + "Neos.Flow-20170127183102", + "DigiComp.SettingValidator-20170603120900", + "Neos.Flow-20180415105700" ] } -} \ No newline at end of file +}