Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php |
||
96 | public static function getByAppName(string $role, BakaCompanies $company): Roles |
||
97 | { |
||
98 | //echeck if we have a dot , taht means we are sending the specific app to use |
||
99 | if (strpos($role, '.') === false) { |
||
100 | throw new ServerErrorHttpException('ACL - We are expecting the app for this role'); |
||
101 | } |
||
102 | |||
103 | $appRole = explode('.', $role); |
||
104 | $role = $appRole[1]; |
||
1 ignored issue
–
show
|
|||
105 | $appName = $appRole[0]; |
||
106 | |||
107 | //look for the app and set it |
||
108 | if (!$app = Apps::getACLApp($appName)) { |
||
109 | throw new ServerErrorHttpException('ACL - No app found for this role'); |
||
110 | } |
||
111 | |||
112 | return self::findFirst([ |
||
113 | 'conditions' => 'apps_id in (?0, ?1) AND company_id in (?2 , ?3)', |
||
114 | 'bind' => [$app->getId(), self::DEFAULT_ACL_APP_ID, $company->getId(), self::DEFAULT_ACL_COMPANY_ID] |
||
115 | ]); |
||
118 |