diff --git a/src/UnicaenAuth/View/Helper/UserCurrent.php b/src/UnicaenAuth/View/Helper/UserCurrent.php index 4a32bcdeb82cfb0e2a00414f054e07ee75e677e3..9926881b0360bd16740b4e64f3c8dc64ce9a9608 100644 --- a/src/UnicaenAuth/View/Helper/UserCurrent.php +++ b/src/UnicaenAuth/View/Helper/UserCurrent.php @@ -37,31 +37,30 @@ class UserCurrent extends UserAbstract */ public function __toString() { - try { - $id = 'user-current-info'; - $userStatusHelper = $this->getView()->plugin('userStatus'); /* @var $userStatusHelper \UnicaenAuth\View\Helper\UserStatus */ - $status = $userStatusHelper(false); - - if ($this->getIdentity()) { - $userProfileHelper = $this->getView()->plugin('userProfile'); /* @var $userProfileHelper \UnicaenAuth\View\Helper\UserProfile */ - $userInfoHelper = $this->getView()->plugin('userInfo'); /* @var $userInfoHelper \UnicaenAuth\View\Helper\UserInfo */ - $content = $userProfileHelper . $userInfoHelper($this->getAffectationFineSiDispo()); - } - else { - $content = _("Aucun"); - if ($this->getTranslator()) { - $content = $this->getTranslator()->translate($content, $this->getTranslatorTextDomain()); - } - } - - $content = preg_replace('/\r\n|\n|\r/', '', $content); - - $title = _("Utilisateur connecté à l'application"); + $id = 'user-current-info'; + $userStatusHelper = $this->getView()->plugin('userStatus'); /* @var $userStatusHelper \UnicaenAuth\View\Helper\UserStatus */ + $status = $userStatusHelper(false); + + if ($this->getIdentity()) { + $userProfileHelper = $this->getView()->plugin('userProfile'); /* @var $userProfileHelper \UnicaenAuth\View\Helper\UserProfile */ + $userInfoHelper = $this->getView()->plugin('userInfo'); /* @var $userInfoHelper \UnicaenAuth\View\Helper\UserInfo */ + $content = $userProfileHelper . $userInfoHelper($this->getAffectationFineSiDispo()); + } + else { + $content = _("Aucun"); if ($this->getTranslator()) { - $title = $this->getTranslator()->translate($title, $this->getTranslatorTextDomain()); + $content = $this->getTranslator()->translate($content, $this->getTranslatorTextDomain()); } - - $out = <<<EOS + } + + $content = preg_replace('/\r\n|\n|\r/', '', $content); + + $title = _("Utilisateur connecté à l'application"); + if ($this->getTranslator()) { + $title = $this->getTranslator()->translate($title, $this->getTranslatorTextDomain()); + } + + $out = <<<EOS <a class="navbar-link" id="$id" title="$title" @@ -70,20 +69,15 @@ class UserCurrent extends UserAbstract data-content="$content" href="#">$status</a> EOS; - $out .= PHP_EOL; - $out .= <<<EOS + $out .= PHP_EOL; + $out .= <<<EOS <script type="text/javascript"> $(function() { $("#$id").popover({ html: true, container: '#navbar' }); }); </script> EOS; - $out .= PHP_EOL; - } - catch (\Exception $e) { - var_dump($e); - $out = '<p>' . $e->getMessage() . '</p><p>' . $e->getTraceAsString() . '</p>'; - } + $out .= PHP_EOL; return $out; }