MouchardCompleterAuth.php 842 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php

namespace UnicaenAuth\Mouchard;

use UnicaenApp\Mouchard\MouchardCompleterInterface;
use UnicaenApp\Mouchard\MouchardMessage;
use UnicaenAuth\Service\Traits\UserContextServiceAwareTrait;
use Zend\Mvc\Application;

/**
 * Interface MouchardCompleterInterface
 *
 * @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr>
 * @package UnicaenApp\Mouchard
 */
class MouchardCompleterAuth implements MouchardCompleterInterface
{
    use UserContextServiceAwareTrait;

    /**
     * @return $this
     */
    public function complete(MouchardMessage $message)
    {
25
26
27
28
        $user = $this->getServiceUserContext()->getDbUser();
        if ($user) $user = $user->getDisplayName();

        $message->setUser($user);
29
30
31
32
33
34
        $message->setRole((string)$this->getServiceUserContext()->getSelectedIdentityRole());

        return $this;
    }

}