* ``` * * @internal */ final class UsernameViewHelper extends AbstractViewHelper { public function __construct( #[Autowire(service: 'cache.runtime')] private readonly FrontendInterface $usernameRuntimeCache ) {} public function initializeArguments(): void { $this->registerArgument('uid', 'int', 'Uid of the user', true); } /** * Resolve username from backend user id. Can return empty string if there is no user with that UID. */ public function render(): string { $uid = $this->arguments['uid']; $cacheIdentifier = 'belog-viewhelper-username_' . $uid; if ($this->usernameRuntimeCache->has($cacheIdentifier)) { return $this->usernameRuntimeCache->get($cacheIdentifier); } $username = BackendUtility::getRecord('be_users', $uid)['username'] ?? ''; $this->usernameRuntimeCache->set($cacheIdentifier, $username); return $username; } }