User Signup using PHP Command Pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class SignupCommand extends AbstractCommand { | |
private $oUser = null; | |
private $data = array(); | |
function __construct($oUser, $data) { | |
$this->oUser = $oUser; | |
$this->data = $data; | |
} | |
protected function processCommand() { | |
return $this->oUser->Create($this->data); | |
} | |
} | |
$oUser = new User(); /* Dummy User Object*/ | |
$data = array( | |
'name' => "John Doe", | |
'username' => "jdoe", | |
'email' => "john@doe.com", | |
); | |
/* Example */ | |
$oSignupCommand = new SignupCommand($oUser, $data); | |
$isExecuted = $oSignupCommand->execute()->isExecuted(); | |
if($isExecuted){ | |
//handle success | |
}else{ | |
//handle error | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment