Skip to content

Instantly share code, notes, and snippets.

@martianboy
Created August 21, 2012 20:30
Show Gist options
  • Save martianboy/3419153 to your computer and use it in GitHub Desktop.
Save martianboy/3419153 to your computer and use it in GitHub Desktop.
Improvments for Reza's Controller class
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