2 declare(strict_types = 1);
18 use Symfony\Component\ExpressionLanguage\ExpressionFunction;
19 use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
50 return new ExpressionFunction(
'loginUser',
function () {
52 },
function ($arguments, $str) {
53 $user = $arguments[
'frontend']->user ?? $arguments[
'backend']->user;
54 if ($user->isLoggedIn) {
55 foreach (GeneralUtility::trimExplode(
',', $str,
true) as $test) {
56 if ($test ===
'*' || (
string)$user->userId === (
string)$test) {
67 return new ExpressionFunction(
'getTSFE',
function () {
69 },
function ($arguments) {
79 return new ExpressionFunction(
'usergroup',
function () {
81 },
function ($arguments, $str) {
82 $user = $arguments[
'frontend']->user ?? $arguments[
'backend']->user;
83 $groupList = $user->userGroupList ??
'';
85 if ($groupList !==
'0,-1' && $groupList !==
'') {
86 foreach (GeneralUtility::trimExplode(
',', $str,
true) as $test) {
87 if ($test ===
'*' || GeneralUtility::inList($groupList, $test)) {
98 return new ExpressionFunction(
103 function ($arguments, $str) {
105 $keyParts = explode(
'|', $str);
106 $sessionKey = array_shift($keyParts);
109 if ($tsfe && is_object($tsfe->fe_user)) {
110 $retVal = $tsfe->fe_user->getSessionData($sessionKey);
111 foreach ($keyParts as $keyPart) {
112 if (is_object($retVal)) {
113 $retVal = $retVal->{$keyPart};
114 } elseif (is_array($retVal)) {
115 $retVal = $retVal[$keyPart];
128 return new ExpressionFunction(
133 function ($arguments, $str) {
135 $requestWrapper = $arguments[
'request'];
136 $site = $requestWrapper->getSite();
137 if ($site instanceof
Site) {
138 $methodName =
'get' . ucfirst(trim($str));
139 if (method_exists($site, $methodName)) {
140 return $site->$methodName();
150 return new ExpressionFunction(
155 function ($arguments, $str) {
157 $requestWrapper = $arguments[
'request'];
158 $siteLanguage = $requestWrapper->getSiteLanguage();
160 $methodName =
'get' . ucfirst(trim($str));
161 if (method_exists($siteLanguage, $methodName)) {
162 return $siteLanguage->$methodName();