-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace ONGR\FilterManagerBundle\Event; | ||
|
||
use Doctrine\Common\Proxy\Exception\InvalidArgumentException; | ||
use Symfony\Component\EventDispatcher\Event; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class ExceptionListener | ||
{ | ||
/** | ||
* @param Event $event | ||
* | ||
* @return Response | ||
*/ | ||
public function onKernelException(Event $event) | ||
{ | ||
$exception = $event->getException(); | ||
if ($exception instanceof InvalidArgumentException && | ||
$exception->getMessage() == 'Given value must not be an array' | ||
) { | ||
$response = new Response('Given value to the single choice filter must not be an array', 406); | ||
$event->setResponse($response); | ||
} | ||
} | ||
} |
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
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
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
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
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
31 changes: 31 additions & 0 deletions
31
Tests/app/fixture/TestBundle/Controller/TestController.php
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the ONGR package. | ||
* | ||
* (c) NFQ Technologies UAB <info@nfq.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace ONGR\FilterManagerBundle\Tests\app\fixture\TestBundle\Controller; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class TestController extends Controller | ||
{ | ||
/** | ||
* @param Request $request | ||
* | ||
* @return Response | ||
*/ | ||
public function testSingleChoiceExceptionAction(Request $request) | ||
{ | ||
$manager = $this->get('ongr_filter_manager.single_choice'); | ||
$result = $manager->handleRequest($request); | ||
return new Response($result); | ||
} | ||
} |