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