user = $user; $this->userOptionsLookup = $userOptionsLookup; $this->optionName = $optionName; $this->requirementName = $requirementName; $this->title = $title; $this->helper = new OverrideableRequirementHelper( $request, $requirementName ); } /** * @inheritDoc */ public function getName(): string { return $this->requirementName; } /** * Checks whether the user preference is enabled or not. Returns true if * enabled AND title is not null. * * @internal * * @return bool */ public function isPreferenceEnabled(): bool { $user = $this->user; $userOptionsLookup = $this->userOptionsLookup; $optionValue = $userOptionsLookup->getOption( $user, $this->optionName ); // Check for 0, '0' or 'disabled'. // Any other value will be handled as enabled. $isEnabled = $optionValue && $optionValue !== 'disabled'; return $this->title && $isEnabled; } /** * @inheritDoc */ public function isMet(): bool { $override = $this->helper->isMet(); return $override ?? $this->isPreferenceEnabled(); } }