<?php
/**
* A concrete filter for validating the username. This filter may intercept the
- * filter chain if no username is given or if the supplied username has an
- * invalid form. It could also intercept the filter chain if the username is
- * already taken.
+ * filter chain if no username is given or if supplied username has an invalid
+ * form. It could also intercept our filter chain if username is already taken.
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
protected function __construct () {
// Call parent constructor
parent::__construct(__CLASS__);
-
- // Set part description
- $this->setObjectDescription("A filter for username validation");
-
- // Create unique ID number
- $this->generateUniqueId();
}
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createUserNameValidatorFilter () {
+ public final static function createUserNameValidatorFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new UserNameValidatorFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
// If this instance is created then the username *does* exist
try {
// Get a new instance
- $userInstance = call_user_func_array(array($this->getConfigInstance()->readConfig('user_class'), "createUserByUsername"), array($userName));
+ $userInstance = call_user_func_array(array($this->getConfigInstance()->readConfig('user_class'), 'createMemberByUsername'), array($userName));
// Remember this user instance in our registry for later usage
$registry->addInstance('user', $userInstance);
}
// Does the username exist?
- if ((is_null($userInstance)) || (!$userInstance->ifUsernameExists())) {
+ if ((is_null($userInstance)) || ($userInstance->ifUsernameExists() === false)) {
// This username is still available
$alreadyTaken = false;
} // END - if