public function bootstrapRoleLabelFunction(UserInterface $user = null, array $roleColors = [], array $roleTrans = []) {

        if (null === $user) {
            return "";
        }

        $output = [];

        foreach ($user->getRoles() as $current) {

            $role = true === $current instanceof Role ? $current->getRole() : $current;

            $trans = $role;
            if (true === array_key_exists($role, $roleTrans)) {
                $trans = $this->getTranslator()->trans($roleTrans[$role]);
            }

            $label = $this->getLabelTwigExtension()->bootstrapLabelDefaultFunction(["content" => $trans]);
            if (true === array_key_exists($role, $roleColors)) {
                $label = $this->applyColor($label, $trans, $roleColors[$role]);
            }

            $output[] = $label;
        }

        return implode(" ", $output);
    }
public function bootstrapRoleLabelFunction(UserInterface $user = null, array $roleColors = [], array $roleTrans = []) {

        if (null === $user) {
            return "";
        }

        $output = [];

        foreach ($user->getRoles() as $current) {

            $role = true === $current instanceof Role ? $current->getRole() : $current;

            $trans = $role;
            if (true === array_key_exists($role, $roleTrans)) {
                $trans = $this->getTranslator()->trans($roleTrans[$role]);
            }

            $label = $this->getLabelTwigExtension()->bootstrapLabelDefaultFunction(["content" => $trans]);
            if (true === array_key_exists($role, $roleColors)) {
                $label = $this->applyColor($label, $trans, $roleColors[$role]);
            }

            $output[] = $label;
        }

        return implode(" ", $output);
    }
public function bootstrapRoleLabelFunction ( UserInterface $ user = null , array $ roleColors = [ ] , array $ roleTrans = [ ] ) { if ( null === $ user ) { return "" ; } $ output = [ ] ; foreach ( $ user -> getRoles ( ) as $ current ) { $ role = true === $ current instanceof Role ? $ current -> getRole ( ) : $ current ; $ trans = $ role ; if ( true === array_key_exists ( $ role , $ roleTrans ) ) { $ trans = $ this -> getTranslator ( ) -> trans ( $ roleTrans [ $ role ] ) ; } $ label = $ this -> getLabelTwigExtension ( ) -> bootstrapLabelDefaultFunction ( [ "content" => $ trans ] ) ; if ( true === array_key_exists ( $ role , $ roleColors ) ) { $ label = $ this -> applyColor ( $ label , $ trans , $ roleColors [ $ role ] ) ; } $ output [ ] = $ label ; } return implode ( " " , $ output ) ; }
Display a Bootstrap role label.

@param UserInterface $user The user.
@param array $roleColors The role colors.
@param array $roleTrans The role translations.
@return string Returns the Bootstrap role label.
Display a Bootstrap role label .