Skip to content

Instantly share code, notes, and snippets.

@shadowhand
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shadowhand/226cc11d3d7ede99dd66 to your computer and use it in GitHub Desktop.
Save shadowhand/226cc11d3d7ede99dd66 to your computer and use it in GitHub Desktop.
register controller using use case
<?php
/* snip */
$parser = $app->get('user.parse.register');
$usecase = $app->get('usecase.user.register');
$params = $this->request->post();
try
{
$user = $parser($params);
$userid = $usecase->interact($user);
// TODO: this should forward to the login use case
$this->redirect('user/login' . URL::query());
}
catch (Ushahidi\Exception\Validator $e)
{
$this->template = View::factory('user/register')
->set('error', implode(', ', Arr::flatten($e->getErrors())))
->set('form', $params);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment