34 lines
983 B
PHP
Executable File
34 lines
983 B
PHP
Executable File
<?php
|
|
|
|
namespace Evoweb\EwBase\ViewHelpers\Condition;
|
|
|
|
/*
|
|
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
|
*
|
|
* For the full copyright and license information, please read the
|
|
* LICENSE.md file that was distributed with this source code.
|
|
*/
|
|
|
|
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
|
|
|
|
/**
|
|
* ### Condition: String contains substring
|
|
*
|
|
* Condition ViewHelper which renders the `then` child if provided
|
|
* string $haystack contains provided string $needle.
|
|
*/
|
|
class StringContainsViewHelper extends AbstractConditionViewHelper
|
|
{
|
|
public function initializeArguments(): void
|
|
{
|
|
parent::initializeArguments();
|
|
$this->registerArgument('haystack', 'string', 'haystack', true);
|
|
$this->registerArgument('needle', 'string', 'need', true);
|
|
}
|
|
|
|
protected static function evaluateCondition($arguments = null): bool
|
|
{
|
|
return str_contains($arguments['haystack'], $arguments['needle']);
|
|
}
|
|
}
|