Created
August 21, 2012 20:30
-
-
Save martianboy/3419153 to your computer and use it in GitHub Desktop.
Improvments for Reza's Controller class
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
protected $args = array(); | |
public function __construct($arguments = NULL){ | |
$this->_repository = new \db\model\repository(); | |
$this->_result['error'] = false; | |
$this->_result['body'] = "Working in construct of controller\n"; | |
$this->_result['message'] = ""; | |
if (is_array($arguments)) | |
$this->args = $arguments; | |
} | |
protected function getRequestParameters() { | |
return $this->args; | |
} | |
public function create(){ | |
parse_str(implode('&', $this->getRequestParameters()),$arguments); | |
// Have to check to the arguements; | |
$refinedArguments = $this->__refine($arguments); | |
$newPerson = $this->_repository->create($refinedArguments); | |
$id = $newPerson->save(); | |
$this->_result['id'] = $id; | |
$this->_result['body'] = "Person named $newPerson->fname was created with the ID $id"; | |
return $this->_result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment