enabled = true; $this->autoCreateActions = $config['actions']; $this->genPattern = new Pattern( 'genPattern', $config['genPattern'] ); if ( isset( $config['matchPattern'] ) ) { $this->matchPattern = new Pattern( 'matchPattern', $config['matchPattern'] ); } else { $this->matchPattern = $this->genPattern; } $this->serialProviderConfig = $config['serialProvider']; $this->serialMappingConfig = $config['serialMapping']; } if ( isset( $config['reservedPattern'] ) ) { $this->reservedPattern = new Pattern( 'reservedPattern', $config['reservedPattern'] ); } } public function isEnabled() { return $this->enabled; } public function isAutoCreateAction( string $action ) { if ( $action === 'create' ) { $action = 'edit'; } return $this->enabled && in_array( $action, $this->autoCreateActions, true ); } public function shouldAutoCreate( Authority $authority, string $action ) { return $this->isAutoCreateAction( $action ) && !$authority->isRegistered() && $authority->isAllowed( 'createaccount' ); } public function isTempName( string $name ) { return $this->enabled && $this->matchPattern->isMatch( $name ); } public function isReservedName( string $name ) { return ( $this->enabled && $this->matchPattern->isMatch( $name ) ) || ( $this->reservedPattern && $this->reservedPattern->isMatch( $name ) ); } public function getPlaceholderName(): string { if ( $this->enabled ) { return $this->genPattern->generate( '*' ); } else { throw new BadMethodCallException( __METHOD__ . ' is disabled' ); } } /** * @internal For TempUserCreator only * @return Pattern */ public function getGeneratorPattern(): Pattern { if ( $this->enabled ) { return $this->genPattern; } else { throw new BadMethodCallException( __METHOD__ . ' is disabled' ); } } /** * @internal For TempUserCreator only * @return array */ public function getSerialProviderConfig(): array { return $this->serialProviderConfig; } /** * @internal For TempUserCreator only * @return array */ public function getSerialMappingConfig(): array { return $this->serialMappingConfig; } }