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


PHP Parameter::getSentAs方法代码示例

本文整理汇总了PHP中Guzzle\Service\Description\Parameter::getSentAs方法的典型用法代码示例。如果您正苦于以下问题:PHP Parameter::getSentAs方法的具体用法?PHP Parameter::getSentAs怎么用?PHP Parameter::getSentAs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Guzzle\Service\Description\Parameter的用法示例。


在下文中一共展示了Parameter::getSentAs方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addPrefixedHeaders

 /**
  * Add a prefixed array of headers to the request
  *
  * @param RequestInterface $request Request to update
  * @param Parameter        $param   Parameter object
  * @param array            $value   Header array to add
  *
  * @throws InvalidArgumentException
  */
 protected function addPrefixedHeaders(RequestInterface $request, Parameter $param, $value)
 {
     if (!is_array($value)) {
         throw new InvalidArgumentException('An array of mapped headers expected, but received a single value');
     }
     $prefix = $param->getSentAs();
     foreach ($value as $headerName => $headerValue) {
         $request->setHeader($prefix . $headerName, $headerValue);
     }
 }
开发者ID:xkeygmbh,项目名称:ifresco-php,代码行数:19,代码来源:HeaderVisitor.php

示例2: processPrefixedHeaders

 protected function processPrefixedHeaders(Response $response, Parameter $param, &$value)
 {
     if ($prefix = $param->getSentAs()) {
         $container = $param->getName();
         $len = strlen($prefix);
         foreach ($response->getHeaders()->toArray() as $key => $header) {
             if (stripos($key, $prefix) === 0) {
                 $value[$container][substr($key, $len)] = count($header) == 1 ? end($header) : $header;
             }
         }
     }
 }
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:12,代码来源:HeaderVisitor.php

示例3: processPrefixedHeaders

 /**
  * Process a prefixed header array
  *
  * @param Response  $response Response that contains the headers
  * @param Parameter $param    Parameter object
  * @param array     $value    Value response array to modify
  */
 protected function processPrefixedHeaders(Response $response, Parameter $param, &$value)
 {
     // Grab prefixed headers that should be placed into an array with the prefix stripped
     if ($prefix = $param->getSentAs()) {
         $container = $param->getName();
         $len = strlen($prefix);
         // Find all matching headers and place them into the containing element
         foreach ($response->getHeaders() as $key => $header) {
             if (stripos($key, $prefix) === 0) {
                 // Account for multi-value headers
                 $value[$container][substr($key, $len)] = count($header) == 1 ? end($header) : $header;
             }
         }
     }
 }
开发者ID:KANU82,项目名称:guzzle,代码行数:22,代码来源:HeaderVisitor.php

示例4: visit

 /**
  * {@inheritdoc}
  */
 public function visit(CommandInterface $command, RequestInterface $request, Parameter $param, $value)
 {
     $filteredValue = $param->filter($value);
     if (null !== $this->serializer && (is_object($filteredValue) || is_array($filteredValue))) {
         switch ($param->getSentAs()) {
             case 'json':
                 $request->setHeader('Content-Type', 'application/json');
                 $contentType = 'json';
                 break;
             case 'yml':
             case 'yaml':
                 $request->setHeader('Content-Type', 'application/yaml');
                 $contentType = 'yml';
                 break;
             default:
                 $request->setHeader('Content-Type', 'application/xml');
                 $contentType = 'xml';
                 break;
         }
         $context = SerializationContext::create();
         if (null !== ($groups = $param->getData('jms_serializer.groups'))) {
             $context->setGroups($groups);
         }
         if (null !== ($version = $param->getData('jms_serializer.version'))) {
             $context->setVersion($version);
         }
         if (null !== ($nulls = $param->getData('jms_serializer.serialize_nulls'))) {
             $context->setSerializeNull($nulls);
         }
         if (true === $param->getData('jms_serializer.max_depth_checks')) {
             $context->enableMaxDepthChecks();
         }
         $value = $this->serializer->serialize($filteredValue, $contentType, $context);
     }
     parent::visit($command, $request, $param, $value);
 }
开发者ID:aciliainternet,项目名称:guzzle-bundle,代码行数:39,代码来源:JMSSerializerBodyVisitor.php

示例5: addLinkParam

 /**
  * Prepares and stores the description for a link parameter
  *
  * Prepares and stores the data describing a link parameter, to be
  * later used by getLinksParameter() to describe all the links.
  *
  * @param \Guzzle\Service\Command\CommandInterface $command
  * @param \Guzzle\Service\Description\Parameter    $parameter
  */
 public function addLinkParam(CommandInterface $command, Parameter $parameter)
 {
     $params = array();
     if (isset($this->params[$command])) {
         $params = $this->params[$command];
     }
     // Store parameter definition for later
     $params[$parameter->getName()] = array('name' => $parameter->getName(), 'description' => $parameter->getDescription(), 'required' => $parameter->getRequired(), 'sentAs' => $parameter->getSentAs(), 'type' => 'object', 'properties' => array('class' => array('type' => 'string', 'required' => true, 'pattern' => '/^[a-z_]+$/'), 'href' => array('type' => 'string', 'required' => true, 'pattern' => '#^/api/v2/#')));
     $this->params[$command] = $params;
 }
开发者ID:dh-open,项目名称:desk-php,代码行数:19,代码来源:JsonVisitor.php

示例6: testCanBuildUpParams

 public function testCanBuildUpParams()
 {
     $p = new Parameter(array());
     $p->setName('foo')->setDescription('c')->setFilters(array('d'))->setLocation('e')->setSentAs('f')->setMaxLength(1)->setMinLength(1)->setMinimum(2)->setMaximum(2)->setMinItems(3)->setMaxItems(3)->setRequired(true)->setStatic(true)->setDefault('h')->setType('i');
     $p->addFilter('foo');
     $this->assertEquals('foo', $p->getName());
     $this->assertEquals('h', $p->getDefault());
     $this->assertEquals('c', $p->getDescription());
     $this->assertEquals(array('d', 'foo'), $p->getFilters());
     $this->assertEquals('e', $p->getLocation());
     $this->assertEquals('f', $p->getSentAs());
     $this->assertEquals(1, $p->getMaxLength());
     $this->assertEquals(1, $p->getMinLength());
     $this->assertEquals(2, $p->getMaximum());
     $this->assertEquals(2, $p->getMinimum());
     $this->assertEquals(3, $p->getMaxItems());
     $this->assertEquals(3, $p->getMinItems());
     $this->assertEquals(true, $p->getRequired());
     $this->assertEquals(true, $p->getStatic());
     $this->assertEquals('i', $p->getType());
 }
开发者ID:Frinstio,项目名称:AlfredWorkflow.com,代码行数:21,代码来源:ParameterTest.php


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