DigiComp.Menu/Classes/ViewHelpers/ItemsViewHelper.php

55 lines
1.3 KiB
PHP
Raw Normal View History

<?php
2021-05-12 02:01:22 +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.
*/
use DigiComp\Menu\MenuService\ServiceInterface;
use Neos\Flow\Annotations as Flow;
use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper;
use Neos\FluidAdaptor\Core\ViewHelper\Exception;
2017-06-03 11:39:59 +02:00
/**
2017-06-03 11:39:59 +02:00
* Just adds the return of MenuService
* TODO: Write example
*/
class ItemsViewHelper extends AbstractViewHelper
2017-06-03 11:39:59 +02:00
{
protected $escapeOutput = false;
/**
* @Flow\Inject
* @var ServiceInterface
*/
protected $menuService;
/**
* @throws Exception
*/
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 mixed
2017-06-03 11:39:59 +02:00
*/
public function render()
2017-06-03 11:39:59 +02:00
{
$this->templateVariableContainer->add(
$this->arguments['as'],
$this->menuService->getItems($this->arguments['for'])
);
return $this->renderChildren();
}
}