Skip to content

Commit

Permalink
🐛 fix TYPO3 13.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Kanti committed Oct 28, 2024
1 parent c094f18 commit 0a48d0e
Show file tree
Hide file tree
Showing 4 changed files with 666 additions and 680 deletions.
2 changes: 1 addition & 1 deletion Classes/UnleashFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(
public function getConfig(string $key): string
{
return $this->extensionConfiguration->get('unleash', $key)
?: throw new RuntimeException('Missing ' . $key . ' in configuration');
?: throw new RuntimeException('Missing ' . $key . ' in configuration', 1132011323);
}

public function __invoke(): Unleash
Expand Down
15 changes: 5 additions & 10 deletions Classes/ViewHelpers/GetVariantViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,24 @@

namespace Andersundsehr\Unleash\ViewHelpers;

use Closure;
use Override;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
use Unleash\Client\Unleash;

final class GetVariantViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
public function __construct(private readonly Unleash $unleash)
{
}

#[Override]
public function initializeArguments(): void
{
$this->registerArgument('feature', 'string', 'Feature name', true);
}

#[Override]
public static function renderStatic(array $arguments, Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): ?string
public function render(): ?string
{
$unleash = GeneralUtility::makeInstance(Unleash::class);
assert($unleash instanceof Unleash);
return $unleash->getVariant($arguments['feature'])->getPayload()?->getValue() ?: null;
return $this->unleash->getVariant($this->arguments['feature'])->getPayload()?->getValue() ?: null;
}
}
5 changes: 2 additions & 3 deletions Classes/ViewHelpers/IsEnabledViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Override;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
use Unleash\Client\Unleash;

Expand All @@ -21,12 +22,10 @@ public function initializeArguments(): void

/**
* @param array{feature: string, default: bool} $arguments
* @return bool
*/
#[Override]
protected static function evaluateCondition($arguments = null)
public static function verdict(array $arguments, RenderingContextInterface $renderingContext): bool
{
assert(is_array($arguments), 'Arguments must be an array');
$unleash = GeneralUtility::makeInstance(Unleash::class);
assert($unleash instanceof Unleash);
return $unleash->isEnabled($arguments['feature'], default: (bool)$arguments['default']);
Expand Down
Loading

0 comments on commit 0a48d0e

Please sign in to comment.