Compare commits
No commits in common. "master" and "version/2.x-dev" have entirely different histories.
master
...
version/2.
7 changed files with 81 additions and 105 deletions
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
|
||||
namespace DigiComp\Menu\MenuService;
|
||||
|
||||
/*
|
||||
|
@ -17,10 +16,11 @@ namespace DigiComp\Menu\MenuService;
|
|||
*/
|
||||
interface ServiceInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string|null $forPath
|
||||
* @param mixed $forPath
|
||||
*
|
||||
* @return \Iterator
|
||||
* @return array|\Iterator
|
||||
*/
|
||||
public function getItems(string $forPath = null): \Iterator;
|
||||
public function getItems($forPath = null);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
|
||||
namespace DigiComp\Menu\MenuService;
|
||||
|
||||
/*
|
||||
|
@ -13,38 +12,53 @@ namespace DigiComp\Menu\MenuService;
|
|||
*/
|
||||
|
||||
use Neos\Flow\Annotations as Flow;
|
||||
use Neos\Flow\Configuration\ConfigurationManager;
|
||||
|
||||
/**
|
||||
* @package DigiComp\Menu\Menu
|
||||
*
|
||||
* @Flow\Scope("singleton")
|
||||
*/
|
||||
class SettingsService implements ServiceInterface
|
||||
{
|
||||
/**
|
||||
* @Flow\InjectConfiguration(type="Menu")
|
||||
* @var array
|
||||
* @var \Neos\Flow\Configuration\ConfigurationManager
|
||||
*/
|
||||
protected array $menuConfiguration;
|
||||
protected $configurationManager;
|
||||
public function injectConfigurationManager(ConfigurationManager $configurationManager)
|
||||
{
|
||||
$this->configurationManager = $configurationManager;
|
||||
$this->menuConfiguration = $this->configurationManager->getConfiguration('Menu');
|
||||
}
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected array $items = [];
|
||||
protected $menuConfiguration;
|
||||
|
||||
public function getItems(string $forPath = null): \Iterator
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $items = array();
|
||||
|
||||
/**
|
||||
* @param string $forMenu
|
||||
* @return array
|
||||
*/
|
||||
public function getItems($forMenu = null)
|
||||
{
|
||||
if ($forPath) {
|
||||
$items = &$this->menuConfiguration[$forPath];
|
||||
if ($forMenu) {
|
||||
$items = &$this->menuConfiguration[$forMenu];
|
||||
} else {
|
||||
$items = &$this->menuConfiguration;
|
||||
}
|
||||
if ($items) {
|
||||
\uasort(
|
||||
$items,
|
||||
static function ($a, $b) {
|
||||
uasort(
|
||||
$items, function ($a, $b) {
|
||||
return $a['sorting'] > $b['sorting'];
|
||||
}
|
||||
);
|
||||
}
|
||||
return new \ArrayIterator($items);
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
|
||||
namespace DigiComp\Menu;
|
||||
|
||||
/*
|
||||
|
@ -12,26 +11,26 @@ namespace DigiComp\Menu;
|
|||
* source code.
|
||||
*/
|
||||
|
||||
use Neos\Flow\Configuration\ConfigurationManager;
|
||||
use Neos\Flow\Core\Bootstrap;
|
||||
use Neos\Flow\Package\Package as BasePackage;
|
||||
use Neos\Flow\Configuration\ConfigurationManager;
|
||||
|
||||
/**
|
||||
* Package base class of the DigiComp.Menu package.
|
||||
*/
|
||||
class Package extends BasePackage
|
||||
{
|
||||
|
||||
public function boot(Bootstrap $bootstrap)
|
||||
{
|
||||
parent::boot($bootstrap);
|
||||
|
||||
$dispatcher = $bootstrap->getSignalSlotDispatcher();
|
||||
$dispatcher->connect(
|
||||
ConfigurationManager::class,
|
||||
'configurationManagerReady',
|
||||
'Neos\Flow\Configuration\ConfigurationManager', 'configurationManagerReady',
|
||||
function (ConfigurationManager $configurationManager) {
|
||||
$configurationManager->registerConfigurationType('Menu');
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
|
||||
namespace DigiComp\Menu\ViewHelpers;
|
||||
|
||||
/*
|
||||
|
@ -12,10 +11,8 @@ 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
|
||||
|
@ -23,32 +20,23 @@ use Neos\FluidAdaptor\Core\ViewHelper\Exception;
|
|||
*/
|
||||
class ItemsViewHelper extends AbstractViewHelper
|
||||
{
|
||||
|
||||
protected $escapeOutput = false;
|
||||
|
||||
/**
|
||||
* @var \DigiComp\Menu\MenuService\ServiceInterface
|
||||
* @Flow\Inject
|
||||
* @var ServiceInterface
|
||||
*/
|
||||
protected $menuService;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @param string $as
|
||||
* @param string $for
|
||||
* @return string
|
||||
*/
|
||||
public function initializeArguments(): void
|
||||
public function render($as = 'items', $for = null)
|
||||
{
|
||||
$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'])
|
||||
);
|
||||
$this->templateVariableContainer->add($as, $this->menuService->getItems($for));
|
||||
return $this->renderChildren();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
|
||||
namespace DigiComp\Menu\ViewHelpers;
|
||||
|
||||
/*
|
||||
|
@ -13,56 +12,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;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @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
|
||||
*/
|
||||
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, \EXTR_OVERWRITE);
|
||||
public function render(
|
||||
array $links,
|
||||
$activeStep = 1,
|
||||
$returnable = true,
|
||||
$stepsAs = 'steps',
|
||||
$backLinkAs = 'backLink',
|
||||
$activeStepAs = 'activeStep',
|
||||
$linksAs = 'links',
|
||||
$activeStepLinkAs = 'activeStepLink',
|
||||
$offset = 1,
|
||||
$linkCount = null
|
||||
) {
|
||||
//handling famous off by one
|
||||
$activeStep -= $offset;
|
||||
//make sure our array index is numeric
|
||||
if (\is_iterable($links)) {
|
||||
$links = \iterator_to_array($links);
|
||||
}
|
||||
$links = \array_values($links);
|
||||
$links = array_values($links);
|
||||
if (!$linkCount) {
|
||||
$linkCount = \count($links);
|
||||
$linkCount = count($links);
|
||||
}
|
||||
foreach ($links as $i => &$link) {
|
||||
$link['completed'] = $activeStep > $i;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2021 Ferdinand Kuhl <f.kuhl@digital-competence.de>
|
||||
Copyright (c) 2016 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
|
||||
|
@ -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.
|
||||
THE SOFTWARE.
|
|
@ -1,48 +1,33 @@
|
|||
{
|
||||
"name": "digicomp/menu",
|
||||
"type": "typo3-flow-package",
|
||||
"description": "Helps with the creation of simple fluid based menus",
|
||||
"type": "neos-package",
|
||||
"keywords": [
|
||||
"Neos",
|
||||
"Flow",
|
||||
"flow",
|
||||
"neos",
|
||||
"menu"
|
||||
],
|
||||
"homepage": "https://git.digital-competence.de/Packages/DigiComp.Menu",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ferdinand Kuhl",
|
||||
"email": "f.kuhl@digital-competence.de",
|
||||
"homepage": "https://www.digital-competence.de",
|
||||
"homepage": "http://www.digital-competence.de",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/digicomp/DigiComp.Sequence",
|
||||
"require": {
|
||||
"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"
|
||||
"neos/flow": "~4.0|~5.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"DigiComp\\Menu\\": "Classes/"
|
||||
"DigiComp\\Menu\\": "Classes"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true,
|
||||
"platform-check": true
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-develop": "3.0.x-dev",
|
||||
"dev-version/2.x-dev": "2.0.x-dev"
|
||||
},
|
||||
"neos": {
|
||||
"package-key": "DigiComp.Menu"
|
||||
"dev-master": "2.0.x-dev"
|
||||
},
|
||||
"applied-flow-migrations": [
|
||||
"TYPO3.Fluid-20150214130800",
|
||||
|
@ -80,4 +65,4 @@
|
|||
"Neos.Flow-20180415105700"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue