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

View file

@ -1,4 +1,5 @@
<?php <?php
namespace DigiComp\Menu\MenuService; namespace DigiComp\Menu\MenuService;
/* /*
@ -12,7 +13,6 @@ namespace DigiComp\Menu\MenuService;
*/ */
use Neos\Flow\Annotations as Flow; use Neos\Flow\Annotations as Flow;
use Neos\Flow\Configuration\ConfigurationManager;
/** /**
* @package DigiComp\Menu\Menu * @package DigiComp\Menu\Menu
@ -22,43 +22,31 @@ use Neos\Flow\Configuration\ConfigurationManager;
class SettingsService implements ServiceInterface class SettingsService implements ServiceInterface
{ {
/** /**
* @var \Neos\Flow\Configuration\ConfigurationManager * @Flow\InjectConfiguration(type="Menu")
* @var array
*/ */
protected $configurationManager; protected array $menuConfiguration;
public function injectConfigurationManager(ConfigurationManager $configurationManager)
{
$this->configurationManager = $configurationManager;
$this->menuConfiguration = $this->configurationManager->getConfiguration('Menu');
}
/** /**
* @var array * @var array
*/ */
protected $menuConfiguration; protected array $items = array();
/** public function getItems(string $forPath = null): \Iterator
* @var array
*/
protected $items = array();
/**
* @param string $forMenu
* @return array
*/
public function getItems($forMenu = null)
{ {
if ($forMenu) { if ($forPath) {
$items = &$this->menuConfiguration[$forMenu]; $items = &$this->menuConfiguration[$forPath];
} else { } else {
$items = &$this->menuConfiguration; $items = &$this->menuConfiguration;
} }
if ($items) { if ($items) {
uasort( uasort(
$items, function ($a, $b) { $items,
function ($a, $b) {
return $a['sorting'] > $b['sorting']; return $a['sorting'] > $b['sorting'];
} }
); );
} }
return $items; return new \ArrayIterator($items);
} }
} }

View file

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

View file

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

View file

@ -1,4 +1,5 @@
<?php <?php
namespace DigiComp\Menu\ViewHelpers; namespace DigiComp\Menu\ViewHelpers;
/* /*
@ -12,41 +13,47 @@ namespace DigiComp\Menu\ViewHelpers;
*/ */
use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper; use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper;
use Neos\FluidAdaptor\Core\ViewHelper\Exception;
/** /**
* Helps to get useful template variables for process menus * Helps to get useful template variables for process menus
*/ */
class ProgressViewHelper extends AbstractViewHelper class ProgressViewHelper extends AbstractViewHelper
{ {
protected $escapeOutput = false; protected $escapeOutput = false;
/** /**
* @param array $links * @throws Exception
* @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
*/ */
public function render( public function initializeArguments(): void
array $links, {
$activeStep = 1, $this->registerArgument('for', 'string', 'path in Menu.yaml', false);
$returnable = true, $this->registerArgument('as', 'string', 'Name in Frontend', false);
$stepsAs = 'steps', $this->registerArgument('links', 'array', 'links to show', true);
$backLinkAs = 'backLink', $this->registerArgument('activeStep', 'int', 'current active link index', false, 1);
$activeStepAs = 'activeStep', $this->registerArgument('returnable', 'bool', 'can you go back to the last index', false, true);
$linksAs = 'links', $this->registerArgument('stepsAs', 'string', 'variable name of a single step', false, 'steps');
$activeStepLinkAs = 'activeStepLink', $this->registerArgument('backLinkAs', 'string', 'variable name of a backlink', false, 'backLink');
$offset = 1, $this->registerArgument('linksAs', 'string', 'variable name of the links array', false, 'links');
$linkCount = null $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 //handling famous off by one
$activeStep -= $offset; $activeStep -= $offset;
//make sure our array index is numeric //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 Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.

View file

@ -1,6 +1,6 @@
{ {
"name": "digicomp/menu", "name": "digicomp/menu",
"type": "typo3-flow-package", "type": "neos-package",
"description": "Helps with the creation of simple fluid based menus", "description": "Helps with the creation of simple fluid based menus",
"keywords": [ "keywords": [
"flow", "flow",
@ -16,9 +16,10 @@
} }
], ],
"license": "MIT", "license": "MIT",
"homepage": "https://github.com/digicomp/DigiComp.Sequence", "homepage": "https://github.com/digicomp/DigiComp.Menu",
"require": { "require": {
"neos/flow": "~4.0" "neos/flow": "~6.3",
"php": "^7.4"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
@ -27,7 +28,8 @@
}, },
"extra": { "extra": {
"branch-alias": { "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": [ "applied-flow-migrations": [
"TYPO3.Fluid-20150214130800", "TYPO3.Fluid-20150214130800",
@ -60,7 +62,9 @@
"TYPO3.FluidAdaptor-20161130112935", "TYPO3.FluidAdaptor-20161130112935",
"Neos.Media-20161219094126", "Neos.Media-20161219094126",
"Neos.Flow-20170125103800", "Neos.Flow-20170125103800",
"Neos.Flow-20170127183102" "Neos.Flow-20170127183102",
"DigiComp.SettingValidator-20170603120900",
"Neos.Flow-20180415105700"
] ]
} }
} }