src/Graviton/RestBundle/Listener/SpecialMimetypeRequestListener.php
public function onKernelRequest(RestEvent $event)
    {
        $request = $event->getRequest();

        if ($request->headers->has('Accept')) {
            $format = $request->getFormat($request->headers->get('Accept'));
            if (empty($format)) {
                foreach ($this->container->getParameter('graviton.rest.special_mimetypes') as $format => $types) {
                    $mimetypes = $request->getMimeType($format);

                    if (!empty($mimetypes)) {
                        $mimetypes = is_array($mimetypes)? $mimetypes : array($mimetypes);
                        $types = array_unique(array_merge_recursive($mimetypes, $types));
                    }

                    $request->setFormat($format, $types);
                }
            }
        }
    }
public function onKernelRequest(RestEvent $event)
    {
        $request = $event->getRequest();

        if ($request->headers->has('Accept')) {
            $format = $request->getFormat($request->headers->get('Accept'));
            if (empty($format)) {
                foreach ($this->container->getParameter('graviton.rest.special_mimetypes') as $format => $types) {
                    $mimetypes = $request->getMimeType($format);

                    if (!empty($mimetypes)) {
                        $mimetypes = is_array($mimetypes)? $mimetypes : array($mimetypes);
                        $types = array_unique(array_merge_recursive($mimetypes, $types));
                    }

                    $request->setFormat($format, $types);
                }
            }
        }
    }
public function onKernelRequest ( RestEvent $ event ) { $ request = $ event -> getRequest ( ) ; if ( $ request -> headers -> has ( 'Accept' ) ) { $ format = $ request -> getFormat ( $ request -> headers -> get ( 'Accept' ) ) ; if ( empty ( $ format ) ) { foreach ( $ this -> container -> getParameter ( 'graviton.rest.special_mimetypes' ) as $ format => $ types ) { $ mimetypes = $ request -> getMimeType ( $ format ) ; if ( ! empty ( $ mimetypes ) ) { $ mimetypes = is_array ( $ mimetypes ) ? $ mimetypes : array ( $ mimetypes ) ; $ types = array_unique ( array_merge_recursive ( $ mimetypes , $ types ) ) ; } $ request -> setFormat ( $ format , $ types ) ; } } } }
Adds the configured formats and mimetypes to the request.

@param RestEvent $event Event

@return void|null
Adds the configured formats and mimetypes to the request .