File size: 1,315 Bytes
07c3cdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
50
51
52
53
54
55
56
57
58
59
60
<?php

namespace ProcessMaker\Exception;

use G;

/**
 * Class PMException
 * @package ProcessMaker\Exception
 */
class RBACException extends \Exception
{
    const PM_LOGIN = '../login/login';
    const PM_403 = '/errors/error403.php';

    /**
     * RBACException constructor.
     * @param string $message
     * @param null $code
     */
    public function __construct($message, $code=NULL)
    {
        parent::__construct($message, $code);
    }

    /**
     * Displays the entire exception as a string
     * @return string
     */
    public function __toString()
    {
        switch ($this->getCode()) {
            case -1:
                G::SendTemporalMessage($this->getMessage(), 'error', 'labels');
                $message = self::PM_LOGIN;
                break;
            case -2:
                G::SendTemporalMessage($this->getMessage(), 'error', 'labels');
                $message = self::PM_LOGIN;
                break;
            case 403:
                $message = self::PM_403;
                break;
            default:
                $message = self::PM_LOGIN;
                break;
        }
        return $message;
    }

    /**
     * Returns the path to which to redirect
     * @return $this
     */
    public function getPath()
    {
        return $this;
    }
}