const EXCEPTION_ASSERTION_FAILED = 0x037;
const EXCEPTION_FILE_CANNOT_BE_READ = 0x038;
const EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED = 0x039;
+ const EXCEPTION_FILTER_CHAIN_INTERCEPTED = 0x040;
/**
* In the super constructor these system classes shall be ignored or else
);
/**
- * Private super constructor
+ * Protected super constructor
*
* @param $className Name of the class
* @return void
*/
public function processFilters (Requestable $requestInstance, Responseable $responseInstance) {
// Run all filters
- //* DEBUG */ echo "COUNT=".count($this->filters)."<br />\n";
+ /* DEBUG */ echo "COUNT=".count($this->filters)."<br />\n";
foreach ($this->filters as $filterInstance) {
// Try to execute this filter
try {
- //* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing started.<br />\n";
+ /* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing started.<br />\n";
$filterInstance->execute($requestInstance, $responseInstance);
- //* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing ended.<br />\n";
+ /* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing ended.<br />\n";
} catch (FilterChainException $e) {
// This exception can be thrown to just skip any further processing
break;
* @param $responseInstance An instance of a class with an Responseable interface
* @return void
* @todo 0% done
+ * @throws FilterChainException If this filter fails to operate
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Try to get real discovery class
$responseInstance->addFatalMessagePlain($e->getMessage());
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} catch (ClassNotFoundException $e) {
// Something bad happend
$requestInstance->requestIsValid(false);
$responseInstance->addFatalMessagePlain($e->getMessage());
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
}
}
}
* @param $requestInstance An instance of a class with an Requestable interface
* @param $responseInstance An instance of a class with an Responseable interface
* @return void
+ * @throws FilterChainException If this filter fails to operate
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get Email from request
$responseInstance->addFatalMessage('email_unset');
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif ((empty($email1)) || (empty($email2))) {
// Email is empty
$requestInstance->requestIsValid(false);
} // END - if
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif ($this->ifEmailIsTaken($email1)) {
// Email is already taken
$requestInstance->requestIsValid(false);
$responseInstance->addFatalMessage('email_taken');
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif ($email1 != $email2) {
// Emails didn't match
$requestInstance->requestIsValid(false);
$responseInstance->addFatalMessage('emails_mismatch');
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} // END - elseif
} elseif (empty($email)) {
// Empty field!
$responseInstance->addFatalMessage('email_empty');
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} // END - elseif
}
* @param $requestInstance An instance of a class with an Requestable interface
* @param $responseInstance An instance of a class with an Responseable interface
* @return void
+ * @throws FilterChainException If this filter fails to operate
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get passwords
$responseInstance->addFatalMessage('password_unset');
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif ((empty($password1)) || (empty($password2))) {
// Password is empty
$requestInstance->requestIsValid(false);
} // END - if
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif ($password1 != $password2) {
// Passwords didn't match
$requestInstance->requestIsValid(false);
$responseInstance->addFatalMessage('pass_mismatch');
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} // END - elseif
}
}
* @param $requestInstance An instance of a class with an Requestable interface
* @param $responseInstance An instance of a class with an Responseable interface
* @return void
+ * @throws FilterChainException If this filter fails to operate
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get username from request
$responseInstance->addFatalMessage('username_unset');
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif (empty($userName)) {
// Empty field!
$requestInstance->requestIsValid(false);
$responseInstance->addFatalMessage('username_empty');
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif ($this->ifUserNameIsTaken($userName)) {
// Username is already taken
$requestInstance->requestIsValid(false);
$responseInstance->addFatalMessage('username_taken');
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
}
}
* @param $responseInstance An instance of a class with an Responseable interface
* @return void
* @throws AccountPasswordMismatchException If the account password does not match
+ * @throws FilterChainException If this filter fails to operate
* @todo Rewrite handling of different password fields
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
$responseInstance->addFatalMessage('password_unset');
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} // END - if
} // END - if
$responseInstance->addFatalMessage('password_empty');
// Abort here
- return false;
- }
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
+ } // END - if
// Get a user instance
$userInstance = Registry::getRegistry()->getInstance('user');
* @param $responseInstance An instance of a class with an Responseable interface
* @return void
* @throws NullPointerException If the user instance from registry is null
+ * @throws FilterChainException If this filter fails to operate
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get confirmation code from request
$responseInstance->addFatalMessage('confirm_code_unset');
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif (empty($confirmCode)) {
// Email is empty
$requestInstance->requestIsValid(false);
$responseInstance->addFatalMessage('confirm_code_empty');
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
}
// Get a user instance from registry
* @param $requestInstance An instance of a class with an Requestable interface
* @param $responseInstance An instance of a class with an Responseable interface
* @return void
+ * @throws FilterChainException If this filter fails to operate
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get password
$responseInstance->addFatalMessage('password_unset');
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif (empty($password)) {
// Password is empty
$requestInstance->requestIsValid(false);
$responseInstance->addFatalMessage('password_empty');
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
}
}
}
* @param $requestInstance An instance of a class with an Requestable interface
* @param $responseInstance An instance of a class with an Responseable interface
* @return void
+ * @throws FilterChainException If this filter fails to operate
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get password
$responseInstance->addFatalMessage('password_unset');
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif (empty($password)) {
// Password is empty
$requestInstance->requestIsValid(false);
$responseInstance->addFatalMessage('password_empty');
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
}
}
}
* @param $requestInstance An instance of a class with an Requestable interface
* @param $responseInstance An instance of a class with an Responseable interface
* @return void
+ * @throws FilterChainException If this filter fails to operate
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get username from request
$responseInstance->addFatalMessage('username_guest_unset');
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif (empty($userName)) {
// Empty field!
$requestInstance->requestIsValid(false);
$responseInstance->addFatalMessage('username_guest_empty');
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif ($this->ifUserGuestIsTaken($userName) === false) {
// Username is already taken
$requestInstance->requestIsValid(false);
$responseInstance->addFatalMessage('username_guest_not_found');
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
}
// Set the element for compatiblity reasons
* @param $requestInstance An instance of a class with an Requestable interface
* @param $responseInstance An instance of a class with an Responseable interface
* @return void
+ * @throws FilterChainException If this filter fails to operate
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get username from request
$responseInstance->addFatalMessage('username_unset');
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif (empty($userName)) {
// Empty field!
$requestInstance->requestIsValid(false);
$responseInstance->addFatalMessage('username_empty');
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif ($this->ifUserNameIsTaken($userName) === false) {
// Username is already taken
$requestInstance->requestIsValid(false);
$responseInstance->addFatalMessage('username_not_found');
// Abort here
- return false;
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
}
}
<?php
/**
- * A registry for several data types
+ * A registry for several data types and objects. Objects should be added by
+ * addInstance() and therefore must implement the interface Registerable.
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
if (is_null(self::$registryInstance)) {
// Not yet, so create one
self::$registryInstance = new Registry();
- }
+ } // END - if
// Return the instance
return self::$registryInstance;
// Is the instance there?
if ($this->instanceExists($instanceKey)) {
$objectInstance = $this->instanceRegistry[$instanceKey];
- }
+ } // END - if
// Return the result
return $objectInstance;