143 if ( isset( $filterDefinition[
'group'] ) ) {
144 $this->group = $filterDefinition[
'group'];
146 throw new MWException(
'You must use \'group\' to specify the ' .
147 'ChangesListFilterGroup this filter belongs to' );
150 if ( strpos( $filterDefinition[
'name'], self::RESERVED_NAME_CHAR ) !==
false ) {
151 throw new MWException(
'Filter names may not contain \'' .
152 self::RESERVED_NAME_CHAR .
153 '\'. Use the naming convention: \
'lowercase\''
157 if ( $this->group->getFilter( $filterDefinition[
'name'] ) ) {
158 throw new MWException(
'Two filters in a group cannot have the ' .
159 "same name: '{$filterDefinition['name']}'" );
162 $this->name = $filterDefinition[
'name'];
164 if ( isset( $filterDefinition[
'cssClassSuffix'] ) ) {
165 $this->cssClassSuffix = $filterDefinition[
'cssClassSuffix'];
166 $this->isRowApplicableCallable = $filterDefinition[
'isRowApplicableCallable'];
169 if ( isset( $filterDefinition[
'label'] ) ) {
170 $this->label = $filterDefinition[
'label'];
171 $this->description = $filterDefinition[
'description'];
174 $this->priority = $filterDefinition[
'priority'];
176 $this->group->registerFilter( $this );
193 public function conflictsWith( $other, $globalKey, $forwardKey, $backwardKey ) {
194 if ( $globalKey ===
null || $forwardKey ===
null || $backwardKey ===
null ) {
195 throw new MWException(
'All messages must be specified' );
204 $other->setUnidirectionalConflict(
224 $this->conflictingGroups[] = [
225 'group' => $other->getName(),
226 'groupObject' => $other,
227 'globalDescription' => $globalDescription,
228 'contextDescription' => $contextDescription,
231 $this->conflictingFilters[] = [
232 'group' => $other->getGroup()->getName(),
233 'filter' => $other->getName(),
234 'filterObject' => $other,
235 'globalDescription' => $globalDescription,
236 'contextDescription' => $contextDescription,
239 throw new MWException(
'You can only pass in a ChangesListFilterGroup or a ChangesListFilter' );
254 throw new MWException(
'Supersets can only be defined for filters in the same group' );
257 $this->subsetFilters[] = [
260 'group' => $other->
getGroup()->getName(),
307 return $this->label !==
null;
334 if ( $this->cssClassSuffix !==
null ) {
349 if ( $this->isRowApplicableCallable ===
null ) {
353 if ( call_user_func( $this->isRowApplicableCallable, $ctx, $rc ) ) {
382 $conflicts = array_merge(
383 $this->conflictingGroups,
384 $this->conflictingFilters
387 foreach ( $conflicts as $conflictInfo ) {
388 unset( $conflictInfo[
'filterObject'] );
389 unset( $conflictInfo[
'groupObject'] );
390 $output[
'conflicts'][] = $conflictInfo;
393 $conflictInfo[
'globalDescription'],
394 $conflictInfo[
'contextDescription']
416 function ( $conflictDesc ) {
417 return $conflictDesc[
'groupObject' ];
430 function ( $conflictDesc ) {
431 return $conflictDesc[
'filterObject' ];
447 foreach ( $this->
getSiblings() as $siblingFilter ) {
448 if ( $siblingFilter->isSelected( $opts ) && !$siblingFilter->hasConflictWithGroup(
$group ) ) {
471 foreach ( $this->
getSiblings() as $siblingFilter ) {
473 $siblingFilter->isSelected( $opts ) &&
474 !$siblingFilter->hasConflictWithFilter(
$filter )