本文整理汇总了PHP中Zend\Http\Request::isXmlHttpRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::isXmlHttpRequest方法的具体用法?PHP Request::isXmlHttpRequest怎么用?PHP Request::isXmlHttpRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Http\Request
的用法示例。
在下文中一共展示了Request::isXmlHttpRequest方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init(Request $request)
{
if (!$request->isXmlHttpRequest() || !$request->isPost()) {
$this->noAccess();
}
$this->post = $request->getPost();
}
示例2: render
public function render($template = null, $leftWidth = 2, $force = false)
{
$template = $template ? 'discussion/helper/' . $template . '/' . $template : $this->getOption('template');
if ($force || !$this->request->isXmlHttpRequest()) {
return $this->renderer->render($template, ['discussions' => $this->discussions, 'isArchived' => $this->archived, 'object' => $this->getObject(), 'forum' => $this->getForum(), 'leftWidth' => $leftWidth]);
} else {
return '';
}
}
示例3: build
/**
* @param HttpRequest $request
*
* @return \Zend\View\Model\ViewModel
*/
public function build(HttpRequest $request, SmartServiceResult $result, $action)
{
$viewModel = null;
if ($request->isXmlHttpRequest()) {
$viewModel = new JsonModel();
$viewModel->setTerminal(true);
} else {
$viewModel = new \Zend\View\Model\ViewModel();
$viewModel->setVariable('entity', $result->getEntity());
$viewModel->setVariable('form', $result->getForm());
$viewModel->setVariable('list', $result->getList());
$viewModel->setTemplate(sprintf($this->getTemplate(), $action));
}
return $viewModel;
}
示例4: testRequestIsXmlHttpRequest
public function testRequestIsXmlHttpRequest()
{
$request = new Request();
$this->assertFalse($request->isXmlHttpRequest());
$request = new Request();
$request->getHeaders()->addHeaderLine('X_REQUESTED_WITH', 'FooBazBar');
$this->assertFalse($request->isXmlHttpRequest());
$request = new Request();
$request->getHeaders()->addHeaderLine('X_REQUESTED_WITH', 'XMLHttpRequest');
$this->assertTrue($request->isXmlHttpRequest());
}