bundles/BlockManagerBundle/EventListener/SerializerListener.php
public function onView(GetResponseForControllerResultEvent $event): void
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $request = $event->getRequest();
        $value = $event->getControllerResult();
        if (!$value instanceof AbstractValue) {
            return;
        }

        $context = [];
        if ($request->query->get('html') === 'false') {
            $context['disable_html'] = true;
        }

        $response = new JsonResponse(null, $value->getStatusCode());
        $response->setContent(
            $this->serializer->serialize($value, 'json', $context)
        );

        $event->setResponse($response);
    }
public function onView(GetResponseForControllerResultEvent $event): void
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $request = $event->getRequest();
        $value = $event->getControllerResult();
        if (!$value instanceof AbstractValue) {
            return;
        }

        $context = [];
        if ($request->query->get('html') === 'false') {
            $context['disable_html'] = true;
        }

        $response = new JsonResponse(null, $value->getStatusCode());
        $response->setContent(
            $this->serializer->serialize($value, 'json', $context)
        );

        $event->setResponse($response);
    }
public function onView ( GetResponseForControllerResultEvent $ event ) : void { if ( ! $ event -> isMasterRequest ( ) ) { return ; } $ request = $ event -> getRequest ( ) ; $ value = $ event -> getControllerResult ( ) ; if ( ! $ value instanceof AbstractValue ) { return ; } $ context = [ ] ; if ( $ request -> query -> get ( 'html' ) === 'false' ) { $ context [ 'disable_html' ] = true ; } $ response = new JsonResponse ( null , $ value -> getStatusCode ( ) ) ; $ response -> setContent ( $ this -> serializer -> serialize ( $ value , 'json' , $ context ) ) ; $ event -> setResponse ( $ response ) ; }
Serializes the value provided by the event.
Serializes the value provided by the event .