Neos.Neos/Classes/ViewHelpers/Backend/UserInitialsViewHelper.php
public function render($format = 'initials')
    {
        if (!in_array($format, ['fullFirstName', 'initials', 'fullName'])) {
            throw new \InvalidArgumentException(sprintf('Format "%s" given to backend.userInitials(), only supporting "fullFirstName", "initials" and "fullName".', $format), 1415705861);
        }

        $username = $this->renderChildren();

        /* @var $requestedUser Person */
        $requestedUser = $this->domainUserService->getUser($username);
        if ($requestedUser === null || $requestedUser->getName() === null) {
            return $username;
        }

        $currentUser = $this->userService->getBackendUser();
        if ($currentUser) {
            if ($currentUser === $requestedUser) {
                $translationHelper = new TranslationHelper();
                $you = $translationHelper->translate('you', null, [], 'Main', 'Neos.Neos');
            }
        }

        switch ($format) {
            case 'initials':
                return mb_substr(preg_replace('/[^[:alnum:][:space:]]/u', '', $requestedUser->getName()->getFirstName()), 0, 1) . mb_substr(preg_replace('/[^[:alnum:][:space:]]/u', '', $requestedUser->getName()->getLastName()), 0, 1);
            case 'fullFirstName':
                return isset($you) ? $you : trim($requestedUser->getName()->getFirstName() . ' ' . ltrim(mb_substr($requestedUser->getName()->getLastName(), 0, 1) . '.', '.'));
            case 'fullName':
                return isset($you) ? $you : $requestedUser->getName()->getFullName();
        }
    }
public function render($format = 'initials')
    {
        if (!in_array($format, ['fullFirstName', 'initials', 'fullName'])) {
            throw new \InvalidArgumentException(sprintf('Format "%s" given to backend.userInitials(), only supporting "fullFirstName", "initials" and "fullName".', $format), 1415705861);
        }

        $username = $this->renderChildren();

        /* @var $requestedUser Person */
        $requestedUser = $this->domainUserService->getUser($username);
        if ($requestedUser === null || $requestedUser->getName() === null) {
            return $username;
        }

        $currentUser = $this->userService->getBackendUser();
        if ($currentUser) {
            if ($currentUser === $requestedUser) {
                $translationHelper = new TranslationHelper();
                $you = $translationHelper->translate('you', null, [], 'Main', 'Neos.Neos');
            }
        }

        switch ($format) {
            case 'initials':
                return mb_substr(preg_replace('/[^[:alnum:][:space:]]/u', '', $requestedUser->getName()->getFirstName()), 0, 1) . mb_substr(preg_replace('/[^[:alnum:][:space:]]/u', '', $requestedUser->getName()->getLastName()), 0, 1);
            case 'fullFirstName':
                return isset($you) ? $you : trim($requestedUser->getName()->getFirstName() . ' ' . ltrim(mb_substr($requestedUser->getName()->getLastName(), 0, 1) . '.', '.'));
            case 'fullName':
                return isset($you) ? $you : $requestedUser->getName()->getFullName();
        }
    }
public function render ( $ format = 'initials' ) { if ( ! in_array ( $ format , [ 'fullFirstName' , 'initials' , 'fullName' ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Format "%s" given to backend.userInitials(), only supporting "fullFirstName", "initials" and "fullName".' , $ format ) , 1415705861 ) ; } $ username = $ this -> renderChildren ( ) ; /* @var $requestedUser Person */ $ requestedUser = $ this -> domainUserService -> getUser ( $ username ) ; if ( $ requestedUser === null || $ requestedUser -> getName ( ) === null ) { return $ username ; } $ currentUser = $ this -> userService -> getBackendUser ( ) ; if ( $ currentUser ) { if ( $ currentUser === $ requestedUser ) { $ translationHelper = new TranslationHelper ( ) ; $ you = $ translationHelper -> translate ( 'you' , null , [ ] , 'Main' , 'Neos.Neos' ) ; } } switch ( $ format ) { case 'initials' : return mb_substr ( preg_replace ( '/[^[:alnum:][:space:]]/u' , '' , $ requestedUser -> getName ( ) -> getFirstName ( ) ) , 0 , 1 ) . mb_substr ( preg_replace ( '/[^[:alnum:][:space:]]/u' , '' , $ requestedUser -> getName ( ) -> getLastName ( ) ) , 0 , 1 ) ; case 'fullFirstName' : return isset ( $ you ) ? $ you : trim ( $ requestedUser -> getName ( ) -> getFirstName ( ) . ' ' . ltrim ( mb_substr ( $ requestedUser -> getName ( ) -> getLastName ( ) , 0 , 1 ) . '.' , '.' ) ) ; case 'fullName' : return isset ( $ you ) ? $ you : $ requestedUser -> getName ( ) -> getFullName ( ) ; } }
Render user initials or an abbreviated name for a given username. If the account was deleted, use the username as fallback.

@param string $format Supported are "fullFirstName", "initials" and "fullName"
@return string
@throws \Neos\Neos\Domain\Exception
Render user initials or an abbreviated name for a given username . If the account was deleted use the username as fallback .