Conditions | 2 |
Paths | 2 |
Total Lines | 12 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 2.0116 |
Changes | 0 |
1 | <?php |
||
118 | 3 | public static function getByName(string $name): EmailTemplates |
|
119 | { |
||
120 | 3 | $emailTemplate = self::findFirst([ |
|
121 | 3 | 'conditions' => 'company_id in (?0, 0) and app_id in (?1, 0) and name = ?2 and is_deleted = 0', |
|
122 | 3 | 'bind' => [Di::getDefault()->getUserData()->default_company, Di::getDefault()->getConfig()->app->id, $name] |
|
123 | ]); |
||
124 | |||
125 | 3 | if (!is_object($emailTemplate)) { |
|
126 | throw new UnprocessableEntityHttpException(_('No template ' . $name . ' found for this app ' . Di::getDefault()->getApp()->name)); |
||
127 | } |
||
128 | |||
129 | 3 | return $emailTemplate; |
|
130 | } |
||
132 |