DigiComp.FluidJsonViews/Classes/ViewHelpers/FluidJsonViewHelper.php

73 lines
1.9 KiB
PHP
Raw Permalink Normal View History

2024-06-02 01:59:15 +02:00
<?php
declare(strict_types=1);
namespace DigiComp\FluidJsonViews\ViewHelpers;
use DigiComp\FluidJsonViews\ViewHelpers\Controller\FluidJsonController;
use DigiComp\FluidRenderFunctions\ViewHelpers\Traits\ValidateRenderFunctionTrait;
2024-06-02 01:59:15 +02:00
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Exception\InfiniteLoopException;
use Neos\Flow\Mvc\Exception\StopActionException;
use Neos\Flow\Persistence\Doctrine\QueryResult;
use Neos\FluidAdaptor\Core\Widget\AbstractWidgetViewHelper;
use Neos\FluidAdaptor\Core\Widget\Exception\InvalidControllerException;
use Neos\FluidAdaptor\Core\Widget\Exception\MissingControllerException;
class FluidJsonViewHelper extends AbstractWidgetViewHelper
{
use ValidateRenderFunctionTrait;
2024-06-02 01:59:15 +02:00
/**
* @inheritDoc
* @Flow\Inject
* @var FluidJsonController
*/
protected $controller;
/**
* @inheritDoc
*/
protected $ajaxWidget = true;
/**
* @inheritDoc
*/
public function initializeArguments(): void
{
parent::initializeArguments();
$this->registerArgument('objects', QueryResult::class, 'Objects to show in table.', true);
$this->registerArgument(
'renderFunction',
'string',
2024-06-02 01:59:15 +02:00
'callabe to use to render single object',
true
);
$this->registerArgument(
'searchProperties',
'array',
'an array of pathes, which should be used during search evaluation',
false,
[]
);
}
public function validateArguments()
{
parent::validateArguments();
$this->validateRenderFunctionArgument('renderFunction');
}
2024-06-02 01:59:15 +02:00
/**
* @throws InfiniteLoopException
* @throws InvalidControllerException
* @throws MissingControllerException
* @throws StopActionException
*/
public function render(): string
{
return $this->initiateSubRequest();
}
}