forked from neos/neos-development-collection
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEATURE: 3638 Fusion EEL Helper ${Neos.BackendUser.interfaceLanguage}
closes neos#3638 implemented as discussed in neos#3638 yes you are correct - the `implements ProtectedContextAwareInterface` would not be needed in this case as we rely on ObjectAccess::getProperty, but i implemented it so that in the future `Neos.BackendUser.getInterfaceLanguage()` is still disallowed as one should use `Neos.BackendUser.interfaceLanguage`
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
namespace Neos\Neos\Fusion\Helper; | ||
|
||
/* | ||
* This file is part of the Neos.Neos package. | ||
* | ||
* (c) Contributors of the Neos Project - www.neos.io | ||
* | ||
* This package is Open Source Software. For the full copyright and license | ||
* information, please view the LICENSE file which was distributed with this | ||
* source code. | ||
*/ | ||
|
||
use Neos\Eel\ProtectedContextAwareInterface; | ||
use Neos\Flow\Annotations as Flow; | ||
use Neos\Neos\Service\UserService; | ||
|
||
/** | ||
* BackendUser helper for translations in backend. | ||
*/ | ||
class BackendUserHelper implements ProtectedContextAwareInterface | ||
{ | ||
private const FROM_EEL_DIRECTLY_CALLABLE_METHODS = []; | ||
|
||
#[Flow\Inject(lazy: false)] | ||
protected UserService $userService; | ||
|
||
/** | ||
* Returns the interface language the user selected. Will fall back to the default language defined in settings. | ||
* | ||
* @example Neos.BackendUser.interfaceLanguage | ||
*/ | ||
public function getInterfaceLanguage(): string | ||
{ | ||
return $this->userService->getInterfaceLanguage(); | ||
} | ||
|
||
public function allowsCallOfMethod($methodName) | ||
{ | ||
// checks if method is allowed to be called from EEL directly or should use property access notation | ||
return in_array($methodName, self::FROM_EEL_DIRECTLY_CALLABLE_METHODS, true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters