Compare commits
17 commits
version/2.
...
master
Author | SHA1 | Date | |
---|---|---|---|
c03377c974 | |||
|
f4d3da82a6 | ||
|
e8ea04f323 | ||
f54dded1e0 | |||
b77e4f391b | |||
|
5cbd1340cd | ||
f32f995f43 | |||
13206fec9a | |||
5baf0c080c | |||
07233f7750 | |||
68e35595f3 | |||
6b3f24b0ee | |||
27bfb049f3 | |||
6339e96084 | |||
e436e722c1 | |||
893e6b313a | |||
ac808d34d6 |
7 changed files with 105 additions and 81 deletions
|
@ -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 \Iterator
|
||||||
*/
|
*/
|
||||||
public function getItems($forPath = null);
|
public function getItems(string $forPath = null): \Iterator;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace DigiComp\Menu\MenuService;
|
namespace DigiComp\Menu\MenuService;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -12,53 +13,38 @@ 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
|
|
||||||
*
|
|
||||||
* @Flow\Scope("singleton")
|
* @Flow\Scope("singleton")
|
||||||
*/
|
*/
|
||||||
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 = [];
|
||||||
|
|
||||||
/**
|
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,
|
||||||
|
static function ($a, $b) {
|
||||||
return $a['sorting'] > $b['sorting'];
|
return $a['sorting'] > $b['sorting'];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $items;
|
return new \ArrayIterator($items);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace DigiComp\Menu;
|
namespace DigiComp\Menu;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -11,23 +12,23 @@ namespace DigiComp\Menu;
|
||||||
* source code.
|
* source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Neos\Flow\Configuration\ConfigurationManager;
|
||||||
use Neos\Flow\Core\Bootstrap;
|
use Neos\Flow\Core\Bootstrap;
|
||||||
use Neos\Flow\Package\Package as BasePackage;
|
use Neos\Flow\Package\Package as BasePackage;
|
||||||
use Neos\Flow\Configuration\ConfigurationManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Package base class of the DigiComp.Menu package.
|
* Package base class of the DigiComp.Menu package.
|
||||||
*/
|
*/
|
||||||
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');
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace DigiComp\Menu\ViewHelpers;
|
namespace DigiComp\Menu\ViewHelpers;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -12,47 +13,56 @@ 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, \EXTR_OVERWRITE);
|
||||||
//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
|
||||||
$links = array_values($links);
|
if (\is_iterable($links)) {
|
||||||
|
$links = \iterator_to_array($links);
|
||||||
|
}
|
||||||
|
$links = \array_values($links);
|
||||||
if (!$linkCount) {
|
if (!$linkCount) {
|
||||||
$linkCount = count($links);
|
$linkCount = \count($links);
|
||||||
}
|
}
|
||||||
foreach ($links as $i => &$link) {
|
foreach ($links as $i => &$link) {
|
||||||
$link['completed'] = $activeStep > $i;
|
$link['completed'] = $activeStep > $i;
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -1,33 +1,48 @@
|
||||||
{
|
{
|
||||||
"name": "digicomp/menu",
|
"name": "digicomp/menu",
|
||||||
"type": "typo3-flow-package",
|
|
||||||
"description": "Helps with the creation of simple fluid based menus",
|
"description": "Helps with the creation of simple fluid based menus",
|
||||||
|
"type": "neos-package",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"flow",
|
"Neos",
|
||||||
"neos",
|
"Flow",
|
||||||
"menu"
|
"menu"
|
||||||
],
|
],
|
||||||
|
"homepage": "https://git.digital-competence.de/Packages/DigiComp.Menu",
|
||||||
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Ferdinand Kuhl",
|
"name": "Ferdinand Kuhl",
|
||||||
"email": "f.kuhl@digital-competence.de",
|
"email": "f.kuhl@digital-competence.de",
|
||||||
"homepage": "http://www.digital-competence.de",
|
"homepage": "https://www.digital-competence.de",
|
||||||
"role": "Developer"
|
"role": "Developer"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
|
||||||
"homepage": "https://github.com/digicomp/DigiComp.Sequence",
|
|
||||||
"require": {
|
"require": {
|
||||||
"neos/flow": "~4.0|~5.3"
|
"php": ">=7.4.0",
|
||||||
|
"neos/flow": "^6.3.21"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"mikey179/vfsstream": "^1.6.1",
|
||||||
|
"neos/buildessentials": "^7.0.0",
|
||||||
|
"phpunit/phpunit": "~8.5",
|
||||||
|
"vimeo/psalm": "~4.22.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"DigiComp\\Menu\\": "Classes"
|
"DigiComp\\Menu\\": "Classes/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"config": {
|
||||||
|
"sort-packages": true,
|
||||||
|
"platform-check": true
|
||||||
|
},
|
||||||
"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"
|
||||||
|
},
|
||||||
|
"neos": {
|
||||||
|
"package-key": "DigiComp.Menu"
|
||||||
},
|
},
|
||||||
"applied-flow-migrations": [
|
"applied-flow-migrations": [
|
||||||
"TYPO3.Fluid-20150214130800",
|
"TYPO3.Fluid-20150214130800",
|
||||||
|
|
Loading…
Reference in a new issue