2014-07-07 15:49:44 +02:00
|
|
|
<?php
|
2021-05-12 02:01:22 +02:00
|
|
|
|
2014-07-07 15:49:44 +02:00
|
|
|
namespace DigiComp\Menu\ViewHelpers;
|
2017-06-03 11:39:59 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the DigiComp.Menu package.
|
|
|
|
*
|
|
|
|
* (c) digital competence
|
|
|
|
*
|
|
|
|
* This package is Open Source Software. For the full copyright and license
|
|
|
|
* information, please view the LICENSE file which was distributed with this
|
|
|
|
* source code.
|
|
|
|
*/
|
|
|
|
|
2017-06-03 11:53:57 +02:00
|
|
|
use Neos\Flow\Annotations as Flow;
|
2017-06-03 11:53:57 +02:00
|
|
|
use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper;
|
2017-06-03 11:39:59 +02:00
|
|
|
|
2014-07-07 15:49:44 +02:00
|
|
|
/**
|
2017-06-03 11:39:59 +02:00
|
|
|
* Just adds the return of MenuService
|
|
|
|
* TODO: Write example
|
2014-07-07 15:49:44 +02:00
|
|
|
*/
|
2017-06-05 18:40:50 +02:00
|
|
|
class ItemsViewHelper extends AbstractViewHelper
|
2017-06-03 11:39:59 +02:00
|
|
|
{
|
|
|
|
protected $escapeOutput = false;
|
2015-06-15 16:48:34 +02:00
|
|
|
|
2014-07-07 15:49:44 +02:00
|
|
|
/**
|
|
|
|
* @var \DigiComp\Menu\MenuService\ServiceInterface
|
|
|
|
* @Flow\Inject
|
|
|
|
*/
|
|
|
|
protected $menuService;
|
|
|
|
|
2020-10-15 21:13:20 +02:00
|
|
|
public function initializeArguments(): void
|
|
|
|
{
|
|
|
|
$this->registerArgument('for', 'string', 'path in Menu.yaml', false);
|
|
|
|
$this->registerArgument('as', 'string', 'Name in Frontend', false);
|
|
|
|
}
|
|
|
|
|
2017-06-03 11:39:59 +02:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
2020-10-15 21:13:20 +02:00
|
|
|
public function render(): string
|
2017-06-03 11:39:59 +02:00
|
|
|
{
|
2020-10-15 21:13:20 +02:00
|
|
|
$this->templateVariableContainer->add(
|
|
|
|
$this->arguments['as'],
|
|
|
|
$this->menuService->getItems($this->arguments['for'])
|
|
|
|
);
|
2014-07-07 15:49:44 +02:00
|
|
|
return $this->renderChildren();
|
|
|
|
}
|
|
|
|
}
|