当前位置: 首页>>代码示例>>PHP>>正文


PHP Headers::toArray方法代码示例

本文整理汇总了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;
 }
开发者ID:DenLilleMand,项目名称:christianssite,代码行数:17,代码来源:ZendHttpClientDecorator.php

示例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;
 }
开发者ID:zhangyuxiao,项目名称:qoros,代码行数:14,代码来源:MobileDetectHelper.php

示例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;
 }
开发者ID:neilime,项目名称:zf2-mobile-detect,代码行数:20,代码来源:MobileDetectPlugin.php

示例4: testHeadersCanBeCastToArray

 public function testHeadersCanBeCastToArray()
 {
     $headers = new Headers();
     $headers->addHeaders(array('Foo' => 'bar', 'Baz' => 'baz'));
     $this->assertEquals(array('Foo' => 'bar', 'Baz' => 'baz'), $headers->toArray());
 }
开发者ID:JojoBombardo,项目名称:zf2,代码行数:6,代码来源:HeadersTest.php

示例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);
 }
开发者ID:navassouza,项目名称:zf2,代码行数:11,代码来源:HeadersTest.php

示例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;
 }
开发者ID:neilime,项目名称:zf2-mobile-detect,代码行数:15,代码来源:MobileDetectHelper.php


注:本文中的Zend\Http\Headers::toArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。