<?php namespace SGalinski\SgNews\ViewHelpers; /*************************************************************** * Copyright notice * * (c) sgalinski Internet Services (http://www.sgalinski.de) * * All rights reserved * * This script is part of the AY project. The AY project is * free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * The GNU General Public License can be found at * http://www.gnu.org/copyleft/gpl.html. * * This script is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ use TYPO3\CMS\Extbase\Core\Bootstrap; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; /** * Example: * {namespace sgnews=SGalinski\SgNews\ViewHelpers} * <sgnews:renderAuthorNews newsAuthors="123,321" excludedNews="123,423" /> */ class RenderAuthorNewsViewHelper extends AbstractViewHelper { /** * Extbase Bootstrap * * @var Bootstrap */ protected $bootstrap; /** * @param Bootstrap $bootstrap * @return void */ public function injectBootstrap(Bootstrap $bootstrap) { $this->bootstrap = $bootstrap; } /** * CommentThreadViewHelper constructor. */ public function __construct() { $this->escapeOutput = FALSE; $this->escapeChildren = FALSE; } /** * Initialize arguments. * * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception * @return void * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception */ public function initializeArguments() { $this->registerArgument('newsAuthors', 'string', 'A list with author uids', TRUE); $this->registerArgument('excludedNews', 'string', 'A list with excluded news uids'); $this->registerArgument('showDetails', 'bool', 'Shows the information of the author', FALSE, TRUE); } /** * Renders the Comment plugin. The view helper arguments configures the behavior. * * @return mixed */ public function render() { $configuration = [ 'extensionName' => 'SgNews', 'vendorName' => 'SGalinski', 'pluginName' => 'NewsByAuthor', 'controllerName' => 'NewsByAuthor', 'action' => 'list' ]; if ($this->arguments['newsAuthors']) { $configuration['settings']['newsAuthors'] = $this->arguments['newsAuthors']; } if ($this->arguments['excludedNews']) { $configuration['settings']['excludedNews'] = $this->arguments['excludedNews']; } if ($this->arguments['showDetails']) { $configuration['settings']['showDetails'] = $this->arguments['showDetails']; } return $this->bootstrap->run('', $configuration); } }