Permalink
Showing with 252 additions and 234 deletions.
  1. +36 −37 Controller/ExceptionController.php
  2. +12 −1 Decoder/ContainerDecoderProvider.php
  3. +2 −2 DependencyInjection/Compiler/ConfigurationCheckPass.php
  4. +3 −3 DependencyInjection/Configuration.php
  5. +9 −9 DependencyInjection/FOSRestExtension.php
  6. +6 −6 EventListener/BodyListener.php
  7. +11 −11 EventListener/FormatListener.php
  8. +4 −4 EventListener/MimeTypeListener.php
  9. +5 −5 EventListener/ParamFetcherListener.php
  10. +5 −6 EventListener/ViewResponseListener.php
  11. +5 −6 FOSRestBundle.php
  12. +3 −3 Request/ParamFetcherInterface.php
  13. +3 −3 Request/ParamReaderInterface.php
  14. +1 −1 Resources/config/format_listener.xml
  15. +11 −12 Resources/doc/examples/RssHandler.php
  16. +4 −4 Routing/Loader/AbstractRestRouteLoader.php
  17. +2 −1 Routing/Loader/Reader/RestActionReader.php
  18. +2 −2 Routing/Loader/RestRouteLoader.php
  19. +2 −2 Routing/Loader/RestRouteLoader20.php
  20. +4 −6 Routing/Loader/RestRouteProcessor.php
  21. +18 −11 Routing/Loader/RestXmlCollectionLoader.php
  22. +19 −13 Routing/Loader/RestYamlCollectionLoader.php
  23. +4 −4 Tests/DependencyInjection/FOSRestExtensionTest.php
  24. +4 −4 Tests/EventListener/BodyListenerTest.php
  25. +0 −1 Tests/Fixtures/Controller/AnnotatedUsersController.php
  26. +2 −2 Tests/Fixtures/Etalon/annotated_users_controller.yml
  27. +2 −2 Tests/Fixtures/Etalon/users_collection.yml
  28. +1 −1 Tests/Fixtures/Etalon/users_controller.yml
  29. +2 −2 Tests/Fixtures/Routes/prefixed_users_collection.xml
  30. +2 −2 Tests/Fixtures/Routes/users_collection.xml
  31. +1 −1 Tests/Routing/Loader/LoaderTest.php
  32. +3 −3 Tests/Routing/Loader/RestRouteLoaderTest.php
  33. +1 −1 Tests/Routing/Loader/RestXmlCollectionLoaderTest.php
  34. +1 −1 Tests/Routing/Loader/RestYamlCollectionLoaderTest.php
  35. +4 −4 Tests/Util/PluralizationTest.php
  36. +1 −0 Tests/bootstrap.php
  37. +4 −4 Util/Pluralization.php
  38. +2 −2 View/RedirectView.php
  39. +3 −3 View/RouteRedirectView.php
  40. +12 −12 View/View.php
  41. +20 −21 View/ViewHandler.php
  42. +16 −16 View/ViewHandlerInterface.php
