24use Psr\Log\LoggerInterface;
25use Wikimedia\Assert\Assert;
61 $this->logger = LoggerFactory::getInstance(
'EditConstraintRunner' );
75 $this->constraints[] = $constraint;
87 foreach ( $this->constraints as $constraint ) {
89 if ( $result !== IEditConstraint::CONSTRAINT_PASSED ) {
92 'Checked {name}, got result: {result}',
99 $this->failedConstraint = $constraint;
104 $this->logger->debug(
105 'Checked {name}, got result: {result}',
121 $fullClassName = explode(
'\\', get_class( $constraint ) );
122 $constraintName = end( $fullClassName );
128 $constraintName .=
' ' . $constraint->getType();
130 return $constraintName;
139 Assert::precondition(
140 $this->failedConstraint !== false,
141 'getFailedConstraint called with no failed constraint'
143 return $this->failedConstraint;
Back end to process the edit constraints.
IEditConstraint bool $failedConstraint
The constraint that failed, so that its status can be fetched, or false if none failed.
addConstraint(IEditConstraint $constraint)
Add a constraint to check.
getFailedConstraint()
Get the constraint that failed.
IEditConstraint[] $constraints
Constraints to check.
getConstraintName(IEditConstraint $constraint)
checkConstraints()
Run constraint checks.
__construct()
Create a new runner.
Verify the page isn't larger than the maximum.
Interface for all constraints that can prevent edits.