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