aboutsummaryrefslogtreecommitdiff
path: root/lib/exceptions/AccessDeniedException.php
blob: 5593997d8ce027f653c86d7fcfb400deb756a04c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
 * AccessDeniedException.php
 *
 * Use this exception whenever a user tries to access a restricted part of the
 * system without having the required permissions.
 *
 * @author   Marcus Lunzenauer <mlunzena@uos.de>
 * @license  http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
 * @category Stud.IP
 */
class AccessDeniedException extends Exception
{
    private $details = [];

    /**
     * Constucts the exception
     * @param string    $message  Exception message
     * @param integer   $code     Exception code
     * @param Exception $previous Previous exception (optional)
     */
    public function __construct($message = '', $code = 0, ?Exception $previous = null)
    {
        if (func_num_args() === 0) {
            $message = _('Sie haben nicht die Berechtigung, diese Aktion '
                       . 'auszuführen bzw. diesen Teil des Systems zu betreten.');
        }

        parent::__construct($message, $code, $previous);
    }

    /**
     * Set additional details for the exception.
     * @param array $details Additional details
     */
    public function setDetails(array $details)
    {
        $this->details = $details;
    }

    /**
     * Get the additional details for the exception.
     * @return array Additional details
     */
    public function getDetails()
    {
        return $this->details;
    }
}