36 lines
995 B
PHP
36 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();
|
||
|
}
|
||
|
}
|