src/Salutation/SalutationUtil.php
public function createNameByFields(string $language, array $data)
    {
        if ($language) {
            /** @var System $system */
            $system = $this->framework->getAdapter(System::class);

            $system->loadLanguageFile('default', $language, true);
        }

        $name = '';

        if ($data['firstname']) {
            $name = $data['firstname'].($data['lastname'] ? ' '.$data['lastname'] : '');
        } elseif ($data['lastname']) {
            $name = $data['lastname'];
        }

        if ($name && $data['academicTitle']) {
            $name = $data['academicTitle'].' '.$name;
        }

        if ($name && $data['additionalTitle']) {
            $name = $data['additionalTitle'].' '.$name;
        }

        if ($data['lastname'] && $data['gender'] && ('en' != $language || !$data['academicTitle'])) {
            $gender = $GLOBALS['TL_LANG']['MSC']['haste_plus']['gender'.('female' == $data['gender'] ? 'Female' : 'Male')];

            $name = $gender.' '.$name;
        }

        if ($language) {
            $system->loadLanguageFile('default', $GLOBALS['TL_LANGUAGE'], true);
        }

        return $name;
    }
public function createNameByFields(string $language, array $data)
    {
        if ($language) {
            /** @var System $system */
            $system = $this->framework->getAdapter(System::class);

            $system->loadLanguageFile('default', $language, true);
        }

        $name = '';

        if ($data['firstname']) {
            $name = $data['firstname'].($data['lastname'] ? ' '.$data['lastname'] : '');
        } elseif ($data['lastname']) {
            $name = $data['lastname'];
        }

        if ($name && $data['academicTitle']) {
            $name = $data['academicTitle'].' '.$name;
        }

        if ($name && $data['additionalTitle']) {
            $name = $data['additionalTitle'].' '.$name;
        }

        if ($data['lastname'] && $data['gender'] && ('en' != $language || !$data['academicTitle'])) {
            $gender = $GLOBALS['TL_LANG']['MSC']['haste_plus']['gender'.('female' == $data['gender'] ? 'Female' : 'Male')];

            $name = $gender.' '.$name;
        }

        if ($language) {
            $system->loadLanguageFile('default', $GLOBALS['TL_LANGUAGE'], true);
        }

        return $name;
    }
public function createNameByFields ( string $ language , array $ data ) { if ( $ language ) { /** @var System $system */ $ system = $ this -> framework -> getAdapter ( System :: class ) ; $ system -> loadLanguageFile ( 'default' , $ language , true ) ; } $ name = '' ; if ( $ data [ 'firstname' ] ) { $ name = $ data [ 'firstname' ] . ( $ data [ 'lastname' ] ? ' ' . $ data [ 'lastname' ] : '' ) ; } elseif ( $ data [ 'lastname' ] ) { $ name = $ data [ 'lastname' ] ; } if ( $ name && $ data [ 'academicTitle' ] ) { $ name = $ data [ 'academicTitle' ] . ' ' . $ name ; } if ( $ name && $ data [ 'additionalTitle' ] ) { $ name = $ data [ 'additionalTitle' ] . ' ' . $ name ; } if ( $ data [ 'lastname' ] && $ data [ 'gender' ] && ( 'en' != $ language || ! $ data [ 'academicTitle' ] ) ) { $ gender = $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'haste_plus' ] [ 'gender' . ( 'female' == $ data [ 'gender' ] ? 'Female' : 'Male' ) ] ; $ name = $ gender . ' ' . $ name ; } if ( $ language ) { $ system -> loadLanguageFile ( 'default' , $ GLOBALS [ 'TL_LANGUAGE' ] , true ) ; } return $ name ; }
Creates complete names by inserting an array of the person's data.

Supported field names: firstname, lastname, academicTitle, additionalTitle, gender

If some of the fields shouldn't go into the processed name, just leave them out of $arrData

@param array $data
Creates complete names by inserting an array of the person s data .