| Conditions | 1 |
| Paths | 1 |
| Total Lines | 22 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 51 | protected function beforeUpdate() |
||
| 52 | { |
||
| 53 | $this->addValidator( |
||
| 54 | 'name', |
||
| 55 | v::required()->latin(), |
||
| 56 | v::callback( |
||
| 57 | function ($name) { |
||
| 58 | return !in_array(strtolower($name), Table::getInstance()->getBasicRoles()); |
||
| 59 | } |
||
| 60 | )->setError('Role "{{input}}" is basic and can\'t be editable'), |
||
| 61 | v::callback( |
||
| 62 | function ($name) { |
||
| 63 | return $this->clean['name'] != $name; |
||
| 64 | } |
||
| 65 | )->setError('Role name "{{input}}" the same as original'), |
||
| 66 | v::callback( |
||
| 67 | function ($name) { |
||
| 68 | return !Table::getInstance()->findRowWhere(['name' => $name]); |
||
| 69 | } |
||
| 70 | )->setError('Role name "{{input}}" already exists') |
||
| 71 | ); |
||
| 72 | } |
||
| 73 | |||
| 84 |