public function postMessageAction(Request $request)
    {
        $message = null;

        $form = $this->formFactory->createNamed(null, 'sonata_notification_api_form_message', $message, [
            'csrf_protection' => false,
        ]);

        $form->handleRequest($request);

        if ($form->isValid()) {
            $message = $form->getData();
            $this->messageManager->save($message);

            return $message;
        }

        return $form;
    }
public function postMessageAction(Request $request)
    {
        $message = null;

        $form = $this->formFactory->createNamed(null, 'sonata_notification_api_form_message', $message, [
            'csrf_protection' => false,
        ]);

        $form->handleRequest($request);

        if ($form->isValid()) {
            $message = $form->getData();
            $this->messageManager->save($message);

            return $message;
        }

        return $form;
    }
public function postMessageAction ( Request $ request ) { $ message = null ; $ form = $ this -> formFactory -> createNamed ( null , 'sonata_notification_api_form_message' , $ message , [ 'csrf_protection' => false , ] ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ message = $ form -> getData ( ) ; $ this -> messageManager -> save ( $ message ) ; return $ message ; } return $ form ; }
Adds a message.

@ApiDoc(
input={"class"="sonata_notification_api_form_message", "name"="", "groups"={"sonata_api_write"}},
output={"class"="Sonata\NotificationBundle\Model\Message", "groups"={"sonata_api_read"}},
statusCodes={
200="Returned when successful",
400="Returned when an error has occurred while message creation"
}
)

@View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)

@Route(requirements={"_format"="json|xml"})

@param Request $request A Symfony request

@return MessageInterface
Adds a message .