<?php
namespace Newland\Toubiz\Poi\Neos\ViewHelpers\Topic;

/*
 * This file is part of the "toubiz-poi-neos" package.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 */

use Neos\ContentRepository\Domain\Model\Node;
use Neos\Flow\Annotations as Flow;
use Neos\FluidAdaptor\Core\Widget\AbstractWidgetViewHelper;
use Newland\NeosCommon\Domain\Model\Topic;
use Newland\Toubiz\Poi\Neos\Filter\Items\ArticleRoot;
use Newland\Toubiz\Poi\Neos\ViewHelpers\Topic\Controller\ArticlesController;

class ArticlesViewHelper extends AbstractWidgetViewHelper
{
    /**
     * @var ArticlesController
     * @Flow\Inject()
     */
    protected $controller;

    public function initializeArguments(): void
    {
        parent::initializeArguments();
        $this->registerArgument('topic', Topic::class, 'The selected topic.', true);
        $this->registerArgument('queryOverride', 'array', 'Query override for additional filtering.', false, []);
        $this->registerArgument('properties', 'array', 'Properties additional filtering.', false, []);
        $this->registerArgument('limit', 'integer', 'Query Limit', false, 11);
        $this->registerArgument('node', Node::class, 'Necessary node', true);
    }

    public function render(): string
    {
        $response = $this->initiateSubRequest();
        return (string) $response->getBody();
    }
}
