Skip to content

Instantly share code, notes, and snippets.

@yuxel
Created July 19, 2010 18:46
Show Gist options
  • Save yuxel/481801 to your computer and use it in GitHub Desktop.
Save yuxel/481801 to your computer and use it in GitHub Desktop.
class Service_Exception
{
private $errors;
public put($errorCode, $errrorMessage="Undefined" )
{
array_push(
}
public throwIfAnyException()
{
if ( !empty($errors)) {
throw new Exception(serialize($errors);
}
}
public static resolveExceptions($errors) {
return unserialize($errors);
}
}
abstract class Service_Common_Abstract
{
private $serviceException;
public __construct() {
$this->serviceException = new ServiceException();
}
}
class UserService extends Service_Common_Abstract implements UserService_Interface{
public function register() {
if ( $this->isUserExists($user) ) {
$this->serviceException->put(1,"USER_ALREADY_EXISTS");
}
if ( $this->isEmailExists($User) ) {
$this->serviceException->put(2,"EMAIL_ALREADY_EXISTS");
}
$this->serviceException->throwIfAnyException();
}
}
class userController {
function index() {
try {
$user = new ServiceUser();
$user->register($user);
}
catch(Exception $e) {
Service_Exception::resolveException($e->getMessage());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment