Total Complexity | 4 |
Total Lines | 79 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
6 | class Apps extends \Baka\Auth\Models\Apps |
||
7 | { |
||
8 | /** |
||
9 | * |
||
10 | * @var integer |
||
11 | */ |
||
12 | public $id; |
||
13 | |||
14 | /** |
||
15 | * |
||
16 | * @var string |
||
17 | */ |
||
18 | public $name; |
||
19 | |||
20 | /** |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | public $description; |
||
25 | |||
26 | /** |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | public $created_at; |
||
31 | |||
32 | /** |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | public $updated_at; |
||
37 | |||
38 | /** |
||
39 | * |
||
40 | * @var integer |
||
41 | */ |
||
42 | public $is_deleted; |
||
43 | |||
44 | /** |
||
45 | * Ecosystem default app |
||
46 | * @var string |
||
47 | */ |
||
48 | const GEWAER_DEFAULT_APP_NAME = 'Default'; |
||
49 | |||
50 | /** |
||
51 | * Initialize method for model. |
||
52 | */ |
||
53 | 13 | public function initialize() |
|
54 | { |
||
55 | 13 | parent::initialize(); |
|
56 | |||
57 | 13 | $this->setSource('apps'); |
|
58 | 13 | } |
|
59 | |||
60 | /** |
||
61 | * You can only get 2 variations or default in DB or the api app |
||
62 | * |
||
63 | * @param string $name |
||
64 | * @return Apps |
||
65 | */ |
||
66 | 11 | public static function getACLApp(string $name): Apps |
|
67 | { |
||
68 | 11 | if (trim($name) == self::GEWAER_DEFAULT_APP_NAME) { |
|
69 | 10 | $app = self::findFirst(0); |
|
70 | } else { |
||
71 | 1 | $app = self::findFirst(\Phalcon\DI::getDefault()->getConfig()->app->id); |
|
72 | } |
||
73 | |||
74 | 11 | return $app; |
|
75 | } |
||
76 | |||
77 | /** |
||
78 | * Returns table name mapped in the model. |
||
79 | * |
||
80 | * @return string |
||
81 | */ |
||
82 | 11 | public function getSource() : string |
|
85 | } |
||
86 | } |
||
87 |