本文整理汇总了PHP中Zend\Http\Headers::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Headers::toArray方法的具体用法?PHP Headers::toArray怎么用?PHP Headers::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Http\Headers
的用法示例。
在下文中一共展示了Headers::toArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareResponseHeaders
/**
* Normalize headers to use with HeaderAwareResponseInterface.
*
* Ensures multi-value headers are represented as a single string, via
* comma concatenation.
*
* @param Headers $headers
* @return array
*/
private function prepareResponseHeaders(Headers $headers)
{
$normalized = [];
foreach ($headers->toArray() as $name => $value) {
$normalized[$name] = is_array($value) ? implode(', ', $value) : $value;
}
return $normalized;
}
示例2: __invoke
/**
* Retrieve Mobile-detect service
* @param \Zend\Http\Headers $oHeaders
* @return \Mobile_Detect
*/
public function __invoke(\Zend\Http\Headers $oHeaders = null)
{
$oMobileDetect = $this->getServiceLocator()->getServiceLocator()->get('MobileDetect');
if ($oHeaders) {
$oMobileDetect->setHttpHeaders($oHeaders->toArray());
$oMobileDetect->setUserAgent($oHeaders->get('user-agent')->getFieldValue());
}
return $oMobileDetect;
}
示例3: __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;
}
示例4: testHeadersCanBeCastToArray
public function testHeadersCanBeCastToArray()
{
$headers = new Headers();
$headers->addHeaders(array('Foo' => 'bar', 'Baz' => 'baz'));
$this->assertEquals(array('Foo' => 'bar', 'Baz' => 'baz'), $headers->toArray());
}
示例5: testCastingToArrayReturnsMultiHeadersAsArrays
public function testCastingToArrayReturnsMultiHeadersAsArrays()
{
$headers = new Headers();
$cookie1 = new Header\SetCookie('foo', 'bar');
$cookie2 = new Header\SetCookie('bar', 'baz');
$headers->addHeader($cookie1);
$headers->addHeader($cookie2);
$array = $headers->toArray();
$expected = array('Set-Cookie' => array($cookie1->getFieldValue(), $cookie2->getFieldValue()));
$this->assertEquals($expected, $array);
}
示例6: __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;
}