Merge branch 'feature/flow-6.3' into develop

This commit is contained in:
Ferdinand Kuhl 2021-08-26 11:19:49 +02:00
commit 5baf0c080c
7 changed files with 82 additions and 70 deletions

View file

@ -1,4 +1,5 @@
<?php
namespace DigiComp\Menu\MenuService;
/*
@ -16,11 +17,10 @@ namespace DigiComp\Menu\MenuService;
*/
interface ServiceInterface
{
/**
* @param mixed $forPath
* @param string|null $forPath
*
* @return array|\Iterator
*/
public function getItems($forPath = null);
public function getItems(string $forPath = null): \Iterator;
}

View file

@ -1,4 +1,5 @@
<?php
namespace DigiComp\Menu\MenuService;
/*
@ -12,7 +13,6 @@ namespace DigiComp\Menu\MenuService;
*/
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Configuration\ConfigurationManager;
/**
* @package DigiComp\Menu\Menu
@ -22,43 +22,31 @@ use Neos\Flow\Configuration\ConfigurationManager;
class SettingsService implements ServiceInterface
{
/**
* @var \Neos\Flow\Configuration\ConfigurationManager
* @Flow\InjectConfiguration(type="Menu")
* @var array
*/
protected $configurationManager;
public function injectConfigurationManager(ConfigurationManager $configurationManager)
{
$this->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);
}
}

View file

@ -1,4 +1,5 @@
<?php
namespace DigiComp\Menu;
/*
@ -20,14 +21,14 @@ use Neos\Flow\Configuration\ConfigurationManager;
*/
class Package extends BasePackage
{
public function boot(Bootstrap $bootstrap)
{
parent::boot($bootstrap);
$dispatcher = $bootstrap->getSignalSlotDispatcher();
$dispatcher->connect(
'Neos\Flow\Configuration\ConfigurationManager', 'configurationManagerReady',
ConfigurationManager::class,
'configurationManagerReady',
function (ConfigurationManager $configurationManager) {
$configurationManager->registerConfigurationType('Menu');
}

View file

@ -1,4 +1,5 @@
<?php
namespace DigiComp\Menu\ViewHelpers;
/*
@ -11,8 +12,10 @@ namespace DigiComp\Menu\ViewHelpers;
* source code.
*/
use DigiComp\Menu\MenuService\ServiceInterface;
use Neos\Flow\Annotations as Flow;
use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper;
use Neos\FluidAdaptor\Core\ViewHelper\Exception;
/**
* Just adds the return of MenuService
@ -20,23 +23,32 @@ use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper;
*/
class ItemsViewHelper extends AbstractViewHelper
{
protected $escapeOutput = false;
/**
* @var \DigiComp\Menu\MenuService\ServiceInterface
* @Flow\Inject
* @var ServiceInterface
*/
protected $menuService;
/**
* @param string $as
* @param string $for
* @return string
* @throws Exception
*/
public function render($as = 'items', $for = null)
public function initializeArguments(): void
{
$this->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();
}
}

View file

@ -1,4 +1,5 @@
<?php
namespace DigiComp\Menu\ViewHelpers;
/*
@ -12,41 +13,47 @@ namespace DigiComp\Menu\ViewHelpers;
*/
use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper;
use Neos\FluidAdaptor\Core\ViewHelper\Exception;
/**
* Helps to get useful template variables for process menus
*/
class ProgressViewHelper extends AbstractViewHelper
{
protected $escapeOutput = false;
/**
* @param array $links
* @param int $activeStep
* @param bool $returnable
* @param string $stepsAs
* @param string $backLinkAs
* @param string $activeStepAs
* @param string $linksAs
* @param string $activeStepLinkAs
* @param int $offset
* @param int $linkCount if given overrides count($links)
*
* @return string
* @throws Exception
*/
public function render(
array $links,
$activeStep = 1,
$returnable = true,
$stepsAs = 'steps',
$backLinkAs = 'backLink',
$activeStepAs = 'activeStep',
$linksAs = 'links',
$activeStepLinkAs = 'activeStepLink',
$offset = 1,
$linkCount = null
) {
public function initializeArguments(): void
{
$this->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

View file

@ -1,4 +1,4 @@
Copyright (c) 2016 Ferdinand Kuhl <f.kuhl@digital-competence.de>
Copyright (c) 2021 Ferdinand Kuhl <f.kuhl@digital-competence.de>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -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"
]
}
}