Skip to content

Commit

Permalink
Added validation exception handler
Browse files Browse the repository at this point in the history
  • Loading branch information
sleeping-owl committed Oct 15, 2014
1 parent ef55f06 commit c0a533d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/SleepingOwl/Admin/Admin.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php namespace SleepingOwl\Admin;

use App;
use Redirect;
use SleepingOwl\Admin\Exceptions\ValidationException;
use SleepingOwl\Html\FormBuilder;
use SleepingOwl\Html\HtmlBuilder;
use SleepingOwl\Admin\Menu\MenuItem;
Expand Down Expand Up @@ -90,6 +93,8 @@ function __construct(HtmlBuilder $htmlBuilder, FormBuilder $formBuilder, Finder
$this->models = new Models;

$this->requireBootstrap();

$this->registerValidateExceptionHandler();
}

/**
Expand Down Expand Up @@ -139,4 +144,14 @@ public static function menu($model = null)
{
return new MenuItem($model);
}

/**
*
*/
protected function registerValidateExceptionHandler()
{
App::error(function (ValidationException $e) {
return Redirect::back()->withInput()->withErrors($e->getErrors());
});
}
}
2 changes: 1 addition & 1 deletion src/docs/08_License.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
```AsciiDoc
The MIT License (MIT)

Copyright 2014 SleepingOwl <sleeping-owl@gmail.com>
Copyright 2014 SleepingOwl <owl.sleeping@yahoo.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down

0 comments on commit c0a533d

Please sign in to comment.