‪TYPO3CMS  ‪main
IfHasStateViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
22 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
23 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
24 
30 final class ‪IfHasStateViewHelper extends AbstractConditionViewHelper
31 {
32  public function ‪initializeArguments(): void
33  {
34  parent::initializeArguments();
35  $this->registerArgument('state', 'string', 'The state to check for (e.g. active or locked)', true);
36  $this->registerArgument('provider', MfaProviderManifestInterface::class, 'The provider in question', true);
37  }
38 
42  public static function ‪verdict(array $arguments, RenderingContextInterface $renderingContext): bool
43  {
44  $stateMethod = 'is' . ucfirst($arguments['state']);
45  $provider = $arguments['provider'];
46  $propertyManager = ‪MfaProviderPropertyManager::create($provider, ‪$GLOBALS['BE_USER']);
47  return is_callable([$provider, $stateMethod]) && $provider->{$stateMethod}($propertyManager);
48  }
49 }
‪TYPO3\CMS\Core\Authentication\Mfa\MfaProviderManifestInterface
Definition: MfaProviderManifestInterface.php:26
‪TYPO3\CMS\Core\Authentication\Mfa\MfaProviderPropertyManager\create
‪static create(MfaProviderManifestInterface $provider, AbstractUserAuthentication $user)
Definition: MfaProviderPropertyManager.php:193
‪TYPO3\CMS\Backend\ViewHelpers\Mfa
Definition: IfHasStateViewHelper.php:18
‪TYPO3\CMS\Backend\ViewHelpers\Mfa\IfHasStateViewHelper
Definition: IfHasStateViewHelper.php:31
‪TYPO3\CMS\Core\Authentication\Mfa\MfaProviderPropertyManager
Definition: MfaProviderPropertyManager.php:33
‪TYPO3\CMS\Backend\ViewHelpers\Mfa\IfHasStateViewHelper\verdict
‪static verdict(array $arguments, RenderingContextInterface $renderingContext)
Definition: IfHasStateViewHelper.php:42
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Backend\ViewHelpers\Mfa\IfHasStateViewHelper\initializeArguments
‪initializeArguments()
Definition: IfHasStateViewHelper.php:32