Skip to content

Instantly share code, notes, and snippets.

@MikSDigital
Created February 15, 2017 14:41
Show Gist options
  • Save MikSDigital/0810a567edff7c1470c81a299d5b38e3 to your computer and use it in GitHub Desktop.
Save MikSDigital/0810a567edff7c1470c81a299d5b38e3 to your computer and use it in GitHub Desktop.
UserSubscribe controller, Class ApiUserSubscriptionController
<?php
namespace Manager\ManagerBundle\Controller\Management;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use FOS\RestBundle\View\View;
/**
* Class ApiUserSubscriptionController
*
*/
class ApiUserSubscriptionController extends Controller
{
/**
* @Route("api/subscribe", name="subscribe", defaults={"_format":"json"})
* @Template()
* @Method({"POST"})
*/
public function subscribeUserAction(Request $oRequest)
{
if ($oRequest->getMethod() == 'POST')
{
return $this->get('fos_rest.view_handler')
->handle(
View::create()
->setStatusCode(200)
->setData(array(
'language'=>$oRequest->getLanguages(),
'fields' =>$oRequest->request->all()
))
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment