我开发了一个控制器,用于使用JSON回答AJAX请求:
class PeopleController extends Controller
{
public function listAction()
{
$request = $this->getRequest();
// if ajax only is going to be used uncomment next lines
//if (!$request->isXmlHttpRequest())
//throw $this->createNotFoundException('The page is not found');
$repository = $this->getDoctrine()->getRepository('PeopleManagerBundle:People');
$items = $repository->findAll();
// yes, here we are retrieving "_format" from routing. In our case it's json
$format = $request->getRequestFormat();
return $this->render('::base.'.$format.'.twig', array('data' => $items));
}
Run Code Online (Sandbox Code Playgroud)
我启用了HTML视图,因为它对调试非常有用,但是我想限制在应用程序投入生产时使用_format = html调用此控制器的可能性.如何确定是从开发环境还是从生产环境调用控制器?
我们有一个关于Symfony2.1的webapp,我们正试图通过使用OAuth来安装一些REST Web服务.这些Web服务将由Android应用程序使用.
我们正在尝试FOSOAuthServerBundle,并且似乎可以验证来自其他网站的webservices的使用,因为auth步骤完全基于Web.
但我们需要的是下一个工作流程:
这可能吗?FOSOAuthServerBundle是我们需要的Bundle吗?如何在没有用户交互的情况下检索有效的OAuth令牌,只能使用用户名+密码作为身份验证的参数?
非常感谢.
我想知道如何确定给定的WC_Product对象$ product是否是订阅产品.