Skip to content

Commit

Permalink
Merge b1a8a03 into d377109
Browse files Browse the repository at this point in the history
  • Loading branch information
Moln committed Nov 2, 2016
2 parents d377109 + b1a8a03 commit c1f356b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
21 changes: 21 additions & 0 deletions src/ContentValidationListenerFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Zfegg\ContentValidation;

use Interop\Container\ContainerInterface;

/**
* Class ContentValidatioinListenerFactory
* @package Zfegg\ContentValidation
*/
class ContentValidationListenerFactory
{

public function __invoke(ContainerInterface $container)
{
$listener = new ContentValidationListener();
$listener->setInputFilterManager($container->get('InputFilterManager'));

return $listener;
}
}
4 changes: 2 additions & 2 deletions src/ContentValidationMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public function setInputFilter(InputFilterInterface $inputFilter)
public function __construct(InputFilterPluginManager $inputFilters = null, callable $invalidHandler = null)
{
$defaultInvalidHandler = function ($self, $request, ResponseInterface $response, $next) {
$response->withStatus(422);
$response->withHeader('Content-Type', 'application/json');
$response = $response->withStatus(422);
$response = $response->withHeader('Content-Type', 'application/json');
$response->getBody()->write(json_encode([
'status' => 422,
'detail' => 'Failed Validation',
Expand Down

0 comments on commit c1f356b

Please sign in to comment.