DigiComp.FlowWebManifestUtils/Classes/ViewHelpers/WebManifestViewHelper.php
Ferdinand Kuhl 6908aad70c
All checks were successful
ci/woodpecker/push/code-style Pipeline was successful
first working version
2024-06-21 13:17:27 +02:00

35 lines
995 B
PHP

<?php
declare(strict_types=1);
namespace DigiComp\FlowWebManifestUtils\ViewHelpers;
use Neos\Flow\Annotations as Flow;
use Neos\FluidAdaptor\Core\ViewHelper\AbstractTagBasedViewHelper;
class WebManifestViewHelper extends AbstractTagBasedViewHelper
{
protected $tagName = 'link';
/**
* @Flow\InjectConfiguration(package="DigiComp.FlowWebManifestUtils", path="reactOnPath")
* @var string
*/
protected string $reactOnPath;
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('useCredentials', 'bool', 'does the manifest requires authentication');
}
public function render(): string
{
if ($this->arguments['useCredentials'] === true) {
$this->tag->addAttribute('crossorigin', 'use-credentials');
}
$this->tag->addAttribute('rel', 'manifest');
$this->tag->addAttribute('href', $this->reactOnPath);
return $this->tag->render();
}
}