Skip to content

Commit

Permalink
FEATURE: 3638 Fusion EEL Helper ${Neos.BackendUser.interfaceLanguage}
Browse files Browse the repository at this point in the history
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
mhsdesign committed Oct 27, 2022
1 parent 9c7daf8 commit 280e66d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Neos.Neos/Classes/Fusion/Helper/BackendUserHelper.php
@@ -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);
}
}
1 change: 1 addition & 0 deletions Neos.Neos/Configuration/Settings.yaml
Expand Up @@ -552,6 +552,7 @@ Neos:
Neos.Array: Neos\Neos\Fusion\Helper\ArrayHelper
Neos.Rendering: Neos\Neos\Fusion\Helper\RenderingHelper
Neos.Caching: Neos\Neos\Fusion\Helper\CachingHelper
Neos.BackendUser: Neos\Neos\Fusion\Helper\BackendUserHelper

# DocTools is a tool used by Neos Developers to help with a variety of documentation tasks.
# These settings are only used in generating Documentation.
Expand Down

0 comments on commit 280e66d

Please sign in to comment.