@@ -11,17 +11,17 @@
namespace FOS\RestBundle\Controller;
-use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference,
- Symfony\Component\DependencyInjection\ContainerAware,
- Symfony\Component\HttpKernel\Exception\FlattenException,
- Symfony\Component\HttpKernel\Log\DebugLoggerInterface,
- Symfony\Component\HttpFoundation\Request,
- Symfony\Component\HttpFoundation\Response;
-
-use FOS\Rest\Util\Codes,
- FOS\RestBundle\View\ViewHandler,
- FOS\RestBundle\View\View,
- FOS\RestBundle\Util\ExceptionWrapper;
+use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
+use Symfony\Component\DependencyInjection\ContainerAware;
+use Symfony\Component\HttpKernel\Exception\FlattenException;
+use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
+
+use FOS\Rest\Util\Codes;
+use FOS\RestBundle\View\ViewHandler;
+use FOS\RestBundle\View\View;
+use FOS\RestBundle\Util\ExceptionWrapper;
/**
* Custom ExceptionController that uses the view layer and supports HTTP response status code mapping
@@ -31,21 +31,20 @@ class ExceptionController extends ContainerAware
/**
* Converts an Exception to a Response.
*
- * @param FlattenException $exception A FlattenException instance
- * @param DebugLoggerInterface $logger A DebugLoggerInterface instance
- * @param string $format The format to use for rendering (html, xml, ...)
- * @param integer $code An HTTP response code
- * @param string $message An HTTP response status message
- * @param array $headers HTTP response headers
+ * @param Request $request Request
+ * @param FlattenException $exception A FlattenException instance
+ * @param DebugLoggerInterface $logger A DebugLoggerInterface instance
+ * @param string $format The format to use for rendering (html, xml, ...)
*
- * @return Response Response instance
+ * @return Response Response instance
*/
public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
{
$format = $this->getFormat($request, $format);
if (null === $format) {
$message = 'No matching accepted Response format could be determined, while handling: ';
$message.= $this->getExceptionMessage($exception);
+
return new Response($message, Codes::HTTP_NOT_ACCEPTABLE, $exception->getHeaders());
}
@@ -99,10 +98,10 @@ protected function getAndCleanOutputBuffering()
/**
* Extract the exception message
*
- * @param FlattenException $exception A FlattenException instance
- * @param array $exceptionMap
+ * @param FlattenException $exception A FlattenException instance
+ * @param array $exceptionMap
*
- * @return string Message
+ * @return string Message
*/
protected function isSubclassOf($exception, $exceptionMap)
{
@@ -127,9 +126,9 @@ protected function isSubclassOf($exception, $exceptionMap)
/**
* Extract the exception message
*
- * @param FlattenException $exception A FlattenException instance
+ * @param FlattenException $exception A FlattenException instance
*
- * @return string Message
+ * @return string Message
*/
protected function getExceptionMessage($exception)
{
@@ -142,9 +141,9 @@ protected function getExceptionMessage($exception)
/**
* Determine the status code to use for the response
*
- * @param FlattenException $exception A FlattenException instance
+ * @param FlattenException $exception A FlattenException instance
*
- * @return integer An HTTP response code
+ * @return integer An HTTP response code
*/
protected function getStatusCode($exception)
{
@@ -157,10 +156,10 @@ protected function getStatusCode($exception)
/**
* Determine the format to use for the response
*
- * @param Request $request Request instance
- * @param string $format The format to use for rendering (html, xml, ...)
+ * @param Request $request Request instance
+ * @param string $format The format to use for rendering (html, xml, ...)
*
- * @return string Encoding format
+ * @return string Encoding format
*/
protected function getFormat(Request $request, $format)
{
@@ -175,14 +174,14 @@ protected function getFormat(Request $request, $format)
/**
* Determine the parameters to pass to the view layer
*
- * @param ViewHandler $viewHandler The view handler instance
- * @param string $currentContent The current content in the output buffer
- * @param integer $code An HTTP response code
- * @param FlattenException $exception A FlattenException instance
- * @param DebugLoggerInterface $logger A DebugLoggerInterface instance
- * @param string $format The format to use for rendering (html, xml, ...)
+ * @param ViewHandler $viewHandler The view handler instance
+ * @param string $currentContent The current content in the output buffer
+ * @param integer $code An HTTP response code
+ * @param FlattenException $exception A FlattenException instance
+ * @param DebugLoggerInterface $logger A DebugLoggerInterface instance
+ * @param string $format The format to use for rendering (html, xml, ...)
*
- * @return array Template parameters
+ * @return array Template parameters
*/
protected function getParameters(ViewHandler $viewHandler, $currentContent, $code, FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
{
@@ -208,8 +207,8 @@ protected function getParameters(ViewHandler $viewHandler, $currentContent, $cod
* Note this method needs to be overridden in case another
* engine than Twig should be supported;
*
- * @param string $format The format to use for rendering (html, xml, ...)
- * @param integer $code An HTTP response code
+ * @param string $format The format to use for rendering (html, xml, ...)
+ * @param integer $code An HTTP response code
*
* @return TemplateReference
*/
@@ -30,18 +30,29 @@ class ContainerDecoderProvider extends ContainerAware implements DecoderProvider
/**
* Constructor.
*
- * @param array $decoders List of key (format) value (service ids) of decoders
+ * @param array $decoders List of key (format) value (service ids) of decoders
*/
public function __construct(array $decoders)
{
$this->decoders = $decoders;
}
+ /**
+ * @param string $format format
+ *
+ * @return boolean
+ */
public function supports($format)
{
return isset($this->decoders[$format]);
}
+ /**
+ * @param string $format format
+ *
+ * @throws \InvalidArgumentException
+ * @return FOS\Rest\Decoder\DecoderInterface
+ */
public function getDecoder($format)
{
if (!$this->supports($format)) {
@@ -11,8 +11,8 @@
namespace FOS\RestBundle\DependencyInjection\Compiler;
-use Symfony\Component\DependencyInjection\ContainerBuilder,
- Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
/**
* Checks if the SensioFrameworkExtraBundle views annotations are disabled when using the View Response listener.
@@ -11,9 +11,9 @@
namespace FOS\RestBundle\DependencyInjection;
-use Symfony\Component\Config\Definition\Builder\TreeBuilder,
- Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition,
- Symfony\Component\Config\Definition\ConfigurationInterface;
+use Symfony\Component\Config\Definition\Builder\TreeBuilder;
+use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
+use Symfony\Component\Config\Definition\ConfigurationInterface;
use FOS\Rest\Util\Codes;
@@ -11,13 +11,13 @@
namespace FOS\RestBundle\DependencyInjection;
-use Symfony\Component\Config\FileLocator,
- Symfony\Component\HttpKernel\DependencyInjection\Extension,
- Symfony\Component\DependencyInjection\Reference,
- Symfony\Component\DependencyInjection\ContainerInterface,
- Symfony\Component\DependencyInjection\ContainerBuilder,
- Symfony\Component\DependencyInjection\Loader\XmlFileLoader,
- Symfony\Component\HttpKernel\Kernel;
+use Symfony\Component\Config\FileLocator;
+use Symfony\Component\HttpKernel\DependencyInjection\Extension;
+use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Symfony\Component\HttpKernel\Kernel;
use FOS\Rest\Util\Codes;
@@ -28,7 +28,7 @@ class FOSRestExtension extends Extension
/**
* Loads the services based on your application configuration.
*
- * @param array $configs
+ * @param array $configs
* @param ContainerBuilder $container
*/
public function load(array $configs, ContainerBuilder $container)
@@ -142,7 +142,7 @@ public function load(array $configs, ContainerBuilder $container)
/**
* Check if an exception is loadable.
*
- * @param string $exception class to test
+ * @param string $exception class to test
* @throws InvalidArgumentException if the class was not found.
*/
private function testExceptionExists($exception)
@@ -13,8 +13,8 @@
use FOS\Rest\Decoder\DecoderProviderInterface;
-use Symfony\Component\HttpFoundation\ParameterBag,
- Symfony\Component\HttpKernel\Event\GetResponseEvent;
+use Symfony\Component\HttpFoundation\ParameterBag;
+use Symfony\Component\HttpKernel\Event\GetResponseEvent;
/**
* This listener handles Request body decoding.
@@ -31,7 +31,7 @@ class BodyListener
/**
* Constructor.
*
- * @param DecoderProviderInterface $decoderProvider Provider for fetching decoders
+ * @param DecoderProviderInterface $decoderProvider Provider for fetching decoders
*/
public function __construct(DecoderProviderInterface $decoderProvider)
{
@@ -41,7 +41,7 @@ public function __construct(DecoderProviderInterface $decoderProvider)
/**
* Core request handler
*
- * @param GetResponseEvent $event The event
+ * @param GetResponseEvent $event The event
*/
public function onKernelRequest(GetResponseEvent $event)
{
@@ -50,9 +50,9 @@ public function onKernelRequest(GetResponseEvent $event)
if (!count($request->request->all())
&& in_array($request->getMethod(), array('POST', 'PUT', 'PATCH', 'DELETE'))
) {
- $content_type = $request->headers->get('Content-Type');
+ $contentType = $request->headers->get('Content-Type');
- $format = null === $content_type
+ $format = null === $contentType
? $request->getRequestFormat()
: $request->getFormat($request->headers->get('Content-Type'));
@@ -11,12 +11,12 @@
namespace FOS\RestBundle\EventListener;
-use Symfony\Component\HttpKernel\Event\FilterControllerEvent,
- Symfony\Component\HttpKernel\Exception\HttpException,
- Symfony\Component\HttpKernel\HttpKernelInterface;
+use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
+use Symfony\Component\HttpKernel\Exception\HttpException;
+use Symfony\Component\HttpKernel\HttpKernelInterface;
-use FOS\Rest\Util\Codes,
- FOS\Rest\Util\FormatNegotiatorInterface;
+use FOS\Rest\Util\Codes;
+use FOS\Rest\Util\FormatNegotiatorInterface;
/**
* This listener handles Accept header format negotiations.
@@ -48,10 +48,10 @@ class FormatListener
/**
* Initialize FormatListener.
*
- * @param FormatNegotiatorInterface $formatNegotiator The content negotiator service to use
- * @param string $fallbackFormat Default fallback format
- * @param array $defaultPriorities Ordered array of formats (highest priority first)
- * @param Boolean $preferExtension If to consider the extension last or first
+ * @param FormatNegotiatorInterface $formatNegotiator The content negotiator service to use
+ * @param string $fallbackFormat Default fallback format
+ * @param array $defaultPriorities Ordered array of formats (highest priority first)
+ * @param Boolean $preferExtension If to consider the extension last or first
*/
public function __construct(FormatNegotiatorInterface $formatNegotiator, $fallbackFormat, array $defaultPriorities = array(), $preferExtension = false)
{
@@ -64,7 +64,7 @@ public function __construct(FormatNegotiatorInterface $formatNegotiator, $fallba
/**
* Determines and sets the Request format
*
- * @param GetResponseEvent $event The event
+ * @param GetResponseEvent $event The event
*/
public function onKernelController(FilterControllerEvent $event)
{
@@ -91,7 +91,7 @@ public function onKernelController(FilterControllerEvent $event)
}
if (null === $format) {
- if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) {
+ if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) {
throw new HttpException(Codes::HTTP_NOT_ACCEPTABLE, "No matching accepted Response format could be determined");
}
@@ -11,8 +11,8 @@
namespace FOS\RestBundle\EventListener;
-use Symfony\Component\HttpKernel\Event\GetResponseEvent,
- Symfony\Component\HttpKernel\HttpKernelInterface;
+use Symfony\Component\HttpKernel\Event\GetResponseEvent;
+use Symfony\Component\HttpKernel\HttpKernelInterface;
/**
* This listener handles registering custom mime types.
@@ -29,7 +29,7 @@ class MimeTypeListener
/**
* Constructor.
*
- * @param array $mimeTypes key format, value mime type
+ * @param array $mimeTypes key format, value mime type
*/
public function __construct(array $mimeTypes)
{
@@ -39,7 +39,7 @@ public function __construct(array $mimeTypes)
/**
* Core request handler
*
- * @param GetResponseEvent $event The event
+ * @param GetResponseEvent $event The event
*/
public function onKernelRequest(GetResponseEvent $event)
{
@@ -11,9 +11,8 @@
namespace FOS\RestBundle\EventListener;
-use Symfony\Component\HttpKernel\Event\FilterControllerEvent,
- Symfony\Component\HttpKernel\HttpKernelInterface,
- Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
+use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* This listener handles various setup tasks related to the query fetcher
@@ -35,7 +34,8 @@ class ParamFetcherListener
/**
* Constructor.
*
- * @param ContainerInterface $container container
+ * @param ContainerInterface $container container
+ * @param boolean $setParamsAsAttributes params as attributes
*/
public function __construct(ContainerInterface $container, $setParamsAsAttributes = false)
{
@@ -46,7 +46,7 @@ public function __construct(ContainerInterface $container, $setParamsAsAttribute
/**
* Core controller handler
*
- * @param FilterControllerEvent $event The event
+ * @param FilterControllerEvent $event The event
*/
public function onKernelController(FilterControllerEvent $event)
{
Oops, something went wrong.

0 comments on commit b2c9f9c

Please sign in to comment.