本文整理汇总了PHP中Mobile_Detect::setHttpHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP Mobile_Detect::setHttpHeaders方法的具体用法?PHP Mobile_Detect::setHttpHeaders怎么用?PHP Mobile_Detect::setHttpHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mobile_Detect
的用法示例。
在下文中一共展示了Mobile_Detect::setHttpHeaders方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __invoke
/**
* Retrieve Mobile-detect service
*
* @param \Zend\Http\Headers $oHeaders
*
* @throws \LogicException
* @return \Mobile_Detect
*/
public function __invoke(\Zend\Http\Headers $oHeaders = null)
{
$oController = $this->getController();
if (!$oController) {
throw new \LogicException('Controller is undefined for MobileDetect controller plugin');
}
if ($oHeaders) {
$this->mobileDetect->setHttpHeaders($oHeaders->toArray());
$this->mobileDetect->setUserAgent($oHeaders->get('user-agent')->getFieldValue());
}
return $this->mobileDetect;
}
示例2: testSetHttpHeaders
/**
* Headers should be reset when you use setHttpHeaders.
* @covers Mobile_Detect::setHttpHeaders
* @issue #144
*/
public function testSetHttpHeaders()
{
$header1 = array('HTTP_PINK_PONY' => 'I secretly love ponies >_>');
$md = new Mobile_Detect($header1);
$this->assertSame($md->getHttpHeaders(), $header1);
$header2 = array('HTTP_FIRE_BREATHING_DRAGON' => 'yeah!');
$md->setHttpHeaders($header2);
$this->assertSame($md->getHttpHeaders(), $header2);
}
示例3: testSetCfHeaders
/**
* Read response from cloudfront, if the cloudfront headers are detected
* @covers Mobile_Detect::setCfHeaders
*/
public function testSetCfHeaders()
{
// Test mobile detected
$header1 = array('HTTP_CLOUDFRONT_IS_DESKTOP_VIEWER' => 'false', 'HTTP_CLOUDFRONT_IS_MOBILE_VIEWER' => 'true', 'HTTP_CLOUDFRONT_IS_TABLET_VIEWER' => 'false');
$md = new Mobile_Detect($header1);
$this->assertSame($md->getCfHeaders(), $header1);
$this->assertSame($md->getUserAgent(), 'Amazon CloudFront');
$this->assertSame($md->isTablet(), false);
$this->assertSame($md->isMobile(), true);
// Test neither mobile nor tablet (desktop)
$header2 = array('HTTP_CLOUDFRONT_IS_DESKTOP_VIEWER' => 'true', 'HTTP_CLOUDFRONT_IS_MOBILE_VIEWER' => 'false', 'HTTP_CLOUDFRONT_IS_TABLET_VIEWER' => 'false');
$md->setHttpHeaders($header2);
$this->assertSame($md->getCfHeaders(), $header2);
$this->assertSame($md->getUserAgent(), 'Amazon CloudFront');
$this->assertSame($md->isTablet(), false);
$this->assertSame($md->isMobile(), false);
// Test tablet detected
$header3 = array('HTTP_CLOUDFRONT_IS_DESKTOP_VIEWER' => 'false', 'HTTP_CLOUDFRONT_IS_MOBILE_VIEWER' => 'false', 'HTTP_CLOUDFRONT_IS_TABLET_VIEWER' => 'true');
$md->setCfHeaders($header3);
$this->assertSame($md->getCfHeaders(), $header3);
$this->assertSame($md->getUserAgent(), 'Amazon CloudFront');
$this->assertSame($md->isTablet(), true);
$this->assertSame($md->isMobile(), false);
// Check if the headers are cleared
$header4 = array();
$md->setHttpHeaders($header4);
$this->assertSame($md->getCfHeaders(), $header4);
}
示例4: __invoke
/**
* Retrieve Mobile-detect service
*
* @param \Zend\Http\Headers $oHeaders
*
* @return \Mobile_Detect
*/
public function __invoke(\Zend\Http\Headers $oHeaders = null)
{
if ($oHeaders) {
$this->mobileDetect->setHttpHeaders($oHeaders->toArray());
$this->mobileDetect->setUserAgent($oHeaders->get('user-agent')->getFieldValue());
}
return $this->mobileDetect;
}