| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Extension\AbuseFilter\Filter; |
| 4 |
|
| 5 |
use LogicException; |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
class MutableFilter extends Filter { |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
public static function newDefault(): self { |
| 19 |
return new self( |
| 20 |
new Specs( |
| 21 |
'', |
| 22 |
'', |
| 23 |
'', |
| 24 |
[], |
| 25 |
'' |
| 26 |
), |
| 27 |
new Flags( |
| 28 |
true, |
| 29 |
false, |
| 30 |
Flags::FILTER_PUBLIC, |
| 31 |
false |
| 32 |
), |
| 33 |
[], |
| 34 |
new LastEditInfo( |
| 35 |
0, |
| 36 |
'', |
| 37 |
'' |
| 38 |
) |
| 39 |
); |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
public static function newFromParentFilter( Filter $filter ): self { |
| 47 |
return new self( |
| 48 |
$filter->getSpecs(), |
| 49 |
$filter->getFlags(), |
| 50 |
|
| 51 |
$filter->actions ?? $filter->actionsCallback, |
| 52 |
$filter->getLastEditInfo(), |
| 53 |
$filter->getID(), |
| 54 |
$filter->getHitCount(), |
| 55 |
$filter->isThrottled() |
| 56 |
); |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
public function setRules( string $rules ): void { |
| 63 |
$this->specs->setRules( $rules ); |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
public function setComments( string $comments ): void { |
| 70 |
$this->specs->setComments( $comments ); |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
public function setName( string $name ): void { |
| 77 |
$this->specs->setName( $name ); |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
public function setActionsNames( array $actionsNames ): void { |
| 85 |
if ( $this->actions !== null ) { |
| 86 |
throw new LogicException( 'Cannot set actions names with actions already set' ); |
| 87 |
} |
| 88 |
$this->specs->setActionsNames( $actionsNames ); |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
public function setGroup( string $group ): void { |
| 95 |
$this->specs->setGroup( $group ); |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
public function setEnabled( bool $enabled ): void { |
| 102 |
$this->flags->setEnabled( $enabled ); |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
public function setDeleted( bool $deleted ): void { |
| 109 |
$this->flags->setDeleted( $deleted ); |
| 110 |
} |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
public function setHidden( bool $hidden ): void { |
| 116 |
$this->flags->setHidden( $hidden ); |
| 117 |
} |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
public function setProtected( bool $protected ): void { |
| 123 |
$this->flags->setProtected( $protected ); |
| 124 |
} |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
public function setGlobal( bool $global ): void { |
| 130 |
$this->flags->setGlobal( $global ); |
| 131 |
} |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
public function setActions( array $actions ): void { |
| 138 |
parent::setActions( $actions ); |
| 139 |
} |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
public function setUserID( int $id ): void { |
| 145 |
$this->lastEditInfo->setUserID( $id ); |
| 146 |
} |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
public function setUserName( string $name ): void { |
| 152 |
$this->lastEditInfo->setUserName( $name ); |
| 153 |
} |
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
public function setTimestamp( string $timestamp ): void { |
| 159 |
$this->lastEditInfo->setTimestamp( $timestamp ); |
| 160 |
} |
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
public function setID( ?int $id ): void { |
| 166 |
$this->id = $id; |
| 167 |
} |
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
public function setHitCount( int $hitCount ): void { |
| 173 |
$this->hitCount = $hitCount; |
| 174 |
} |
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
public function setThrottled( bool $throttled ): void { |
| 180 |
$this->throttled = $throttled; |
| 181 |
} |
| 182 |
} |